Navigation Menu

Skip to content

Commit

Permalink
Implemented left/right mouse click detection on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Apr 14, 2020
1 parent 171ba00 commit dbf7f84
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/video/uikit/SDL_uikitview.m
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dbf7f84

Please sign in to comment.