Prevent duplicate inputs when using remaps with input overlays

This commit is contained in:
jdgleaver 2021-05-21 16:29:29 +01:00
parent f66d4ea33c
commit d5f862ee07

View File

@ -22769,10 +22769,12 @@ static int16_t input_state_device(
{ {
bool bind_valid = p_rarch->libretro_input_binds[port] bool bind_valid = p_rarch->libretro_input_binds[port]
&& p_rarch->libretro_input_binds[port][id].valid; && p_rarch->libretro_input_binds[port][id].valid;
unsigned remap_button = settings->uints.input_remap_ids[port][id];
/* TODO/FIXME: What on earth is this code doing...? */
if (! if (!
( bind_valid ( bind_valid
&& id != settings->uints.input_remap_ids[port][id] && id != remap_button
) )
) )
{ {
@ -22790,10 +22792,30 @@ static int16_t input_state_device(
res = 1; res = 1;
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
if (port == 0) /* Check if overlay is active and button
* corresponding to 'id' has been pressed */
if ((port == 0) &&
p_rarch->overlay_ptr &&
p_rarch->overlay_ptr->alive &&
BIT256_GET(p_rarch->overlay_ptr->overlay_state.buttons, id))
{ {
if (p_rarch->overlay_ptr && p_rarch->overlay_ptr->alive) #ifdef HAVE_MENU
if ((BIT256_GET(p_rarch->overlay_ptr->overlay_state.buttons, id))) bool menu_driver_alive = p_rarch->menu_driver_alive;
#else
bool menu_driver_alive = false;
#endif
bool input_remap_binds_enable = settings->bools.input_remap_binds_enable;
/* This button has already been processed
* inside input_driver_poll() if all the
* following are true:
* > Menu driver is not running
* > Input remaps are enabled
* > 'id' is not equal to remapped button index
* If these conditions are met, input here
* is ignored */
if ((menu_driver_alive || !input_remap_binds_enable) ||
(id == remap_button))
res |= 1; res |= 1;
} }
#endif #endif