Skip to content

Commit

Permalink
Fix input state combos and empty binds (#16233)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos authored Feb 14, 2024
1 parent 34e28f5 commit e895641
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@
|| ((autoconf_bind)->joyaxis != AXIS_NONE)) \
)

/* Checks if hotkey or RetroPad has any bindings at all. */
#define CHECK_INPUT_DRIVER_EMPTY_BIND(port, i) \
( \
(binds[port][i].key == RETROK_UNKNOWN) \
&& (binds[port][i].mbutton == NO_BTN) \
&& ( ( binds[port][i].joykey == NO_BTN \
&& binds[port][i].joyaxis == AXIS_NONE) \
|| ( joypad_info->auto_binds[i].joykey == NO_BTN \
&& joypad_info->auto_binds[i].joyaxis == AXIS_NONE) \
) \
)

/* Human readable order of input binds */
const unsigned input_config_bind_order[24] = {
RETRO_DEVICE_ID_JOYPAD_UP,
Expand Down Expand Up @@ -782,31 +794,21 @@ static int32_t input_state_wrap(

if (device == RETRO_DEVICE_JOYPAD)
{
/* Drivers can overflow when sending too many keys at once.. */
if (id == RETRO_DEVICE_ID_JOYPAD_MASK && ret)
{
/* Deal with menu toggle combo buttons that won't stay inside +32767. */
if (ret == -0x8000) /* R3 */
ret = 0x8000;
else if (ret == -0x4000) /* LR+R3 */
ret = 0x8000 + 0x4000;
else if (ret < 0)
ret = 0;
return ret;
}

/* No binds, no input. This is for ignoring RETROK_UNKNOWN
* if the driver allows setting the key down somehow.
* Otherwise all hotkeys and inputs with null bind get triggered. */
if ( id != RETRO_DEVICE_ID_JOYPAD_MASK && ret
&& binds[_port][id].key == RETROK_UNKNOWN
&& binds[_port][id].mbutton == NO_BTN
&& ( ( binds[_port][id].joykey == NO_BTN
&& binds[_port][id].joyaxis == AXIS_NONE)
|| ( joypad_info->auto_binds[id].joykey == NO_BTN
&& joypad_info->auto_binds[id].joyaxis == AXIS_NONE)
)
)
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
{
int i;
for (i = 0; i < RARCH_FIRST_META_KEY; i++)
{
if (CHECK_INPUT_DRIVER_EMPTY_BIND(_port, i))
ret &= ~(UINT64_C(1) << i);
}
return ret;
}
else if (id != RETRO_DEVICE_ID_JOYPAD_MASK
&& CHECK_INPUT_DRIVER_EMPTY_BIND(_port, id))
return 0;
}

Expand Down

1 comment on commit e895641

@Langerz82
Copy link

@Langerz82 Langerz82 commented on e895641 Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit has a bug with 2-player emulators such as snes, and megadrive cores. When 2 different evdev files are used for auto joypad, the 2nd joypad does not work. Reverting this commit fixed the issue.

edit:
Please disregard this I see this was fixed in a later version.
6e6a4d8#diff-6a5fc94a55b36039df68403d2ecc5de514cc6cc8f6420917d1e515c0ca625fdbL795

Please sign in to comment.