From 3be8a7215594eed3ea0291d8c04bbdc68239696a Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 3 Mar 2024 17:42:20 -0800 Subject: [PATCH] Update button states during wipes - All inputs create input events that get stored in a very small buffer - Normally, the game listens for some inputs and then immediately processes them and updates the button state in-game - However, during wipes the processing step would not happen and it would just let the events pile up - Because the buffer is small though, it would quickly fill up and lose some events - This would lead to button states getting stuck on some controllers if you released a button during a wipe - If you spun an analog stick around, this would cause it to happen more frequently, because there is a new event for every slight change of an analog stick's position --- src/d_clisrv.c | 6 +++--- src/d_main.cpp | 5 ++++- src/d_main.h | 2 +- src/f_wipe.cpp | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9b0c1ff52..dbc95e065 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5920,9 +5920,9 @@ static void Local_Maketic(INT32 realtics) INT32 i; I_OsPolling(); // I_Getevent - D_ProcessEvents(); // menu responder, cons responder, - // game responder calls HU_Responder, AM_Responder, - // and G_MapEventsToControls + D_ProcessEvents(true); // menu responder, cons responder, + // game responder calls HU_Responder, AM_Responder, + // and G_MapEventsToControls if (!dedicated) rendergametic = gametic; diff --git a/src/d_main.cpp b/src/d_main.cpp index 19fd9c1db..1ece00a2b 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -264,7 +264,7 @@ void HandleGamepadDeviceEvents(event_t *ev) // D_ProcessEvents // Send all the events of the given timestamp down the responder chain // -void D_ProcessEvents(void) +void D_ProcessEvents(boolean callresponders) { event_t *ev; int i; @@ -298,6 +298,9 @@ void D_ProcessEvents(void) // update keys current state G_MapEventsToControls(ev); + if (!callresponders) + continue; // eat + // Menu input #ifdef HAVE_THREADS I_lock_mutex(&k_menu_mutex); diff --git a/src/d_main.h b/src/d_main.h index fdaa1bc1c..a47eec7a3 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -50,7 +50,7 @@ void D_PostEvent(const event_t *ev); void D_PostEvent_end(void); // delimiter for locking memory #endif -void D_ProcessEvents(void); +void D_ProcessEvents(boolean callresponders); const char *D_Home(void); diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 6a8587586..6c848cda1 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -553,6 +553,12 @@ void F_RunWipe(UINT8 wipemode, UINT8 wipetype, boolean drawMenu, const char *col } I_OsPolling(); + // The event buffer is rather small so we need to + // process these events immediately, to make sure + // inputs don't get stuck (would happen a lot with + // some controllers that send a lot of analog + // events). + D_ProcessEvents(false); I_UpdateNoBlit(); if (drawMenu && rendermode != render_none)