Implemented left/right mouse click detection on iOS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index 5b42f63..538955c 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -221,8 +221,13 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
- /* FIXME: How can we tell the difference between left and right button clicks? */
- SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
+ int i;
+
+ for (i = SDL_BUTTON_LEFT; i <= SDL_BUTTON_X2; ++i) {
+ if (event.buttonMask & SDL_BUTTON(i)) {
+ SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, i);
+ }
+ }
handled = YES;
}
}
@@ -253,8 +258,13 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
- /* FIXME: How can we tell the difference between left and right button clicks? */
- SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
+ int i;
+
+ for (i = SDL_BUTTON_LEFT; i <= SDL_BUTTON_X2; ++i) {
+ if (!(event.buttonMask & SDL_BUTTON(i))) {
+ SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, i);
+ }
+ }
handled = YES;
}
}
@@ -380,6 +390,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
/* This is only called when the force of a press changes. */
[super pressesChanged:presses withEvent:event];
}
+
#endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */
#if TARGET_OS_TV