mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Increase reliability of menuKey system
The intersection between processed buttons and raw keyboard data is a messy one and will probably never be perfect, but it is now consistent.
- Never overwrite a valid keyboard menuKey recieved this frame with a -1 if a different type of event is recieved as well.
- Store previous state of dpad_lr and dpad_ud on menucmd struct.
- Previously, if `a` was bound to Turn Left, it could produce a valid menuKey for one frame, then be considered a leftward input - switching from manual keyboard to Virtual Keyboard.
- It still only produces a valid menuKey for one frame... but we simply filter out leftward inputs that are older than this frame to keep things (relatively) clean.
This commit is contained in:
parent
df31f7cf3a
commit
f24a640e04
3 changed files with 37 additions and 9 deletions
|
|
@ -552,10 +552,16 @@ typedef enum
|
|||
|
||||
struct menucmd_t
|
||||
{
|
||||
// Current frame's data
|
||||
SINT8 dpad_ud; // up / down dpad
|
||||
SINT8 dpad_lr; // left / right
|
||||
UINT32 buttons; // buttons
|
||||
UINT32 buttonsHeld; // prev frame's buttons
|
||||
|
||||
// Previous frame's data
|
||||
SINT8 prev_dpad_ud;
|
||||
SINT8 prev_dpad_lr;
|
||||
UINT32 buttonsHeld;
|
||||
|
||||
UINT16 delay; // menu wait
|
||||
UINT32 delayCount; // num times ya did menu wait (to make the wait shorter each time)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ static boolean M_GamestateCanOpenMenu(void)
|
|||
//
|
||||
boolean M_Responder(event_t *ev)
|
||||
{
|
||||
menuKey = -1;
|
||||
boolean menuKeyJustChanged = false;
|
||||
|
||||
if (dedicated
|
||||
|| (demo.playback && demo.title)
|
||||
|
|
@ -255,10 +255,11 @@ boolean M_Responder(event_t *ev)
|
|||
D_StartTitle();
|
||||
}
|
||||
|
||||
if (ev->type == ev_keydown && ev->data1 < NUMKEYS)
|
||||
if (ev->type == ev_keydown && ev->data1 > 0 && ev->data1 < NUMKEYS)
|
||||
{
|
||||
// Record keyboard presses
|
||||
menuKey = ev->data1;
|
||||
menuKeyJustChanged = true;
|
||||
}
|
||||
|
||||
// Profiles: Control mapping.
|
||||
|
|
@ -354,7 +355,7 @@ boolean M_Responder(event_t *ev)
|
|||
}
|
||||
|
||||
// Typing for CV_IT_STRING
|
||||
if (menutyping.active && !menutyping.menutypingclose && menutyping.keyboardtyping)
|
||||
if (menuKeyJustChanged && menutyping.active && !menutyping.menutypingclose && menutyping.keyboardtyping)
|
||||
{
|
||||
M_ChangeStringCvar(menuKey);
|
||||
}
|
||||
|
|
@ -740,6 +741,9 @@ void M_UpdateMenuCMD(UINT8 i)
|
|||
{
|
||||
UINT8 mp = max(1, setup_numplayers);
|
||||
|
||||
menucmd[i].prev_dpad_ud = menucmd[i].dpad_ud;
|
||||
menucmd[i].prev_dpad_lr = menucmd[i].dpad_lr;
|
||||
|
||||
menucmd[i].dpad_ud = 0;
|
||||
menucmd[i].dpad_lr = 0;
|
||||
|
||||
|
|
@ -833,6 +837,9 @@ static void M_HandleMenuInput(void)
|
|||
void (*routine)(INT32 choice); // for some casting problem
|
||||
UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu.
|
||||
SINT8 lr = 0, ud = 0;
|
||||
INT32 thisMenuKey = menuKey;
|
||||
|
||||
menuKey = -1;
|
||||
|
||||
if (menuactive == false)
|
||||
{
|
||||
|
|
@ -849,7 +856,7 @@ static void M_HandleMenuInput(void)
|
|||
// Typing for CV_IT_STRING
|
||||
if (menutyping.active)
|
||||
{
|
||||
M_MenuTypingInput(menuKey);
|
||||
M_MenuTypingInput(thisMenuKey);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -861,7 +868,7 @@ static void M_HandleMenuInput(void)
|
|||
// Handle menu-specific input handling. If this returns true, we skip regular input handling.
|
||||
if (currentMenu->inputroutine)
|
||||
{
|
||||
if (currentMenu->inputroutine(menuKey))
|
||||
if (currentMenu->inputroutine(thisMenuKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -887,7 +894,7 @@ static void M_HandleMenuInput(void)
|
|||
// If we're hovering over a IT_CV_STRING option, pressing A/X opens the typing submenu
|
||||
if (M_MenuConfirmPressed(pid))
|
||||
{
|
||||
menutyping.keyboardtyping = menuKey != -1 ? true : false; // If we entered this menu by pressing a menu Key, default to keyboard typing, otherwise use controller.
|
||||
menutyping.keyboardtyping = thisMenuKey != -1 ? true : false; // If we entered this menu by pressing a menu Key, default to keyboard typing, otherwise use controller.
|
||||
menutyping.active = true;
|
||||
menutyping.menutypingclose = false;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -243,10 +243,25 @@ void M_MenuTypingInput(INT32 key)
|
|||
|| M_MenuButtonPressed(pid, MBT_X)
|
||||
|| M_MenuButtonPressed(pid, MBT_Y)
|
||||
|| M_MenuButtonPressed(pid, MBT_Z)
|
||||
|| menucmd[pid].dpad_lr != 0
|
||||
|| menucmd[pid].dpad_ud != 0
|
||||
|| (menucmd[pid].dpad_lr != 0 && menucmd[pid].prev_dpad_lr == 0)
|
||||
|| (menucmd[pid].dpad_ud != 0 && menucmd[pid].prev_dpad_ud != 0)
|
||||
))
|
||||
{
|
||||
/*CONS_Printf("key is %d, \
|
||||
%c%c%c-%c%c%c-%c-%c%c%c%c\n",
|
||||
key,
|
||||
M_MenuButtonPressed(pid, MBT_A) ? 'A' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_B) ? 'B' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_C) ? 'C' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_X) ? 'X' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_Y) ? 'Y' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_Z) ? 'Z' : ' ',
|
||||
M_MenuButtonPressed(pid, MBT_START) ? '+' : ' ',
|
||||
menucmd[pid].dpad_lr < 0 ? '<' : ' ',
|
||||
menucmd[pid].dpad_ud > 0 ? '^' : ' ',
|
||||
menucmd[pid].dpad_ud < 0 ? 'v' : ' ',
|
||||
menucmd[pid].dpad_lr > 0 ? '>' : ' '
|
||||
);*/
|
||||
menutyping.keyboardtyping = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue