aboutsummaryrefslogtreecommitdiff
path: root/src/keypress_thread.c
diff options
context:
space:
mode:
authorspv <spv@spv.sh>2025-09-21 00:07:50 -0400
committerspv <spv@spv.sh>2025-09-21 00:08:43 -0400
commit38d25483657e82eb546ecb8566214f830efba461 (patch)
treeb9568debc69bffc2595df42266c5550cdf05f3d2 /src/keypress_thread.c
parent9ddf37ad959faaca72f1634dc61439cdd3c585f1 (diff)
refactoring ftw (now w/ README updates!)
Diffstat (limited to 'src/keypress_thread.c')
-rw-r--r--src/keypress_thread.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/keypress_thread.c b/src/keypress_thread.c
new file mode 100644
index 0000000..47fb1de
--- /dev/null
+++ b/src/keypress_thread.c
@@ -0,0 +1,32 @@
+// XXX includes
+
+#include "consts.h"
+#include "config.h"
+
+#include "common.h"
+
+void on_press(void) {
+ gettimeofday(last_press, NULL);
+
+ // XXX signal light thread
+}
+
+int keypress_thread(void) {
+ 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);
+
+ on_press();
+
+ usleep(DEBOUNCE);
+ }
+
+ // XXX handle SIGINT or whatever
+
+ return 0;
+}