From 5e9e98bf88b6ab2314e492480123f4ada33fa2b9 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sun, 21 Sep 2014 15:01:02 -0700 Subject: [PATCH] Fixes keypad joystick emulation with glvideo * This prevents resetting the joystick to the origin too soon when key is being held down * Verified doesn't affect legacy X11 xvideo input processing --- src/keys.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/keys.c b/src/keys.c index 52b33e28..45ad8bc1 100644 --- a/src/keys.c +++ b/src/keys.c @@ -289,12 +289,26 @@ void c_keys_handle_input(int scancode, int pressed) // and allow regular PC arrow keys to manipulate joystick... key_pressed[SCODE_U] || key_pressed[SCODE_D] || key_pressed[SCODE_L] || key_pressed[SCODE_R]); - if (key_pressed[ SCODE_KPAD_C ] || (auto_recenter && joy_axis_unpressed)) + if (key_pressed[ SCODE_KPAD_C ]) { joy_x = HALF_JOY_RANGE; joy_y = HALF_JOY_RANGE; } + if (auto_recenter) { + static int unpressed_count = 0; + if (joy_axis_unpressed) { + ++unpressed_count; + if (unpressed_count > 2) { + unpressed_count = 0; + joy_x = HALF_JOY_RANGE; + joy_y = HALF_JOY_RANGE; + } + } else { + unpressed_count = 0; + } + } + if (key_pressed[ SCODE_KPAD_UL ] || key_pressed[ SCODE_KPAD_U ] || key_pressed[ SCODE_KPAD_UR ] ||/* regular arrow up */key_pressed[ SCODE_U ]) { if (joy_y > joy_step)