Mercurial > repos > blastem
comparison render_fbdev.c @ 1781:2b4d5cfec6d9
Grab keyboard devices at startup so keyboard input stops going to terminal while running
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 10 Mar 2019 22:22:23 -0700 |
parents | fc9bea5ee079 |
children | b2bffd98063d |
comparison
equal
deleted
inserted
replaced
1780:fc9bea5ee079 | 1781:2b4d5cfec6d9 |
---|---|
1295 } | 1295 } |
1296 | 1296 |
1297 void restore_tty(void) | 1297 void restore_tty(void) |
1298 { | 1298 { |
1299 ioctl(STDIN_FILENO, KDSETMODE, KD_TEXT); | 1299 ioctl(STDIN_FILENO, KDSETMODE, KD_TEXT); |
1300 for (int i = 0; i < cur_devices; i++) | |
1301 { | |
1302 if (device_types[i] == DEV_KEYBOARD) { | |
1303 ioctl(device_fds[i], EVIOCGRAB, 0); | |
1304 } | |
1305 } | |
1300 } | 1306 } |
1301 | 1307 |
1302 void render_init(int width, int height, char * title, uint8_t fullscreen) | 1308 void render_init(int width, int height, char * title, uint8_t fullscreen) |
1303 { | 1309 { |
1304 if (height <= 0) { | 1310 if (height <= 0) { |
1378 device_types[cur_devices] = dtype; | 1384 device_types[cur_devices] = dtype; |
1379 char name[1024]; | 1385 char name[1024]; |
1380 char *names[] = {"Keyboard", "Mouse", "Gamepad"}; | 1386 char *names[] = {"Keyboard", "Mouse", "Gamepad"}; |
1381 ioctl(fd, EVIOCGNAME(sizeof(name)), name); | 1387 ioctl(fd, EVIOCGNAME(sizeof(name)), name); |
1382 printf("%s is a %s\n%s\n", filename, names[dtype - 1], name); | 1388 printf("%s is a %s\n%s\n", filename, names[dtype - 1], name); |
1389 | |
1390 if (dtype == DEV_GAMEPAD) { | |
1391 handle_joy_added(joystick_counter++); | |
1392 } else if (dtype == DEV_KEYBOARD && isatty(STDIN_FILENO)) { | |
1393 ioctl(fd, EVIOCGRAB, 1); | |
1394 } | |
1395 | |
1383 //set FD to non-blocking mode for event polling | 1396 //set FD to non-blocking mode for event polling |
1384 fcntl(fd, F_SETFL, O_NONBLOCK); | 1397 fcntl(fd, F_SETFL, O_NONBLOCK); |
1385 if (dtype == DEV_GAMEPAD) { | |
1386 handle_joy_added(joystick_counter++); | |
1387 } | |
1388 cur_devices++; | 1398 cur_devices++; |
1389 } | 1399 } |
1390 free(filename); | 1400 free(filename); |
1391 } | 1401 } |
1392 } | 1402 } |