mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-04-11 20:51:37 +00:00
Refactor for joy_confirm operation
Removed consecutive comparisons in Key_GetMenuKey()
This commit is contained in:
parent
29d95e3388
commit
a7551dae26
3 changed files with 32 additions and 43 deletions
|
@ -94,8 +94,8 @@ qboolean joy_altselector_pressed = false;
|
|||
// Gamepad labels' style (Xbox, Playstation, etc.) in use, normally set after detection
|
||||
gamepad_labels_t joy_current_lbls = LBL_SDL;
|
||||
|
||||
// Confirm & cancel buttons' keynums
|
||||
int btn_confirm = K_BTN_SOUTH, btn_cancel = K_BTN_EAST;
|
||||
// Using japanese style for confirm & cancel buttons on gamepad
|
||||
qboolean japanese_confirm = false;
|
||||
|
||||
// Console Variables
|
||||
cvar_t *freelook;
|
||||
|
@ -573,7 +573,7 @@ static void
|
|||
IN_GamepadConfirm_Changed(void)
|
||||
{
|
||||
const int requested = (int)joy_confirm->value;
|
||||
qboolean japanese_style = false;
|
||||
japanese_confirm = false;
|
||||
joy_confirm->modified = false;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 12)
|
||||
|
@ -585,27 +585,16 @@ IN_GamepadConfirm_Changed(void)
|
|||
#if SDL_VERSION_ATLEAST(2, 24, 0)
|
||||
case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR:
|
||||
#endif // SDL_VERSION_ATLEAST(2, 24, 0)
|
||||
japanese_style = true;
|
||||
japanese_confirm = true;
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif // SDL_VERSION_ATLEAST(2, 0, 12)
|
||||
if (requested == 1)
|
||||
{
|
||||
japanese_style = true;
|
||||
}
|
||||
|
||||
if (japanese_style)
|
||||
{
|
||||
btn_confirm = K_BTN_EAST;
|
||||
btn_cancel = K_BTN_SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_confirm = K_BTN_SOUTH;
|
||||
btn_cancel = K_BTN_EAST;
|
||||
japanese_confirm = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ qboolean joy_altselector_pressed = false;
|
|||
// Gamepad labels' style (Xbox, Playstation, etc.) in use, normally set after detection
|
||||
gamepad_labels_t joy_current_lbls = LBL_SDL;
|
||||
|
||||
// Confirm & cancel buttons' keynums
|
||||
int btn_confirm = K_BTN_SOUTH, btn_cancel = K_BTN_EAST;
|
||||
// Using japanese style for confirm & cancel buttons on gamepad
|
||||
qboolean japanese_confirm = false;
|
||||
|
||||
// Console Variables
|
||||
cvar_t *freelook;
|
||||
|
@ -564,7 +564,7 @@ static void
|
|||
IN_GamepadConfirm_Changed(void)
|
||||
{
|
||||
const int requested = (int)joy_confirm->value;
|
||||
qboolean japanese_style = false;
|
||||
japanese_confirm = false;
|
||||
joy_confirm->modified = false;
|
||||
|
||||
if (requested < 0 && controller) // try to autodetect...
|
||||
|
@ -573,25 +573,14 @@ IN_GamepadConfirm_Changed(void)
|
|||
{
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO:
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR:
|
||||
japanese_style = true;
|
||||
japanese_confirm = true;
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (requested == 1)
|
||||
{
|
||||
japanese_style = true;
|
||||
}
|
||||
|
||||
if (japanese_style)
|
||||
{
|
||||
btn_confirm = K_BTN_EAST;
|
||||
btn_cancel = K_BTN_SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_confirm = K_BTN_SOUTH;
|
||||
btn_cancel = K_BTN_EAST;
|
||||
japanese_confirm = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ M_PushMenu(menuframework_s* menu)
|
|||
cls.key_dest = key_menu;
|
||||
}
|
||||
|
||||
extern int btn_confirm, btn_cancel;
|
||||
extern qboolean japanese_confirm;
|
||||
|
||||
int
|
||||
Key_GetMenuKey(int key)
|
||||
|
@ -295,15 +295,14 @@ Key_GetMenuKey(int key)
|
|||
if (IN_NumpadIsOn() == true) { break; }
|
||||
case K_INS:
|
||||
return K_INS;
|
||||
}
|
||||
|
||||
if (key == btn_confirm)
|
||||
{
|
||||
return K_ENTER;
|
||||
}
|
||||
if (key == btn_cancel)
|
||||
{
|
||||
return K_ESCAPE;
|
||||
case K_BTN_SOUTH:
|
||||
if (japanese_confirm) return K_ESCAPE;
|
||||
else return K_ENTER;
|
||||
|
||||
case K_BTN_EAST:
|
||||
if (japanese_confirm) return K_ENTER;
|
||||
else return K_ESCAPE;
|
||||
}
|
||||
|
||||
return key;
|
||||
|
@ -1329,6 +1328,18 @@ static void
|
|||
GamepadMenu_StatusPrompt(menuframework_s *m)
|
||||
{
|
||||
static char m_gamepadbind_statusbar[64];
|
||||
int btn_confirm, btn_cancel;
|
||||
|
||||
if (japanese_confirm)
|
||||
{
|
||||
btn_confirm = K_BTN_EAST;
|
||||
btn_cancel = K_BTN_SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_confirm = K_BTN_SOUTH;
|
||||
btn_cancel = K_BTN_EAST;
|
||||
}
|
||||
|
||||
snprintf(m_gamepadbind_statusbar, 64, "%s assigns, %s clears, %s exits",
|
||||
Key_KeynumToString_Joy(btn_confirm), Key_KeynumToString_Joy(K_BTN_NORTH),
|
||||
|
|
Loading…
Reference in a new issue