mirror of https://github.com/encounter/SDL.git
Fixed mouse button mapping on iOS
This commit is contained in:
parent
dbf7f84fd9
commit
e1215e857f
|
@ -33,6 +33,9 @@
|
||||||
#import "SDL_uikitmodes.h"
|
#import "SDL_uikitmodes.h"
|
||||||
#import "SDL_uikitwindow.h"
|
#import "SDL_uikitwindow.h"
|
||||||
|
|
||||||
|
/* The maximum number of mouse buttons we support */
|
||||||
|
#define MAX_MOUSE_BUTTONS 5
|
||||||
|
|
||||||
/* This is defined in SDL_sysjoystick.m */
|
/* This is defined in SDL_sysjoystick.m */
|
||||||
extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
|
|
||||||
|
@ -223,8 +226,13 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
if (touch.type == UITouchTypeIndirectPointer) {
|
if (touch.type == UITouchTypeIndirectPointer) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = SDL_BUTTON_LEFT; i <= SDL_BUTTON_X2; ++i) {
|
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
|
||||||
if (event.buttonMask & SDL_BUTTON(i)) {
|
if (event.buttonMask & SDL_BUTTON(i)) {
|
||||||
|
if (i == 2) {
|
||||||
|
i = SDL_BUTTON_RIGHT;
|
||||||
|
} else if (i == 3) {
|
||||||
|
i = SDL_BUTTON_MIDDLE;
|
||||||
|
}
|
||||||
SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, i);
|
SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,8 +268,13 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
if (touch.type == UITouchTypeIndirectPointer) {
|
if (touch.type == UITouchTypeIndirectPointer) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = SDL_BUTTON_LEFT; i <= SDL_BUTTON_X2; ++i) {
|
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
|
||||||
if (!(event.buttonMask & SDL_BUTTON(i))) {
|
if (!(event.buttonMask & SDL_BUTTON(i))) {
|
||||||
|
if (i == 2) {
|
||||||
|
i = SDL_BUTTON_RIGHT;
|
||||||
|
} else if (i == 3) {
|
||||||
|
i = SDL_BUTTON_MIDDLE;
|
||||||
|
}
|
||||||
SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, i);
|
SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue