blob: 4afbd61485079e039ddbb2bd1cc37bdc4cb93fbf (
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
33
34
35
36
37
38
|
#include <linux/input.h>
#include "consts.h"
#include "config.h"
#include "common.h"
static pid_t light_pid;
void on_press(void) {
gettimeofday(last_press, NULL);
kill(light_pid, SIGCONT);
}
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);
while (1) {
fseek(fp, 0, SEEK_END);
fread(&pressed_key, 1, sizeof(pressed_key), fp);
if (pressed_key.value == 1) {
on_press();
}
usleep(DEBOUNCE);
}
// XXX handle SIGINT or whatever
__builtin_unreachable();
}
|