Grab input device to stop key events reaching terminal
This commit is contained in:
8
input.c
8
input.c
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user