aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorThierry Crozat2019-06-23 22:50:36 +0100
committerThierry Crozat2019-06-30 12:36:43 +0100
commitce9e77662988f0bdaeb7f02f9b6d9ce9981fee48 (patch)
tree34d9ef5ba64174975f7b07bc3b611ac6e0aa466c /backends
parent5232cf376bdd1fa5381b9a07e024d075124d1966 (diff)
downloadscummvm-rg350-ce9e77662988f0bdaeb7f02f9b6d9ce9981fee48.tar.gz
scummvm-rg350-ce9e77662988f0bdaeb7f02f9b6d9ce9981fee48.tar.bz2
scummvm-rg350-ce9e77662988f0bdaeb7f02f9b6d9ce9981fee48.zip
IOS7: Map three finger swipes to arrow keys
Also use the pinch gesture to show/hide the keyboard. Previously it was using the three fingers swipe up and dowm, which is now mapped to arrow keys.
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/ios7/ios7_osys_events.cpp72
-rw-r--r--backends/platform/ios7/ios7_video.mm78
2 files changed, 72 insertions, 78 deletions
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index 69a350327f..a7e007ea42 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -399,63 +399,23 @@ void OSystem_iOS7::handleEvent_keyPressed(Common::Event &event, int keyPressed)
}
bool OSystem_iOS7::handleEvent_swipe(Common::Event &event, int direction, int touches) {
- if (touches == 1) {
+ if (touches == 3) {
Common::KeyCode keycode = Common::KEYCODE_INVALID;
- switch (_screenOrientation) {
- case kScreenOrientationPortrait:
- switch ((UIViewSwipeDirection)direction) {
- case kUIViewSwipeUp:
- keycode = Common::KEYCODE_UP;
- break;
- case kUIViewSwipeDown:
- keycode = Common::KEYCODE_DOWN;
- break;
- case kUIViewSwipeLeft:
- keycode = Common::KEYCODE_LEFT;
- break;
- case kUIViewSwipeRight:
- keycode = Common::KEYCODE_RIGHT;
- break;
- default:
- return false;
- }
- break;
- case kScreenOrientationLandscape:
- switch ((UIViewSwipeDirection)direction) {
- case kUIViewSwipeUp:
- keycode = Common::KEYCODE_LEFT;
- break;
- case kUIViewSwipeDown:
- keycode = Common::KEYCODE_RIGHT;
- break;
- case kUIViewSwipeLeft:
- keycode = Common::KEYCODE_DOWN;
- break;
- case kUIViewSwipeRight:
- keycode = Common::KEYCODE_UP;
- break;
- default:
- return false;
- }
- break;
- case kScreenOrientationFlippedLandscape:
- switch ((UIViewSwipeDirection)direction) {
- case kUIViewSwipeUp:
- keycode = Common::KEYCODE_RIGHT;
- break;
- case kUIViewSwipeDown:
- keycode = Common::KEYCODE_LEFT;
- break;
- case kUIViewSwipeLeft:
- keycode = Common::KEYCODE_UP;
- break;
- case kUIViewSwipeRight:
- keycode = Common::KEYCODE_DOWN;
- break;
- default:
- return false;
- }
- break;
+ switch ((UIViewSwipeDirection)direction) {
+ case kUIViewSwipeUp:
+ keycode = Common::KEYCODE_UP;
+ break;
+ case kUIViewSwipeDown:
+ keycode = Common::KEYCODE_DOWN;
+ break;
+ case kUIViewSwipeLeft:
+ keycode = Common::KEYCODE_LEFT;
+ break;
+ case kUIViewSwipeRight:
+ keycode = Common::KEYCODE_RIGHT;
+ break;
+ default:
+ return false;
}
event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode;
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 17d0e1aaaa..321ccdb63d 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -349,18 +349,7 @@ uint getSizeNextPOT(uint size) {
}
- (void)setupGestureRecognizers {
- const NSUInteger KEYBOARDSWIPETOUCHCOUNT = 3;
- UISwipeGestureRecognizer *swipeUpKeyboard = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardSwipeUp:)];
- swipeUpKeyboard.direction = UISwipeGestureRecognizerDirectionUp;
- swipeUpKeyboard.numberOfTouchesRequired = KEYBOARDSWIPETOUCHCOUNT;
- swipeUpKeyboard.delaysTouchesBegan = NO;
- swipeUpKeyboard.delaysTouchesEnded = NO;
-
- UISwipeGestureRecognizer *swipeDownKeyboard = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardSwipeDown:)];
- swipeDownKeyboard.direction = UISwipeGestureRecognizerDirectionDown;
- swipeDownKeyboard.numberOfTouchesRequired = KEYBOARDSWIPETOUCHCOUNT;
- swipeDownKeyboard.delaysTouchesBegan = NO;
- swipeDownKeyboard.delaysTouchesEnded = NO;
+ UIPinchGestureRecognizer *pinchKeyboard = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardPinch:)];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersSwipeRight:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
@@ -386,26 +375,56 @@ uint getSizeNextPOT(uint size) {
swipeDown.delaysTouchesBegan = NO;
swipeDown.delaysTouchesEnded = NO;
+ UISwipeGestureRecognizer *swipeRight3 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(threeFingersSwipeRight:)];
+ swipeRight3.direction = UISwipeGestureRecognizerDirectionRight;
+ swipeRight3.numberOfTouchesRequired = 3;
+ swipeRight3.delaysTouchesBegan = NO;
+ swipeRight3.delaysTouchesEnded = NO;
+
+ UISwipeGestureRecognizer *swipeLeft3 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(threeFingersSwipeLeft:)];
+ swipeLeft3.direction = UISwipeGestureRecognizerDirectionLeft;
+ swipeLeft3.numberOfTouchesRequired = 3;
+ swipeLeft3.delaysTouchesBegan = NO;
+ swipeLeft3.delaysTouchesEnded = NO;
+
+ UISwipeGestureRecognizer *swipeUp3 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(threeFingersSwipeUp:)];
+ swipeUp3.direction = UISwipeGestureRecognizerDirectionUp;
+ swipeUp3.numberOfTouchesRequired = 3;
+ swipeUp3.delaysTouchesBegan = NO;
+ swipeUp3.delaysTouchesEnded = NO;
+
+ UISwipeGestureRecognizer *swipeDown3 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(threeFingersSwipeDown:)];
+ swipeDown3.direction = UISwipeGestureRecognizerDirectionDown;
+ swipeDown3.numberOfTouchesRequired = 3;
+ swipeDown3.delaysTouchesBegan = NO;
+ swipeDown3.delaysTouchesEnded = NO;
+
UITapGestureRecognizer *doubleTapTwoFingers = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersDoubleTap:)];
doubleTapTwoFingers.numberOfTapsRequired = 2;
doubleTapTwoFingers.numberOfTouchesRequired = 2;
doubleTapTwoFingers.delaysTouchesBegan = NO;
doubleTapTwoFingers.delaysTouchesEnded = NO;
- [self addGestureRecognizer:swipeUpKeyboard];
- [self addGestureRecognizer:swipeDownKeyboard];
+ [self addGestureRecognizer:pinchKeyboard];
[self addGestureRecognizer:swipeRight];
[self addGestureRecognizer:swipeLeft];
[self addGestureRecognizer:swipeUp];
[self addGestureRecognizer:swipeDown];
+ [self addGestureRecognizer:swipeRight3];
+ [self addGestureRecognizer:swipeLeft3];
+ [self addGestureRecognizer:swipeUp3];
+ [self addGestureRecognizer:swipeDown3];
[self addGestureRecognizer:doubleTapTwoFingers];
- [swipeUpKeyboard release];
- [swipeDownKeyboard release];
+ [pinchKeyboard release];
[swipeRight release];
[swipeLeft release];
[swipeUp release];
[swipeDown release];
+ [swipeRight3 release];
+ [swipeLeft3 release];
+ [swipeUp3 release];
+ [swipeDown3 release];
[doubleTapTwoFingers release];
}
@@ -1030,12 +1049,11 @@ uint getSizeNextPOT(uint size) {
_secondTouch = nil;
}
-- (void)keyboardSwipeUp:(UISwipeGestureRecognizer *)recognizer {
- [self showKeyboard];
-}
-
-- (void)keyboardSwipeDown:(UISwipeGestureRecognizer *)recognizer {
- [self hideKeyboard];
+- (void)keyboardPinch:(UIPinchGestureRecognizer *)recognizer {
+ if ([recognizer scale] < 0.8)
+ [self showKeyboard];
+ else if ([recognizer scale] > 1.25)
+ [self hideKeyboard];
}
- (void)twoFingersSwipeRight:(UISwipeGestureRecognizer *)recognizer {
@@ -1054,6 +1072,22 @@ uint getSizeNextPOT(uint size) {
[self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeDown, 2)];
}
+- (void)threeFingersSwipeRight:(UISwipeGestureRecognizer *)recognizer {
+ [self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeRight, 3)];
+}
+
+- (void)threeFingersSwipeLeft:(UISwipeGestureRecognizer *)recognizer {
+ [self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeLeft, 3)];
+}
+
+- (void)threeFingersSwipeUp:(UISwipeGestureRecognizer *)recognizer {
+ [self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeUp, 3)];
+}
+
+- (void)threeFingersSwipeDown:(UISwipeGestureRecognizer *)recognizer {
+ [self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeDown, 3)];
+}
+
- (void)twoFingersDoubleTap:(UITapGestureRecognizer *)recognizer {
[self addEvent:InternalEvent(kInputTap, kUIViewTapDouble, 2)];
}