mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-09 03:29:43 -10:00
(menu) Fix stray pointer input when overlays are toggled
Fourth and fifth instances of the class fixed byc09a057,8ab71e9and46288b2. menu_input_get_mouse_hw_state() and menu_input_get_touchscreen_hw_state() each keep 'last_select_pressed'/'last_cancel_pressed' statics, written only near the end of the function, and each returns early when its respective device is disabled: if (!menu_mouse_enable) return; if (!pointer_enabled) { ... return; } Both conditions are forced false whenever an overlay is active: /* Menu pointer controls are ignored when overlays are enabled. */ if (overlay_active) menu_mouse_enable = false; /* resp. pointer_enabled = false */ so these paths are taken on every overlay show/hide, not only when the corresponding setting is changed. The detectors are consumed as change detectors rather than rising edges: if (is_select_pressed || (is_select_pressed != last_select_pressed)) hw_state->flags |= MENU_INP_PTR_FLG_ACTIVE; A press held across the transition therefore leaves the static asserted while the flags it shadows are cleared, and the inequality reports a change with no input behind it once the device is re-enabled, raising a spurious MENU_INP_PTR_FLG_ACTIVE. Reset both statics on the disabled paths so they stay in step with the cleared flags. Note the mouse variant already guards its position statics against the same hazard via MENU_INP_PTR_FLG_RESET; only the button state was missing equivalent handling.
This commit is contained in:
1 parent
46288b2a65
commit
9240338c10
1 file changed
+16
@@ -1925,7 +1925,17 @@ static void menu_input_get_mouse_hw_state(
|
||||
hw_state->flags = 0;
|
||||
|
||||
if (!menu_mouse_enable)
|
||||
{
|
||||
/* 'hw_state->flags' has just been zeroed, but the button
|
||||
* edge detectors below are not reached on this path. Reset
|
||||
* them to match, otherwise they retain the state from the
|
||||
* last enabled frame and report a spurious change - and so
|
||||
* a spurious MENU_INP_PTR_FLG_ACTIVE - once mouse input is
|
||||
* re-enabled (e.g. when an overlay is dismissed) */
|
||||
last_select_pressed = false;
|
||||
last_cancel_pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
joypad_info.joy_idx = 0;
|
||||
joypad_info.auto_binds = NULL;
|
||||
@@ -2159,6 +2169,12 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
hw_state->y = 0;
|
||||
hw_state->flags &= ~(MENU_INP_PTR_FLG_PRESS_SELECT
|
||||
| MENU_INP_PTR_FLG_PRESS_CANCEL);
|
||||
/* Keep the edge detectors in step with the cleared flags,
|
||||
* otherwise they retain the state from the last enabled
|
||||
* frame and report a spurious change once touch input is
|
||||
* re-enabled (e.g. when an overlay is dismissed) */
|
||||
last_select_pressed = false;
|
||||
last_cancel_pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user