From 7d6be1eb142c0ef67671dad411752ca193b719ca Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 18 Oct 2025 17:43:22 +0100 Subject: [PATCH] Grab input device to stop key events reaching terminal --- input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/input.c b/input.c index 09ff76e..bc38e66 100644 --- a/input.c +++ b/input.c @@ -18,14 +18,20 @@ static input_callback_t callbacks[NCALLBACKS]; int input_init() { + memset(callbacks, 0, sizeof(callbacks)); + input_fd = open("/dev/input/event0", O_RDONLY); assert(input_fd != -1); - memset(callbacks, 0, sizeof(callbacks)); + + const int res = ioctl(input_fd, EVIOCGRAB, (void *)1); + assert(res != -1); + return input_fd; } void input_cleanup() { + ioctl(input_fd, EVIOCGRAB, (void *)0); close(input_fd); }