Don't rely on event.buttonMask being set in touchesEnded

Fixes https://github.com/libsdl-org/SDL/issues/11131
This commit is contained in:
Sam Lantinga
2024-10-09 11:35:39 -07:00
parent ee9b6204cf
commit f946f87f30

View File

@@ -292,26 +292,11 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
if (touch.type == UITouchTypeIndirectPointer) {
if (!SDL_HasMouse()) {
int i;
SDL_MouseButtonFlags buttons = SDL_GetMouseState(NULL, NULL);
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
if (event.buttonMask & SDL_BUTTON_MASK(i)) {
Uint8 button;
switch (i) {
case 1:
button = SDL_BUTTON_LEFT;
break;
case 2:
button = SDL_BUTTON_RIGHT;
break;
case 3:
button = SDL_BUTTON_MIDDLE;
break;
default:
button = (Uint8)i;
break;
}
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, button, false);
for (i = 0; i < MAX_MOUSE_BUTTONS; ++i) {
if (buttons & SDL_BUTTON_MASK(i)) {
SDL_SendMouseButton(UIKit_GetEventTimestamp([event timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, (Uint8)i, false);
}
}
}