From ca18bf11eead1ecd58e919bc3dd63abea3b409e6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 16 Dec 2021 12:01:18 -0800 Subject: [PATCH] Don't compare raw mouse button state with windows message button state When mouse buttons are swapped, right mouse button down is the same value as raw mouse button up, and conceptually the two systems use different button masks, so never cache state between the two. Fixes https://github.com/libsdl-org/SDL/issues/5108 --- src/video/windows/SDL_windowsevents.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 880653535..eb9825f8b 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -306,6 +306,9 @@ WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mou static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID) { + // Add a flag to distinguish raw mouse buttons from wParam above + rawButtons |= 0x8000000; + if (rawButtons != data->mouse_button_flags) { Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL); SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;