Fixed mouse button mapping 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index e003513..7a37cfe 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -34,7 +34,7 @@
#import "SDL_uikitwindow.h"
/* The maximum number of mouse buttons we support */
-#define MAX_MOUSE_BUTTONS 5
+#define MAX_MOUSE_BUTTONS 5
/* This is defined in SDL_sysjoystick.m */
extern int SDL_AppleTVRemoteOpenedAsJoystick;
@@ -228,12 +228,23 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
if (event.buttonMask & SDL_BUTTON(i)) {
- if (i == 2) {
- i = SDL_BUTTON_RIGHT;
- } else if (i == 3) {
- i = SDL_BUTTON_MIDDLE;
+ 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(sdlwindow, 0, SDL_PRESSED, i);
+ SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, button);
}
}
handled = YES;
@@ -270,12 +281,23 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
if (!(event.buttonMask & SDL_BUTTON(i))) {
- if (i == 2) {
- i = SDL_BUTTON_RIGHT;
- } else if (i == 3) {
- i = SDL_BUTTON_MIDDLE;
+ 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(sdlwindow, 0, SDL_RELEASED, i);
+ SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, button);
}
}
handled = YES;