summaryrefslogtreecommitdiff
path: root/render_fbdev.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2019-03-10 22:22:23 -0700
committerMichael Pavone <pavone@retrodev.com>2019-03-10 22:22:23 -0700
commitc8c04b04b5fe89e4a30dd1b88d336692a7dd260d (patch)
tree5d8d6381be824429451fc986abadfd90e06ab741 /render_fbdev.c
parent7627765cb6b379008132ddb35f7a5b22bee7df9e (diff)
Grab keyboard devices at startup so keyboard input stops going to terminal while running
Diffstat (limited to 'render_fbdev.c')
-rwxr-xr-xrender_fbdev.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/render_fbdev.c b/render_fbdev.c
index 5f84cb1..e9624df 100755
--- a/render_fbdev.c
+++ b/render_fbdev.c
@@ -1297,6 +1297,12 @@ void window_setup(void)
void restore_tty(void)
{
ioctl(STDIN_FILENO, KDSETMODE, KD_TEXT);
+ for (int i = 0; i < cur_devices; i++)
+ {
+ if (device_types[i] == DEV_KEYBOARD) {
+ ioctl(device_fds[i], EVIOCGRAB, 0);
+ }
+ }
}
void render_init(int width, int height, char * title, uint8_t fullscreen)
@@ -1380,11 +1386,15 @@ void render_init(int width, int height, char * title, uint8_t fullscreen)
char *names[] = {"Keyboard", "Mouse", "Gamepad"};
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
printf("%s is a %s\n%s\n", filename, names[dtype - 1], name);
- //set FD to non-blocking mode for event polling
- fcntl(fd, F_SETFL, O_NONBLOCK);
+
if (dtype == DEV_GAMEPAD) {
handle_joy_added(joystick_counter++);
+ } else if (dtype == DEV_KEYBOARD && isatty(STDIN_FILENO)) {
+ ioctl(fd, EVIOCGRAB, 1);
}
+
+ //set FD to non-blocking mode for event polling
+ fcntl(fd, F_SETFL, O_NONBLOCK);
cur_devices++;
}
free(filename);