From 05e931ae02e3290566dcca0ca639dc019084edd7 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 1 Mar 2017 00:00:04 -0800 Subject: Only allow keyboard capture if the emulated system has a keyboard attached --- io.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'io.c') 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(); -- cgit v1.2.3