power_daemon: added lid_monitor.

Thanks Rene!
This commit is contained in:
Jérôme Duval
2013-11-14 07:42:33 +01:00
parent 8e72745123
commit 4320349447
2 changed files with 69 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright 2013, Jérôme Duval, [email protected].
* Copyright 2005, Nathan Whitehorn.
*
* Distributed under the terms of the MIT License.
*/
#include "lid_monitor.h"
#include <Messenger.h>
#include <Roster.h>
#include <stdio.h>
#include <RosterPrivate.h>
LidMonitor::LidMonitor()
{
fFD = open("/dev/power/acpi_lid/0", O_RDONLY);
}
LidMonitor::~LidMonitor()
{
if (fFD > 0)
close(fFD);
}
void
LidMonitor::HandleEvent()
{
if (fFD <= 0)
return;
uint8 status;
read(fFD, &status, 1);
if (status == 1) {
printf("lid status 1\n");
}
}
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright 2005-2013, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Nathan Whitehorn
*/
#ifndef _LID_MONITOR_H
#define _LID_MONITOR_H
class LidMonitor {
public:
LidMonitor();
~LidMonitor();
void HandleEvent();
int FD() const { return fFD; }
private:
int fFD;
};
#endif // _LID_MONITOR_H