Map buffered inputs to menucmd

This lets buffered tapping not count as one held input.
This commit is contained in:
James R 2022-02-19 16:30:23 -08:00
parent 68ed9982b6
commit 3504f7ebd3
3 changed files with 27 additions and 9 deletions

View file

@ -182,6 +182,7 @@ void D_ProcessEvents(void)
event_t *ev; event_t *ev;
boolean eaten; boolean eaten;
boolean menuresponse = false;
memset(deviceResponding, false, sizeof (deviceResponding)); memset(deviceResponding, false, sizeof (deviceResponding));
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
@ -205,6 +206,7 @@ void D_ProcessEvents(void)
} }
// Menu input // Menu input
menuresponse = true;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_lock_mutex(&k_menu_mutex); I_lock_mutex(&k_menu_mutex);
#endif #endif
@ -244,6 +246,12 @@ void D_ProcessEvents(void)
G_Responder(ev); G_Responder(ev);
} }
// Reset menu controls when no event is processed
if (!menuresponse)
{
M_MapMenuControls(NULL);
}
} }
// //

View file

@ -424,6 +424,7 @@ void Addons_option_Onchange(void);
void M_SortServerList(void); void M_SortServerList(void);
void M_MapMenuControls(event_t *ev);
boolean M_Responder(event_t *ev); boolean M_Responder(event_t *ev);
boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt); boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt);
void M_StartControlPanel(void); void M_StartControlPanel(void);

View file

@ -828,8 +828,7 @@ boolean M_Responder(event_t *ev)
menuKey = ev->data1; menuKey = ev->data1;
} }
// update keys current state M_MapMenuControls(ev);
G_MapEventsToControls(ev);
// Profiles: Control mapping. // Profiles: Control mapping.
// We take the WHOLE EVENT for convenience. // We take the WHOLE EVENT for convenience.
@ -1163,6 +1162,23 @@ static void M_UpdateMenuCMD(UINT8 i)
} }
} }
void M_MapMenuControls(event_t *ev)
{
INT32 i;
if (ev)
{
// update keys current state
G_MapEventsToControls(ev);
}
// Update menu CMD
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
M_UpdateMenuCMD(i);
}
}
boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt) boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt)
{ {
if (menucmd[pid].buttonsHeld & bt) if (menucmd[pid].buttonsHeld & bt)
@ -1326,16 +1342,9 @@ static void M_MenuTypingInput(INT32 key)
static void M_HandleMenuInput(void) static void M_HandleMenuInput(void)
{ {
void (*routine)(INT32 choice); // for some casting problem void (*routine)(INT32 choice); // for some casting problem
INT32 i;
UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu. UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu.
SINT8 lr = 0, ud = 0; SINT8 lr = 0, ud = 0;
// Update menu CMD
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
M_UpdateMenuCMD(i);
}
if (menuactive == false) if (menuactive == false)
{ {
// We're not in the menu. // We're not in the menu.