Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #195 from houqp/master

add usb charging events
  • Loading branch information...
commit 9b0cb24200aed4dfba36e9a5f1b4b32b150ad925 2 parents b46a4f5 + 7ab59e9
@dpavlin authored
Showing with 23 additions and 3 deletions.
  1. +19 −3 input.c
  2. +4 −0 keys.lua
View
22 input.c
@@ -27,8 +27,12 @@
#include <signal.h>
#define OUTPUT_SIZE 21
-#define CODE_IN_SAVER 10000
-#define CODE_OUT_SAVER 10001
+#define CODE_IN_SAVER 10000
+#define CODE_OUT_SAVER 10001
+#define CODE_USB_PLUG_IN 10010
+#define CODE_USB_PLUG_OUT 10011
+#define CODE_CHARGING 10020
+#define CODE_NOT_CHARGING 10021
#define NUM_FDS 4
int inputfds[4] = { -1, -1, -1, -1 };
@@ -78,7 +82,11 @@ static int openInputDevice(lua_State *L) {
/* listen power slider events */
while(1) {
- fp = popen("exec lipc-wait-event com.lab126.powerd goingToScreenSaver,outOfScreenSaver", "r");
+ fp = popen("exec lipc-wait-event com.lab126.powerd goingToScreenSaver,outOfScreenSaver,charging,notCharging", "r");
+ /* @TODO 07.06 2012 (houqp)
+ * plugin and out event can only be watched by:
+ lipc-wait-event com.lab126.hal usbPlugOut,usbPlugIn
+ */
if(fgets(std_out, OUTPUT_SIZE, fp) == NULL) {
break;
}
@@ -87,6 +95,14 @@ static int openInputDevice(lua_State *L) {
ev.code = CODE_IN_SAVER;
} else if(std_out[0] == 'o') {
ev.code = CODE_OUT_SAVER;
+ } else if((std_out[0] == 'u') && (std_out[7] == 'I')) {
+ ev.code = CODE_USB_PLUG_IN;
+ } else if((std_out[0] == 'u') && (std_out[7] == 'O')) {
+ ev.code = CODE_USB_PLUG_OUT;
+ } else if(std_out[0] == 'c') {
+ ev.code = CODE_CHARGING;
+ } else if(std_out[0] == 'n') {
+ ev.code = CODE_NOT_CHARGING;
} else {
printf("Unrecognized event.\n");
}
View
4 keys.lua
@@ -92,6 +92,10 @@ KEY_LPGFWD = 104
KEY_INTO_SCREEN_SAVER = 10000
KEY_OUTOF_SCREEN_SAVER = 10001
+KEY_USB_PLUG_IN = 10010
+KEY_USB_PLUG_OUT = 10011
+KEY_CHARGING = 10020
+KEY_NOT_CHARGING = 10021
-- constants from <linux/input.h>
EV_KEY = 1
Please sign in to comment.
Something went wrong with that request. Please try again.