Mercurial > repos > blastem
diff io.c @ 1026:7267bc1ab547
Fix bug in 68K movep.l when the destination is a register mapped to a host register
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 10 May 2016 08:59:17 -0700 |
parents | 580a806aef6a |
children | 56b1748a8473 |
line wrap: on
line diff
--- a/io.c Fri May 06 19:19:42 2016 -0700 +++ b/io.c Tue May 10 08:59:17 2016 -0700 @@ -26,6 +26,7 @@ "3-button gamepad", "6-button gamepad", "Mega Mouse", + "Saturn Keyboard", "Menacer", "Justifier", "Sega multi-tap", @@ -107,6 +108,7 @@ static keybinding * bindings[0x10000]; static joystick joysticks[MAX_JOYSTICKS]; static mousebinding mice[MAX_MICE]; +static io_port *keyboard_port; const uint8_t dpadbits[] = {RENDER_DPAD_UP, RENDER_DPAD_DOWN, RENDER_DPAD_LEFT, RENDER_DPAD_RIGHT}; void bind_key(int keycode, uint8_t bind_type, uint8_t subtype_a, uint8_t subtype_b, uint8_t value) @@ -254,7 +256,20 @@ } } -void handle_keydown(int keycode) +void store_key_event(uint16_t code) +{ + if (keyboard_port) { + keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos + 1) & 7; + if (keyboard_port->device.keyboard.write_pos == keyboard_port->device.keyboard.read_pos) { + //we've wrapped around to the read position, drop this event + keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos - 1) & 7; + return; + } + keyboard_port->device.keyboard.events[keyboard_port->device.keyboard.write_pos] = code; + } +} + +void handle_keydown(int keycode, char scancode) { int bucket = keycode >> 15 & 0xFFFF; if (!bindings[bucket]) { @@ -263,6 +278,7 @@ int idx = keycode & 0x7FFF; keybinding * binding = bindings[bucket] + idx; handle_binding_down(binding); + store_key_event(scancode); } void handle_joydown(int joystick, int button) @@ -388,7 +404,7 @@ } } -void handle_keyup(int keycode) +void handle_keyup(int keycode, char scancode) { int bucket = keycode >> 15 & 0xFFFF; if (!bindings[bucket]) { @@ -397,6 +413,7 @@ int idx = keycode & 0x7FFF; keybinding * binding = bindings[bucket] + idx; handle_binding_up(binding); + store_key_event(0x100 | scancode); } void handle_joyup(int joystick, int button) @@ -1060,6 +1077,14 @@ } map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS); } + keyboard_port = NULL; + for (int i = 0; i < 3; i++) + { + if (ports[i].device_type == IO_SATURN_KEYBOARD) { + keyboard_port = ports + i; + break; + } + } //not really related to the intention of this function, but the best place to do this currently if (speeds[0] != 100) { set_speed_percent(genesis, speeds[0]);