diff options
| author | spv <spv@spv.sh> | 2025-12-05 14:10:13 -0500 |
|---|---|---|
| committer | spv <spv@spv.sh> | 2025-12-05 14:10:24 -0500 |
| commit | df3775e6bfceac4ab6249c43cffaa348b0eee984 (patch) | |
| tree | 0f93d7a7797b13dac7f4844fde28cf9731c5a5ef /src | |
| parent | 564b38b3a254faedb38bac7b37d27c2f2d8e921f (diff) | |
use linux/input.h & ignore release events
Diffstat (limited to 'src')
| -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); } |
