Skip to content
Permalink
Browse files

Implemented left/right mouse click detection on iOS

  • Loading branch information
slouken committed Apr 14, 2020
1 parent 171ba00 commit dbf7f84fd917ae8921a7ad5b1e0082fed584ad89
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/video/uikit/SDL_uikitview.m
@@ -221,8 +221,13 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
#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 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
#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 @@ - (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)e
/* 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

0 comments on commit dbf7f84

Please sign in to comment.