From 02e56a304e61a12b71c836a74387ca58197bbacd Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 11 Jan 2024 20:58:21 -0600 Subject: [PATCH] Reset all gamekeydown arrays for all devices --- src/d_main.cpp | 2 +- src/f_wipe.cpp | 4 ++-- src/g_game.c | 2 +- src/g_input.c | 13 +++++++++++++ src/g_input.h | 1 + src/k_menufunc.c | 2 +- src/sdl/i_video.cpp | 2 +- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index c16fa8887..3806109ee 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1082,7 +1082,7 @@ void D_ClearState(void) paused = false; // clear cmd building stuff - memset(gamekeydown, 0, sizeof (gamekeydown)); + G_ResetAllDeviceGameKeyDown(); G_ResetAllDeviceResponding(); // Reset the palette diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 9ecb41c32..664c2d11a 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -497,7 +497,7 @@ void F_RunWipe(UINT8 wipemode, UINT8 wipetype, boolean drawMenu, const char *col // FIXME: Wipes SUCK and drop input events for some reason, causing stuck gamepad inputs. // It's better to ignore an intentional hold than to turn a tap into a phantom hold. // (If you're removing this, remove the one after the inner loop too!) - memset(gamekeydown, 0, sizeof(gamekeydown)); + G_ResetAllDeviceGameKeyDown(); // lastwipetic should either be 0 or the tic we last wiped // on for fade-to-black @@ -589,7 +589,7 @@ void F_RunWipe(UINT8 wipemode, UINT8 wipetype, boolean drawMenu, const char *col // FIXME: Wipes SUCK and drop input events for some reason, causing stuck gamepad inputs. // It's better to ignore an intentional hold than to turn a tap into a phantom hold. // (If you're removing this, remove the one before the inner loop too!) - memset(gamekeydown, 0, sizeof(gamekeydown)); + G_ResetAllDeviceGameKeyDown(); if (fcolor) { diff --git a/src/g_game.c b/src/g_game.c index ef9b54f3c..7782210b6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1181,7 +1181,7 @@ void G_DoLoadLevelEx(boolean resetplayer, gamestate_t newstate) } // clear cmd building stuff - memset(gamekeydown, 0, sizeof (gamekeydown)); + G_ResetAllDeviceGameKeyDown(); G_ResetAllDeviceResponding(); // clear hud messages remains (usually from game startup) diff --git a/src/g_input.c b/src/g_input.c index c19d05f1f..dffc6d550 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -249,6 +249,19 @@ INT32* G_GetDeviceGameKeyDownArray(INT32 device) return NULL; } +void G_ResetAllDeviceGameKeyDown(void) +{ + int i; + + memset(gamekeydown, 0, sizeof(gamekeydown)); + memset(g_gamekeydown_device0, 0, sizeof(g_gamekeydown_device0)); + + for (i = 0; i < g_available_gamepad_devices; i++) + { + memset(g_gamepad_gamekeydown[i], 0, sizeof(INT32) * NUMINPUTS); + } +} + boolean G_IsDeviceResponding(INT32 device) { int i; diff --git a/src/g_input.h b/src/g_input.h index d90092971..f2b8e6ca8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -167,6 +167,7 @@ void G_ResetAllDeviceRumbles(void); /// Get the gamekeydown array (NUMINPUTS values) for the given device, or NULL if the device id is invalid. INT32* G_GetDeviceGameKeyDownArray(INT32 device); +void G_ResetAllDeviceGameKeyDown(void); boolean G_IsDeviceResponding(INT32 device); void G_SetDeviceResponding(INT32 device, boolean responding); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index d4ae87e16..3ba20e388 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -598,7 +598,7 @@ void M_StartControlPanel(void) { INT32 i; - memset(gamekeydown, 0, sizeof (gamekeydown)); + G_ResetAllDeviceGameKeyDown(); memset(menucmd, 0, sizeof (menucmd)); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 2d9d4b2c1..824b17997 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -547,7 +547,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { SDLforceUngrabMouse(); } - memset(gamekeydown, 0, sizeof(gamekeydown)); // TODO this is a scary memset + G_ResetAllDeviceGameKeyDown(); G_ResetAllDeviceResponding(); if (MOUSE_MENU)