Grab input device to stop key events reaching terminal

This commit is contained in:
Camden Dixie O'Brien
2025-10-13 20:13:36 +01:00
parent 0dc7d53bbe
commit 6d02f0947d

View File

@@ -18,14 +18,20 @@ static input_callback_t callbacks[NCALLBACKS];
int input_init() int input_init()
{ {
memset(callbacks, 0, sizeof(callbacks));
input_fd = open("/dev/input/event0", O_RDONLY); input_fd = open("/dev/input/event0", O_RDONLY);
assert(input_fd != -1); assert(input_fd != -1);
memset(callbacks, 0, sizeof(callbacks));
const int res = ioctl(input_fd, EVIOCGRAB, (void *)1);
assert(res != -1);
return input_fd; return input_fd;
} }
void input_cleanup() void input_cleanup()
{ {
ioctl(input_fd, EVIOCGRAB, (void *)0);
close(input_fd); close(input_fd);
} }