Grab input device to stop key events reaching terminal

This commit is contained in:
2025-10-18 17:43:22 +01:00
parent ed09a335d4
commit 7d6be1eb14

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);
} }