From 32be8190c864e4f3e34c2449e7f615977a6b58f3 Mon Sep 17 00:00:00 2001 From: ceski <56656010+ceski-1@users.noreply.github.com> Date: Fri, 31 May 2024 23:23:29 -0700 Subject: [PATCH] Prevent mouse motion when returning from message prompts (#1722) * Flush mouse motion when clearing relative state * Clear relative mouse state when clearing input variables * Prevent mouse motion when returning from message prompts --- src/g_game.c | 1 + src/i_video.c | 4 ++-- src/mn_menu.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index edc3a7c7..c70e222b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -820,6 +820,7 @@ void G_ClearInput(void) ClearLocalView(); G_ClearCarry(); memset(&basecmd, 0, sizeof(basecmd)); + I_ResetRelativeMouseState(); } // diff --git a/src/i_video.c b/src/i_video.c index 06b3a951..886a10b0 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -220,6 +220,8 @@ void I_ShowMouseCursor(boolean toggle) void I_ResetRelativeMouseState(void) { + SDL_PumpEvents(); + SDL_FlushEvent(SDL_MOUSEMOTION); SDL_GetRelativeMouseState(NULL, NULL); } @@ -1782,8 +1784,6 @@ void I_InitGraphics(void) ResetLogicalSize(); // clear out events waiting at the start and center the mouse - SDL_PumpEvents(); - SDL_FlushEvent(SDL_MOUSEMOTION); I_ResetRelativeMouseState(); } diff --git a/src/mn_menu.c b/src/mn_menu.c index ef24e5c7..83e73997 100644 --- a/src/mn_menu.c +++ b/src/mn_menu.c @@ -1900,7 +1900,6 @@ void MN_ClearMenus(void) // sendpause = true; G_ClearInput(); - I_ResetRelativeMouseState(); } void MN_Back(void) @@ -2727,6 +2726,7 @@ boolean M_Responder(event_t *ev) messageRoutine(ch); } + G_ClearInput(); menuactive = false; M_StartSound(sfx_swtchx); return true;