reverse variable names for clarity, add separate latch for OK button to solve looping of menu ok/cancel swap toggle

This commit is contained in:
Brad Parker 2016-11-27 11:25:29 -05:00
parent 42a3ec2cf7
commit b9c6fa585c

View File

@ -199,11 +199,18 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
size_t new_scroll_accel = 0;
menu_input_t *menu_input = NULL;
settings_t *settings = config_get_ptr();
bool ok_current = false;
static bool ok_old = false;
bool ok_trigger = false;
menu_ok_btn = settings->input.menu_swap_ok_cancel_buttons ?
RETRO_DEVICE_ID_JOYPAD_A: RETRO_DEVICE_ID_JOYPAD_B;
menu_cancel_btn = settings->input.menu_swap_ok_cancel_buttons ?
RETRO_DEVICE_ID_JOYPAD_B: RETRO_DEVICE_ID_JOYPAD_A;
menu_ok_btn = settings->input.menu_swap_ok_cancel_buttons ?
RETRO_DEVICE_ID_JOYPAD_B : RETRO_DEVICE_ID_JOYPAD_A;
menu_cancel_btn = settings->input.menu_swap_ok_cancel_buttons ?
RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B;
ok_current = input & UINT64_C(1) << menu_ok_btn;
ok_trigger = ok_current & ~ok_old;
ok_old = ok_current;
if (input)
{
@ -334,7 +341,7 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
osk_idx = (enum osk_type)(OSK_TYPE_UNKNOWN + 1);
}
if (trigger_input & (UINT64_C(1) << menu_cancel_btn))
if (trigger_input & (UINT64_C(1) << menu_ok_btn))
{
if (osk_ptr >= 0)
{
@ -342,7 +349,7 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
}
}
if (trigger_input & (UINT64_C(1) << menu_ok_btn))
if (trigger_input & (UINT64_C(1) << menu_cancel_btn))
{
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
}
@ -366,10 +373,10 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
ret = MENU_ACTION_SCROLL_UP;
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R))
ret = MENU_ACTION_SCROLL_DOWN;
else if (trigger_input & (UINT64_C(1) << menu_ok_btn))
ret = MENU_ACTION_CANCEL;
else if (trigger_input & (UINT64_C(1) << menu_cancel_btn))
else if (ok_trigger)
ret = MENU_ACTION_OK;
else if (trigger_input & (UINT64_C(1) << menu_cancel_btn))
ret = MENU_ACTION_CANCEL;
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X))
ret = MENU_ACTION_SEARCH;
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y))