blob: 47fb1de46a2d741c2d11c3b7e990857b772e7d27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}
|