diff options
| -rw-r--r-- | src/consts.h | 2 | ||||
| -rw-r--r-- | src/keypress_thread.c | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/consts.h b/src/consts.h index a1b2af4..efcfe1b 100644 --- a/src/consts.h +++ b/src/consts.h @@ -4,6 +4,4 @@ #define MS * 1000 #define SEC * 1000 MS -#define KEYPRESS_SIZE 72 /* XXX sys/???.h */ - #endif diff --git a/src/keypress_thread.c b/src/keypress_thread.c index d5ec6bf..4afbd61 100644 --- a/src/keypress_thread.c +++ b/src/keypress_thread.c @@ -1,3 +1,5 @@ +#include <linux/input.h> + #include "consts.h" #include "config.h" @@ -12,18 +14,20 @@ void on_press(void) { } void keypress_thread(pid_t _light_pid) { + struct input_event pressed_key; + light_pid = _light_pid; FILE* fp = fopen(KEYBOARD_FILE, "r"); fseek(fp, 0, SEEK_END); - - void* discard = malloc(KEYPRESS_SIZE); while (1) { fseek(fp, 0, SEEK_END); - fread(discard, 1, KEYPRESS_SIZE, fp); + fread(&pressed_key, 1, sizeof(pressed_key), fp); - on_press(); + if (pressed_key.value == 1) { + on_press(); + } usleep(DEBOUNCE); } |
