Touchpads already have their right/left buttons swapped in raw input

Fixes https://github.com/libsdl-org/SDL/issues/8597

(cherry picked from commit cf5e0637b5454b776f749beea856f1f595e03036)
This commit is contained in:
Sam Lantinga 2024-01-15 19:41:46 -08:00
parent f641d91f67
commit eae81ec80e

View file

@ -371,7 +371,7 @@ static void WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL
}
}
static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID)
static void WIN_CheckRawMouseButtons(HANDLE hDevice, ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID)
{
// Add a flag to distinguish raw mouse buttons from wParam above
rawButtons |= 0x8000000;
@ -379,6 +379,10 @@ static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL
if (rawButtons != data->mouse_button_flags) {
Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
if (swapButtons && hDevice == NULL) {
/* Touchpad, already has buttons swapped */
swapButtons = SDL_FALSE;
}
if (rawButtons & RI_MOUSE_BUTTON_1_DOWN) {
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID);
}
@ -937,7 +941,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
data->last_raw_mouse_position.x = x;
data->last_raw_mouse_position.y = y;
}
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID);
WIN_CheckRawMouseButtons(inp.header.hDevice, rawmouse->usButtonFlags, data, mouseID);
}
} break;