[Scummvm-git-logs] scummvm master -> 8f407b7a06f183a297b8a85de1f1b9a3e270c3ec

larsamannen noreply at scummvm.org
Wed Oct 11 04:28:09 UTC 2023


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4dae507f14 IOS7: Add UIGestures for left and right mouse clicks
b2ba581917 IOS7: Remove old touch to mouse button translations
cc499d560e IOS7: Only handle one touch for mouse movements
a490768622 IOS7: Refactor touch event functions
8466e036b5 IOS7: Update touch mode when swiping two fingers right
8f407b7a06 IOS7: Fix long press on touch mode button to show keyboard


Commit: 4dae507f14a47ae31c846e75522966881da25e01
    https://github.com/scummvm/scummvm/commit/4dae507f14a47ae31c846e75522966881da25e01
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Add UIGestures for left and right mouse clicks

On a touch based device the touches made must be translated to
different mouse events. For example when a touch starts and is
moved that should translate to a mouse pointer movement. A quick
tap should be translated to a mouse button click while holding a
touch for a longer time without movement should be translated to
that the mouse button is kept pressed.

Add UIGestures to replace the current mouse button handling, all
done using the callback functions touchesBegan, touchesMoved and
touchesEnded.

A tap gesture with one finger is a left mouse click

A tap gesture with two fingers is a right mouse click

A long press gesture with one finger is holding the left mouse
button down until the press is released. This is accomplished by
sending an button down event when the gesture is recognized and
changes state to UIGestureRecognizerStateBegan.
A button up event is sent when the same gesture changes state to
UIGestureRecognizerStateEnded.

A long press with two fingers is as above but for the right mouse
button.

This commit adds the gestures and their actions. The current
mouse button handling is removed in upcomming commit.

Changed paths:
    backends/platform/ios7/ios7_common.h
    backends/platform/ios7/ios7_osys_events.cpp
    backends/platform/ios7/ios7_osys_main.h
    backends/platform/ios7/ios7_video.mm


diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index f80222286ca..47bdea403f1 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -46,6 +46,7 @@ enum InputEvent {
 	kInputApplicationRestoreState,
 	kInputSwipe,
 	kInputTap,
+	kInputLongPress,
 	kInputMainMenu,
 	kInputJoystickAxisMotion,
 	kInputJoystickButtonDown,
@@ -84,6 +85,11 @@ enum UIViewTapDescription {
 	kUIViewTapDouble = 2
 };
 
+enum UIViewLongPressDescription {
+	UIViewLongPressStarted = 1,
+	UIViewLongPressEnded = 2
+};
+
 struct InternalEvent {
 	InternalEvent() : type(), value1(), value2() {}
 	InternalEvent(InputEvent t, int v1, int v2) : type(t), value1(v1), value2(v2) {}
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index 4b1671c9be3..c80576f9c6c 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -133,6 +133,11 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 				return false;
 			break;
 
+		case kInputLongPress:
+			if (!handleEvent_longPress(event, (UIViewLongPressDescription) internalEvent.value1, internalEvent.value2))
+				return false;
+			break;
+
 		case kInputMainMenu:
 			event.type = Common::EVENT_MAINMENU;
 			_queuedInputEvent.type = Common::EVENT_INVALID;
@@ -491,15 +496,25 @@ bool OSystem_iOS7::handleEvent_swipe(Common::Event &event, int direction, int to
 
 bool OSystem_iOS7::handleEvent_tap(Common::Event &event, UIViewTapDescription type, int touches) {
 	if (touches == 1) {
-		if (type == kUIViewTapDouble) {
+		if (type == kUIViewTapSingle) {
+			event.type = Common::EVENT_LBUTTONDOWN;
+			handleEvent_mouseEvent(event, 0, 0);
+
+			_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
+			_queuedEventTime = getMillis() + kQueuedInputEventDelay;
+			handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
+			return true;
+		}
+	} else if (touches == 2) {
+		if (type == kUIViewTapSingle) {
 			event.type = Common::EVENT_RBUTTONDOWN;
+			handleEvent_mouseEvent(event, 0, 0);
+
 			_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
 			_queuedEventTime = getMillis() + kQueuedInputEventDelay;
+			handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
 			return true;
-		}
-	}
-	else if (touches == 2) {
-		if (type == kUIViewTapDouble) {
+		} else if (type == kUIViewTapDouble) {
 			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
 			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_ESCAPE;
 			event.type = Common::EVENT_KEYDOWN;
@@ -511,3 +526,26 @@ bool OSystem_iOS7::handleEvent_tap(Common::Event &event, UIViewTapDescription ty
 	}
 	return false;
 }
+
+bool OSystem_iOS7::handleEvent_longPress(Common::Event &event, UIViewLongPressDescription type, int touches) {
+	if (touches == 1) {
+		if (type == UIViewLongPressStarted) {
+			event.type = Common::EVENT_LBUTTONDOWN;
+			handleEvent_mouseEvent(event, 0, 0);
+		} else {
+			event.type = Common::EVENT_LBUTTONUP;
+			handleEvent_mouseEvent(event, 0, 0);
+		}
+		return true;
+	} else if (touches == 2) {
+		if (type == UIViewLongPressStarted) {
+			event.type = Common::EVENT_RBUTTONDOWN;
+			handleEvent_mouseEvent(event, 0, 0);
+		} else {
+			event.type = Common::EVENT_RBUTTONUP;
+			handleEvent_mouseEvent(event, 0, 0);
+		}
+		return true;
+	}
+	return false;
+}
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index b08a4480c0d..0affc8b80de 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -182,6 +182,7 @@ protected:
 
 	bool handleEvent_swipe(Common::Event &event, int direction, int touches);
 	bool handleEvent_tap(Common::Event &event, UIViewTapDescription type, int touches);
+	bool handleEvent_longPress(Common::Event &event, UIViewLongPressDescription type, int touches);
 	void handleEvent_keyPressed(Common::Event &event, int keyPressed);
 	void handleEvent_orientationChanged(int orientation);
 	void handleEvent_touchModeChanged();
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 1e87ee14ac0..19e3d0d3d42 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -86,6 +86,8 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 #if TARGET_OS_IOS
 	UIButton *_menuButton;
 	UIButton *_toggleTouchModeButton;
+	UITapGestureRecognizer *oneFingerTapGesture;
+	UITapGestureRecognizer *twoFingerTapGesture;
 #endif
 }
 
@@ -193,6 +195,33 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 	[_toggleTouchModeButton addGestureRecognizer:longPressKeyboard];
 	[longPressKeyboard release];
 
+	oneFingerTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerTap:)];
+	[oneFingerTapGesture setNumberOfTapsRequired:1];
+	[oneFingerTapGesture setNumberOfTouchesRequired:1];
+	[oneFingerTapGesture setDelaysTouchesBegan:NO];
+	[oneFingerTapGesture setDelaysTouchesEnded:NO];
+
+	twoFingerTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerTap:)];
+	[twoFingerTapGesture setNumberOfTapsRequired:1];
+	[twoFingerTapGesture setNumberOfTouchesRequired:2];
+	[twoFingerTapGesture setDelaysTouchesBegan:NO];
+	[twoFingerTapGesture setDelaysTouchesEnded:NO];
+
+	// Default long press duration is 0.5 seconds which suits us well
+	UILongPressGestureRecognizer *oneFingerLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerLongPress:)];
+	[oneFingerLongPressGesture setNumberOfTouchesRequired:1];
+	[oneFingerLongPressGesture setDelaysTouchesBegan:NO];
+	[oneFingerLongPressGesture setDelaysTouchesEnded:NO];
+	[oneFingerLongPressGesture setCancelsTouchesInView:NO];
+	[oneFingerLongPressGesture canPreventGestureRecognizer:oneFingerTapGesture];
+
+	UILongPressGestureRecognizer *twoFingerLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerLongPress:)];
+	[twoFingerLongPressGesture setNumberOfTouchesRequired:2];
+	[twoFingerLongPressGesture setDelaysTouchesBegan:NO];
+	[twoFingerLongPressGesture setDelaysTouchesEnded:NO];
+	[twoFingerLongPressGesture setCancelsTouchesInView:NO];
+	[twoFingerLongPressGesture canPreventGestureRecognizer:twoFingerTapGesture];
+
 	UIPinchGestureRecognizer *pinchKeyboard = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardPinch:)];
 
 	UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersSwipeRight:)];
@@ -259,6 +288,10 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 	[self addGestureRecognizer:swipeUp3];
 	[self addGestureRecognizer:swipeDown3];
 	[self addGestureRecognizer:doubleTapTwoFingers];
+	[self addGestureRecognizer:oneFingerTapGesture];
+	[self addGestureRecognizer:twoFingerTapGesture];
+	[self addGestureRecognizer:oneFingerLongPressGesture];
+	[self addGestureRecognizer:twoFingerLongPressGesture];
 
 	[pinchKeyboard release];
 	[swipeRight release];
@@ -270,6 +303,10 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 	[swipeUp3 release];
 	[swipeDown3 release];
 	[doubleTapTwoFingers release];
+	[oneFingerTapGesture release];
+	[twoFingerTapGesture release];
+	[oneFingerLongPressGesture release];
+	[twoFingerLongPressGesture release];
 #elif TARGET_OS_TV
 	UITapGestureRecognizer *tapUpGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(threeFingersSwipeUp:)];
 	[tapUpGestureRecognizer setAllowedPressTypes:@[@(UIPressTypeUpArrow)]];
@@ -574,6 +611,8 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 }
 
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
+	[oneFingerTapGesture setState:UIGestureRecognizerStateCancelled];
+	[twoFingerTapGesture setState:UIGestureRecognizerStateCancelled];
 	for (GameController *c : _controllers) {
 		if ([c isKindOfClass:TouchController.class]) {
 			[(TouchController *)c touchesMoved:touches withEvent:event];
@@ -666,6 +705,34 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 }
 #endif
 
+- (void)oneFingerTap:(UITapGestureRecognizer *)recognizer {
+	if (recognizer.state == UIGestureRecognizerStateEnded) {
+		[self addEvent:InternalEvent(kInputTap, kUIViewTapSingle, 1)];
+	}
+}
+
+- (void)twoFingerTap:(UITapGestureRecognizer *)recognizer {
+	if (recognizer.state == UIGestureRecognizerStateEnded) {
+		[self addEvent:InternalEvent(kInputTap, kUIViewTapSingle, 2)];
+	}
+}
+
+- (void)oneFingerLongPress:(UILongPressGestureRecognizer *)recognizer {
+	if (recognizer.state == UIGestureRecognizerStateBegan) {
+		[self addEvent:InternalEvent(kInputLongPress, UIViewLongPressStarted, 1)];
+	} else if (recognizer.state == UIGestureRecognizerStateEnded) {
+		[self addEvent:InternalEvent(kInputLongPress, UIViewLongPressEnded, 1)];
+	}
+}
+
+- (void)twoFingerLongPress:(UILongPressGestureRecognizer *)recognizer {
+	if (recognizer.state == UIGestureRecognizerStateBegan) {
+		[self addEvent:InternalEvent(kInputLongPress, UIViewLongPressStarted, 2)];
+	} else if (recognizer.state == UIGestureRecognizerStateEnded) {
+		[self addEvent:InternalEvent(kInputLongPress, UIViewLongPressEnded, 2)];
+	}
+}
+
 - (void)twoFingersSwipeRight:(UISwipeGestureRecognizer *)recognizer {
 	[self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeRight, 2)];
 }


Commit: b2ba5819174d1eaa78ded09e44bdb7c7ec796e99
    https://github.com/scummvm/scummvm/commit/b2ba5819174d1eaa78ded09e44bdb7c7ec796e99
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Remove old touch to mouse button translations

Remove the old translations from touch events to mouse button events.
These have been replaced with UIGestures.

Changed paths:
    backends/platform/ios7/ios7_options.mm
    backends/platform/ios7/ios7_osys_events.cpp
    backends/platform/ios7/ios7_osys_main.cpp
    backends/platform/ios7/ios7_osys_main.h


diff --git a/backends/platform/ios7/ios7_options.mm b/backends/platform/ios7/ios7_options.mm
index 791b8e5b454..d9623c1aa08 100644
--- a/backends/platform/ios7/ios7_options.mm
+++ b/backends/platform/ios7/ios7_options.mm
@@ -70,7 +70,6 @@ private:
 	GUI::StaticTextWidget *_gamepadControllerDirectionalInputDesc;
 	GUI::PopUpWidget *_gamepadControllerDirectionalInputPopUp;
 
-	GUI::CheckboxWidget *_clickAndDragCheckbox;
 	GUI::CheckboxWidget *_keyboardFnBarCheckbox;
 #if TARGET_OS_IOS
 	GUI::StaticTextWidget *_preferredTouchModeDesc;
@@ -108,7 +107,6 @@ IOS7OptionsWidget::IOS7OptionsWidget(GuiObject *boss, const Common::String &name
 	_gamepadControllerDirectionalInputPopUp->appendEntry(_("Thumbstick"), kDirectionalInputThumbstick);
 	_gamepadControllerDirectionalInputPopUp->appendEntry(_("Dpad"), kDirectionalInputDpad);
 
-	_clickAndDragCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.ClickAndDragMode", _("Mouse-click-and-drag mode"));
 	_keyboardFnBarCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.KeyboardFunctionBar", _("Show keyboard function bar"));
 
 #if TARGET_OS_IOS
@@ -250,7 +248,6 @@ void IOS7OptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
 			  "One finger tap: Left mouse click\n"
 			  "Two finger tap: Right mouse click\n"
 			  "Two finger double tap: ESC\n"
-			  "Two finger swipe (bottom to top): Toggles Click and drag mode\n"
 			  "Two finger swipe (left to right): Toggles between touch direct mode and touchpad mode\n"
 			  "Two finger swipe (right to left): Shows/hides on-screen controls\n"
 			  "Two finger swipe (top to bottom): Global Main Menu\n"
@@ -392,7 +389,6 @@ void IOS7OptionsWidget::load() {
 	_gamepadControllerOpacityLabel->setValue(_gamepadControllerOpacitySlider->getValue());
 	_gamepadControllerDirectionalInputPopUp->setSelectedTag(loadDirectionalInput("gamepad_controller_directional_input", !inAppDomain, kDirectionalInputThumbstick));
 
-	_clickAndDragCheckbox->setState(ConfMan.getBool("clickanddrag_mode", _domain));
 	_keyboardFnBarCheckbox->setState(ConfMan.getBool("keyboard_fn_bar", _domain));
 
 #if TARGET_OS_IOS
@@ -419,7 +415,6 @@ bool IOS7OptionsWidget::save() {
 		ConfMan.setInt("gamepad_controller_opacity", _gamepadControllerOpacitySlider->getValue(), _domain);
 		ConfMan.setInt("gamepad_controller_directional_input", _gamepadControllerDirectionalInputPopUp->getSelectedTag(), _domain);
 
-		ConfMan.setBool("clickanddrag_mode", _clickAndDragCheckbox->getState(), _domain);
 		ConfMan.setBool("keyboard_fn_bar", _keyboardFnBarCheckbox->getState(), _domain);
 
 #if TARGET_OS_IOS
@@ -448,7 +443,6 @@ bool IOS7OptionsWidget::save() {
 		ConfMan.removeKey("touch_mode_2d_games", _domain);
 		ConfMan.removeKey("touch_mode_3d_games", _domain);
 
-		ConfMan.removeKey("clickanddrag_mode", _domain);
 		ConfMan.removeKey("keyboard_fn_bar", _domain);
 
 		if (inAppDomain) {
@@ -470,9 +464,7 @@ bool IOS7OptionsWidget::hasKeys() {
 
 	ConfMan.hasKey("touch_mode_menus", _domain) ||
 	ConfMan.hasKey("touch_mode_2d_games", _domain) ||
-	ConfMan.hasKey("touch_mode_3d_games", _domain) ||
-
-	ConfMan.hasKey("clickanddrag_mode", _domain);
+	ConfMan.hasKey("touch_mode_3d_games", _domain);
 
 #if TARGET_OS_IOS
 	hasKeys = hasKeys || (_domain.equalsIgnoreCase(Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("orientation_menus", _domain)) ||
@@ -515,7 +507,6 @@ void IOS7OptionsWidget::setEnabled(bool e) {
 	_gamepadControllerOpacityLabel->setEnabled(false);
 #endif /* TARGET_OS_IOS */
 
-	_clickAndDragCheckbox->setEnabled(e);
 	_keyboardFnBarCheckbox->setEnabled(e);
 
 #if TARGET_OS_IOS
@@ -554,7 +545,6 @@ void OSystem_iOS7::registerDefaultSettings(const Common::String &target) const {
 	ConfMan.registerDefault("touch_mode_2d_games", "touchpad");
 	ConfMan.registerDefault("touch_mode_3d_games", "gamepad");
 
-	ConfMan.registerDefault("clickanddrag_mode", false);
 	ConfMan.registerDefault("keyboard_fn_bar", true);
 
 #if TARGET_OS_IOS
@@ -568,7 +558,6 @@ void OSystem_iOS7::registerDefaultSettings(const Common::String &target) const {
 void OSystem_iOS7::applyBackendSettings() {
 	virtualController(ConfMan.getBool("gamepad_controller"));
 	// _currentTouchMode is applied by the graphic manager
-	_mouseClickAndDragEnabled = ConfMan.getBool("clickanddrag_mode");
 
 #if TARGET_OS_IOS
 	applyOrientationSettings();
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index c80576f9c6c..c00a4dbb12e 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -109,12 +109,10 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 				return false;
 			break;
 		case kInputTouchSecondDown:
-			_secondaryTapped = true;
 			if (!handleEvent_touchSecondDown(event, internalEvent.value1, internalEvent.value2))
 				return false;
 			break;
 		case kInputTouchSecondUp:
-			_secondaryTapped = false;
 			if (!handleEvent_touchSecondUp(event, internalEvent.value1, internalEvent.value2))
 				return false;
 			break;
@@ -180,12 +178,6 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 }
 
 bool OSystem_iOS7::handleEvent_touchFirstDown(Common::Event &event, int x, int y) {
-	//printf("Mouse down at (%u, %u)\n", x, y);
-
-	// Workaround: kInputMouseSecondToggled isn't always sent when the
-	// secondary finger is lifted. Need to make sure we get out of that mode.
-	_secondaryTapped = false;
-
 	_lastPadX = x;
 	_lastPadY = y;
 
@@ -194,106 +186,28 @@ bool OSystem_iOS7::handleEvent_touchFirstDown(Common::Event &event, int x, int y
 		dynamic_cast<iOSCommonGraphics *>(_graphicsManager)->notifyMousePosition(mouse);
 	}
 
-	if (_mouseClickAndDragEnabled) {
-		if (_currentTouchMode == kTouchModeTouchpad) {
-			_queuedInputEvent.type = Common::EVENT_LBUTTONDOWN;
-			_queuedEventTime = getMillis() + 250;
-			handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-		} else {
-			event.type = Common::EVENT_LBUTTONDOWN;
-			handleEvent_mouseEvent(event, 0, 0);
-		}
-		return true;
-	} else {
-		_lastMouseDown = getMillis();
-	}
 	return false;
 }
 
 bool OSystem_iOS7::handleEvent_touchFirstUp(Common::Event &event, int x, int y) {
-	//printf("Mouse up at (%u, %u)\n", x, y);
-
-	if (_secondaryTapped) {
-		_secondaryTapped = false;
-		if (!handleEvent_touchSecondUp(event, x, y))
-			return false;
-	} else if (_mouseClickAndDragEnabled) {
-		if (_currentTouchMode == kTouchModeTouchpad && _queuedInputEvent.type == Common::EVENT_LBUTTONDOWN) {
-			// This has not been sent yet, send it right away
-			event = _queuedInputEvent;
-			_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
-			_queuedEventTime = getMillis() + kQueuedInputEventDelay;
-			handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-		} else {
-			event.type = Common::EVENT_LBUTTONUP;
-			handleEvent_mouseEvent(event, 0, 0);
-		}
-	} else {
-		if (getMillis() - _lastMouseDown < 250) {
-			event.type = Common::EVENT_LBUTTONDOWN;
-			handleEvent_mouseEvent(event, 0, 0);
-
-			_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
-			handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-			_queuedEventTime = getMillis() + kQueuedInputEventDelay;
-		} else
-			return false;
-	}
-
-	return true;
+	return false;
 }
 
 bool OSystem_iOS7::handleEvent_touchSecondDown(Common::Event &event, int x, int y) {
-
-	if (_mouseClickAndDragEnabled) {
-		event.type = Common::EVENT_LBUTTONUP;
-		handleEvent_mouseEvent(event, 0, 0);
-
-		_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN;
-		_queuedEventTime = getMillis() + 250;
-		handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-	} else
-		return false;
-
-	return true;
+	return false;
 }
 
 bool OSystem_iOS7::handleEvent_touchSecondUp(Common::Event &event, int x, int y) {
-	int curTime = getMillis();
-
-	if (!_mouseClickAndDragEnabled) {
-		//printf("Rightclick!\n");
-		event.type = Common::EVENT_RBUTTONDOWN;
-		handleEvent_mouseEvent(event, 0, 0);
-		_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
-		handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-		_queuedEventTime = curTime + kQueuedInputEventDelay;
-	} else if (_queuedInputEvent.type == Common::EVENT_RBUTTONDOWN) {
-		// This has not been sent yet, send it right away
-		event = _queuedInputEvent;
-		_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
-		_queuedEventTime = curTime + kQueuedInputEventDelay;
-		handleEvent_mouseEvent(_queuedInputEvent, 0, 0);
-	} else {
-		event.type = Common::EVENT_RBUTTONUP;
-		handleEvent_mouseEvent(event, 0, 0);
-	}
-
-	return true;
+	return false;
 }
 
 bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, int y) {
-	//printf("Mouse dragged at (%u, %u)\n", x, y);
 	int deltaX = _lastPadX - x;
 	int deltaY = _lastPadY - y;
 	_lastPadX = x;
 	_lastPadY = y;
 
 	if (_currentTouchMode == kTouchModeTouchpad) {
-		if (_mouseClickAndDragEnabled && _queuedInputEvent.type == Common::EVENT_LBUTTONDOWN) {
-			// Cancel the button down event since this was a pure mouse move
-			_queuedInputEvent.type = Common::EVENT_INVALID;
-		}
 		handleEvent_mouseDelta(event, deltaX, deltaY);
 	} else {
 		// Update mouse position
@@ -439,16 +353,6 @@ bool OSystem_iOS7::handleEvent_swipe(Common::Event &event, int direction, int to
 	else if (touches == 2) {
 		switch ((UIViewSwipeDirection)direction) {
 		case kUIViewSwipeUp: {
-			_mouseClickAndDragEnabled = !_mouseClickAndDragEnabled;
-			ConfMan.setBool("clickanddrag_mode", _mouseClickAndDragEnabled);
-			ConfMan.flushToDisk();
-			Common::U32String dialogMsg;
-			if (_mouseClickAndDragEnabled) {
-				dialogMsg = _("Mouse-click-and-drag mode enabled.");
-			} else
-				dialogMsg = _("Mouse-click-and-drag mode disabled.");
-			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
-			dialog.runModal();
 			return false;
 		}
 
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 972e86ca55b..08562241eaa 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -89,12 +89,10 @@ public:
 
 OSystem_iOS7::OSystem_iOS7() :
 	_mixer(NULL), _queuedEventTime(0),
-	_secondaryTapped(false),
 	_screenOrientation(kScreenOrientationAuto),
 	_timeSuspended(0), _runningTasks(0) {
 	_queuedInputEvent.type = Common::EVENT_INVALID;
 	_currentTouchMode = kTouchModeTouchpad;
-	_mouseClickAndDragEnabled = ConfMan.getBool("clickanddrag_mode");
 
 	_chrootBasePath = iOS7_getDocumentsDir();
 	ChRootFilesystemFactory *chFsFactory = new ChRootFilesystemFactory(_chrootBasePath);
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 0affc8b80de..ab7c95b176d 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -66,8 +66,6 @@ protected:
 	long _lastMouseDown;
 	long _queuedEventTime;
 	Common::Event _queuedInputEvent;
-	bool _secondaryTapped;
-	bool _mouseClickAndDragEnabled;
 	TouchMode _currentTouchMode;
 	int _lastPadX;
 	int _lastPadY;


Commit: cc499d560e8302cb6e614f9c5c7d0bc25a281d5e
    https://github.com/scummvm/scummvm/commit/cc499d560e8302cb6e614f9c5c7d0bc25a281d5e
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Only handle one touch for mouse movements

The callback functions touchesBegan, touchesMoved and touchesEnded
are from now only used for mouse pointer movements. Only one touch
is then required to be tracked.

Disable multi-touch in view to accomplish this. The setting does
not affect the gesture recognizers attached to the view, only the
touchesBegan, touchesMoved and touchesEnded callbacks are affected
that only the actions for the first touch in view are sent.

Changed paths:
    backends/platform/ios7/ios7_app_delegate.mm
    backends/platform/ios7/ios7_touch_controller.mm


diff --git a/backends/platform/ios7/ios7_app_delegate.mm b/backends/platform/ios7/ios7_app_delegate.mm
index 1223281b4b0..ce2db9de605 100644
--- a/backends/platform/ios7/ios7_app_delegate.mm
+++ b/backends/platform/ios7/ios7_app_delegate.mm
@@ -58,7 +58,9 @@
 
 	_view = [[iPhoneView alloc] initWithFrame:rect];
 #if TARGET_OS_IOS
-	_view.multipleTouchEnabled = YES;
+	// This property does not affect the gesture recognizers attached to the view.
+	// Gesture recognizers receive all touches that occur in the view.
+	_view.multipleTouchEnabled = NO;
 #endif
 	_controller.view = _view;
 
diff --git a/backends/platform/ios7/ios7_touch_controller.mm b/backends/platform/ios7/ios7_touch_controller.mm
index 926a71274f5..eb6ee0f8c0f 100644
--- a/backends/platform/ios7/ios7_touch_controller.mm
+++ b/backends/platform/ios7/ios7_touch_controller.mm
@@ -26,8 +26,7 @@
 #include "backends/platform/ios7/ios7_video.h"
 
 @implementation TouchController {
-	UITouch *_firstTouch;
-	UITouch *_secondTouch;
+	UITouch *_touch;
 }
 
 @dynamic view;
@@ -36,9 +35,7 @@
 - (id)initWithView:(iPhoneView *)view {
 	self = [super initWithView:view];
 
-	_firstTouch = NULL;
-	_secondTouch = NULL;
-
+	_touch = nil;
 	// Touches should always be present in iOS view
 	[self setIsConnected:YES];
 
@@ -52,90 +49,41 @@
 	// they are required as the Apple TV remote sends touh events
 	// but no mouse events.
 #if TARGET_OS_IOS
-	return touch.type == UITouchTypeDirect;
+	return touch != nil && touch.type == UITouchTypeDirect;
 #else
 	return YES;
 #endif
 }
 
-- (UITouch *)secondTouchOtherTouchThan:(UITouch *)touch in:(NSSet *)set {
-	NSArray *all = [set allObjects];
-	for (UITouch *t in all) {
-		if (t != touch) {
-			return t;
-		}
-	}
-	return nil;
-}
-
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
-	NSSet *allTouches = [event allTouches];
-	switch (allTouches.count) {
-	case 1: {
-		_firstTouch = [allTouches anyObject];
-		if ([self shouldHandleTouch:_firstTouch]) {
-			CGPoint p = [self getLocationInView:_firstTouch];
-			[[self view] addEvent:InternalEvent(kInputTouchFirstDown, p.x, p.y)];
-		}
-		break;
-	}
-	case 2: {
-		_secondTouch = [self secondTouchOtherTouchThan:_firstTouch in:allTouches];
-		if (_secondTouch && [self shouldHandleTouch:_secondTouch]) {
-			CGPoint p = [self getLocationInView:_firstTouch];
-			[[self view] addEvent:InternalEvent(kInputTouchSecondDown, p.x, p.y)];
-		}
-		break;
-	}
-	default:
-		break;
+	_touch = [touches anyObject];
+
+	if ([self shouldHandleTouch:_touch]) {
+		CGPoint p = [self getLocationInView:_touch];
+		[[self view] addEvent:InternalEvent(kInputTouchFirstDown, p.x, p.y)];
 	}
 }
 
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
-	NSSet *allTouches = [event allTouches];
-	for (UITouch *touch in allTouches) {
-		if ([self shouldHandleTouch:touch]) {
-			if (touch == _firstTouch) {
-				CGPoint p = [self getLocationInView:touch];
-				[[self view] addEvent:InternalEvent(kInputTouchFirstDragged , p.x, p.y)];
-			} else if (touch == _secondTouch) {
-				CGPoint p = [self getLocationInView:touch];
-				[[self view] addEvent:InternalEvent(kInputTouchSecondDragged , p.x, p.y)];
-			}
-		}
+	UITouch *t = [touches anyObject];
+
+	if (t != _touch) {
+		// We shouldn't end up here but if we do bail out
+		return;
+	}
+	_touch = t;
+	if ([self shouldHandleTouch:_touch]) {
+		CGPoint p = [self getLocationInView:_touch];
+		[[self view] addEvent:InternalEvent(kInputTouchFirstDragged, p.x, p.y)];
 	}
 }
 
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
-	NSSet *allTouches = [event allTouches];
-	switch (allTouches.count) {
-	case 1: {
-		_firstTouch = [allTouches anyObject];
-		if ([self shouldHandleTouch:_firstTouch]) {
-			CGPoint p = [self getLocationInView:_firstTouch];
-			[[self view] addEvent:InternalEvent(kInputTouchFirstUp, p.x, p.y)];
-		}
-		break;
-	}
-	case 2: {
-		_secondTouch = [self secondTouchOtherTouchThan:_firstTouch in:allTouches];
-		if (_secondTouch && [self shouldHandleTouch:_secondTouch]) {
-			CGPoint p = [self getLocationInView:_firstTouch];
-			[[self view] addEvent:InternalEvent(kInputTouchSecondUp, p.x, p.y)];
-		}
-		break;
-	}
-	default:
-		break;
-	}
-	_firstTouch = nil;
-	_secondTouch = nil;
+	_touch = nil;
 }
 
 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
-	_firstTouch = nil;
-	_secondTouch = nil;
+	_touch = nil;
 }
 
 @end


Commit: a490768622138552a94f73d70f33ccd5e8bed46a
    https://github.com/scummvm/scummvm/commit/a490768622138552a94f73d70f33ccd5e8bed46a
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Refactor touch event functions

Remove the deprecated events and their corresponding functions.

Changed paths:
    backends/platform/ios7/ios7_common.h
    backends/platform/ios7/ios7_osys_events.cpp
    backends/platform/ios7/ios7_osys_main.h
    backends/platform/ios7/ios7_touch_controller.mm


diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index 47bdea403f1..c7dcb42d06b 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -26,12 +26,8 @@
 
 
 enum InputEvent {
-	kInputTouchFirstDown,
-	kInputTouchFirstUp,
-	kInputTouchFirstDragged,
-	kInputTouchSecondDragged,
-	kInputTouchSecondDown,
-	kInputTouchSecondUp,
+	kInputTouchBegan,
+	kInputTouchMoved,
 	kInputMouseLeftButtonDown,
 	kInputMouseLeftButtonUp,
 	kInputMouseRightButtonDown,
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index c00a4dbb12e..321e8667f0e 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -45,18 +45,13 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 
 	if (iOS7_fetchEvent(&internalEvent)) {
 		switch (internalEvent.type) {
-		case kInputTouchFirstDown:
-			if (!handleEvent_touchFirstDown(event, internalEvent.value1, internalEvent.value2))
+		case kInputTouchBegan:
+			if (!handleEvent_touchBegan(event, internalEvent.value1, internalEvent.value2))
 				return false;
 			break;
 
-		case kInputTouchFirstUp:
-			if (!handleEvent_touchFirstUp(event, internalEvent.value1, internalEvent.value2))
-				return false;
-			break;
-
-		case kInputTouchFirstDragged:
-			if (!handleEvent_touchFirstDragged(event, internalEvent.value1, internalEvent.value2))
+		case kInputTouchMoved:
+			if (!handleEvent_touchMoved(event, internalEvent.value1, internalEvent.value2))
 				return false;
 			break;
 
@@ -104,19 +99,6 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 			handleEvent_applicationClearState();
 			return false;
 
-		case kInputTouchSecondDragged:
-			if (!handleEvent_touchSecondDragged(event, internalEvent.value1, internalEvent.value2))
-				return false;
-			break;
-		case kInputTouchSecondDown:
-			if (!handleEvent_touchSecondDown(event, internalEvent.value1, internalEvent.value2))
-				return false;
-			break;
-		case kInputTouchSecondUp:
-			if (!handleEvent_touchSecondUp(event, internalEvent.value1, internalEvent.value2))
-				return false;
-			break;
-
 		case kInputKeyPressed:
 			handleEvent_keyPressed(event, internalEvent.value1);
 			break;
@@ -177,7 +159,7 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
 	return false;
 }
 
-bool OSystem_iOS7::handleEvent_touchFirstDown(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchBegan(Common::Event &event, int x, int y) {
 	_lastPadX = x;
 	_lastPadY = y;
 
@@ -189,19 +171,7 @@ bool OSystem_iOS7::handleEvent_touchFirstDown(Common::Event &event, int x, int y
 	return false;
 }
 
-bool OSystem_iOS7::handleEvent_touchFirstUp(Common::Event &event, int x, int y) {
-	return false;
-}
-
-bool OSystem_iOS7::handleEvent_touchSecondDown(Common::Event &event, int x, int y) {
-	return false;
-}
-
-bool OSystem_iOS7::handleEvent_touchSecondUp(Common::Event &event, int x, int y) {
-	return false;
-}
-
-bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchMoved(Common::Event &event, int x, int y) {
 	int deltaX = _lastPadX - x;
 	int deltaY = _lastPadY - y;
 	_lastPadX = x;
@@ -219,10 +189,6 @@ bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, in
 	return true;
 }
 
-bool OSystem_iOS7::handleEvent_touchSecondDragged(Common::Event &event, int x, int y) {
-	return false;
-}
-
 void OSystem_iOS7::handleEvent_mouseLeftButtonDown(Common::Event &event, int x, int y) {
 	event.type = Common::EVENT_LBUTTONDOWN;
 	handleEvent_mouseEvent(event, 0, 0);
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index ab7c95b176d..0aa705f023f 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -1,4 +1,4 @@
-/* ScummVM - Graphic Adventure Engine
+ /* ScummVM - Graphic Adventure Engine
  *
  * ScummVM is the legal property of its developers, whose names
  * are too numerous to list here. Please refer to the COPYRIGHT
@@ -190,14 +190,8 @@ protected:
 	void handleEvent_applicationRestoreState();
 	void handleEvent_applicationClearState();
 
-	bool handleEvent_touchFirstDown(Common::Event &event, int x, int y);
-	bool handleEvent_touchFirstUp(Common::Event &event, int x, int y);
-
-	bool handleEvent_touchSecondDown(Common::Event &event, int x, int y);
-	bool handleEvent_touchSecondUp(Common::Event &event, int x, int y);
-
-	bool handleEvent_touchFirstDragged(Common::Event &event, int x, int y);
-	bool handleEvent_touchSecondDragged(Common::Event &event, int x, int y);
+	bool handleEvent_touchBegan(Common::Event &event, int x, int y);
+	bool handleEvent_touchMoved(Common::Event &event, int x, int y);
 
 	void handleEvent_mouseLeftButtonDown(Common::Event &event, int x, int y);
 	void handleEvent_mouseLeftButtonUp(Common::Event &event, int x, int y);
diff --git a/backends/platform/ios7/ios7_touch_controller.mm b/backends/platform/ios7/ios7_touch_controller.mm
index eb6ee0f8c0f..22b52d99081 100644
--- a/backends/platform/ios7/ios7_touch_controller.mm
+++ b/backends/platform/ios7/ios7_touch_controller.mm
@@ -60,7 +60,7 @@
 
 	if ([self shouldHandleTouch:_touch]) {
 		CGPoint p = [self getLocationInView:_touch];
-		[[self view] addEvent:InternalEvent(kInputTouchFirstDown, p.x, p.y)];
+		[[self view] addEvent:InternalEvent(kInputTouchBegan, p.x, p.y)];
 	}
 }
 
@@ -74,7 +74,7 @@
 	_touch = t;
 	if ([self shouldHandleTouch:_touch]) {
 		CGPoint p = [self getLocationInView:_touch];
-		[[self view] addEvent:InternalEvent(kInputTouchFirstDragged, p.x, p.y)];
+		[[self view] addEvent:InternalEvent(kInputTouchMoved, p.x, p.y)];
 	}
 }
 


Commit: 8466e036b501543ae2a7831917e0b5b83d73fe7f
    https://github.com/scummvm/scummvm/commit/8466e036b501543ae2a7831917e0b5b83d73fe7f
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Update touch mode when swiping two fingers right

The ability to change touch mode between touchpad emulation and
"direct" mouse mode is kept. Inform the user about the updated
mode change and update the on-screen control button to reflect
the new mode which is useful when the on-screen controls are
disabled.

Changed paths:
    backends/platform/ios7/ios7_osys_events.cpp


diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index 321e8667f0e..682d2e7ad00 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -337,12 +337,13 @@ bool OSystem_iOS7::handleEvent_swipe(Common::Event &event, int direction, int to
 			} else {
 				_currentTouchMode = kTouchModeDirect;
 			}
+			updateTouchMode();
 
 			Common::U32String dialogMsg;
 			if (_currentTouchMode == kTouchModeTouchpad)
-				dialogMsg = _("Touchpad mode enabled.");
+				dialogMsg = _("Touchpad emulation");
 			else
-				dialogMsg = _("Touchpad mode disabled.");
+				dialogMsg = _("Direct mouse");
 			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
 			dialog.runModal();
 			return false;


Commit: 8f407b7a06f183a297b8a85de1f1b9a3e270c3ec
    https://github.com/scummvm/scummvm/commit/8f407b7a06f183a297b8a85de1f1b9a3e270c3ec
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-11T06:28:03+02:00

Commit Message:
IOS7: Fix long press on touch mode button to show keyboard

After adding the other long-press gestures it was hard to trigger
the gesture to show the keyboard by pressing the touch mode button
on the on-screen controls.

Changing the minimum time to trigger from 1 second to default 0.5
seconds fixed that. Add the one-touch-only requirement as well.

Changed paths:
    backends/platform/ios7/ios7_video.mm


diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 19e3d0d3d42..7687e995e05 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -191,8 +191,8 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 - (void)setupGestureRecognizers {
 #if TARGET_OS_IOS
 	UILongPressGestureRecognizer *longPressKeyboard = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressKeyboard:)];
-	[longPressKeyboard setMinimumPressDuration:1];
 	[_toggleTouchModeButton addGestureRecognizer:longPressKeyboard];
+	[longPressKeyboard setNumberOfTouchesRequired:1];
 	[longPressKeyboard release];
 
 	oneFingerTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerTap:)];




More information about the Scummvm-git-logs mailing list