diff options
Diffstat (limited to 'src/keypress_thread.c')
| -rw-r--r-- | src/keypress_thread.c | 12 |
1 files changed, 8 insertions, 4 deletions
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); } |
