Browse Source

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

Fixes https://github.com/libsdl-org/SDL/issues/11131
Sam Lantinga 6 months ago
parent
commit
f946f87f30
1 changed files with 4 additions and 19 deletions
  1. 4 19
      src/video/uikit/SDL_uikitview.m

+ 4 - 19
src/video/uikit/SDL_uikitview.m

@@ -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);
                         }
                     }
                 }