summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-03-01 00:00:04 -0800
committerMichael Pavone <pavone@retrodev.com>2017-03-01 00:00:04 -0800
commit05e931ae02e3290566dcca0ca639dc019084edd7 (patch)
tree6318d81bf72c60e6144adb74b188984dbe71abff /io.c
parentf4fd7c6b726b1c454209b627d6fc4795ebb22531 (diff)
Only allow keyboard capture if the emulated system has a keyboard attached
Diffstat (limited to 'io.c')
-rw-r--r--io.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/io.c b/io.c
index e7d3f84..9134e85 100644
--- a/io.c
+++ b/io.c
@@ -392,6 +392,16 @@ int current_speed = 0;
int num_speeds = 1;
uint32_t * speeds = NULL;
+uint8_t is_keyboard(io_port *port)
+{
+ return port->device_type == IO_SATURN_KEYBOARD || port->device_type == IO_XBAND_KEYBOARD;
+}
+
+uint8_t keyboard_connected(sega_io *io)
+{
+ return is_keyboard(io->ports) || is_keyboard(io->ports+1) || is_keyboard(io->ports+2);
+}
+
void handle_binding_up(keybinding * binding)
{
switch(binding->bind_type)
@@ -471,7 +481,9 @@ void handle_binding_up(keybinding * binding)
}
break;
case UI_TOGGLE_KEYBOARD_CAPTURE:
- current_io->keyboard_captured = !current_io->keyboard_captured;
+ if (keyboard_connected(current_io)) {
+ current_io->keyboard_captured = !current_io->keyboard_captured;
+ }
break;
case UI_TOGGLE_FULLSCREEN:
render_toggle_fullscreen();