[Scummvm-git-logs] scummvm master -> f76cf2195ee368b4a1571c34d429783a3c853350

criezy noreply at scummvm.org
Mon Dec 5 22:02:18 UTC 2022


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

Summary:
f76cf2195e IOS7: Make "touchpad mode" usable again


Commit: f76cf2195ee368b4a1571c34d429783a3c853350
    https://github.com/scummvm/scummvm/commit/f76cf2195ee368b4a1571c34d429783a3c853350
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2022-12-05T22:02:13Z

Commit Message:
IOS7: Make "touchpad mode" usable again

"Touchpad mode" is a mode where the mouse cursor is moved based on touch
movements rather on clicks. The problem was that when "touchpad mode"
was enabled it was very hard to click on items because the cursor moved
on every single click.

Make the action occur based on the current pointer position rather on
the touch location  when in "touchpad mode".

Make the movement more intuitive when in "touchpad mode" by calculating
the delta of locations of touches and update the pointerPosition based
on that. That will give a feeling of using a real touchpad where the
location of where the touch occur doesn't matter for the cursor.

This will solve issue #13917

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


diff --git a/backends/platform/ios7/ios7_touch_controller.mm b/backends/platform/ios7/ios7_touch_controller.mm
index d556606bce8..6e567b4aaea 100644
--- a/backends/platform/ios7/ios7_touch_controller.mm
+++ b/backends/platform/ios7/ios7_touch_controller.mm
@@ -60,14 +60,24 @@
 	if (allTouches.count == 1) {
 		_firstTouch = [allTouches anyObject];
 		if (_firstTouch.type == UITouchTypeDirect) {
-			// Move the pointer to the new position
-			[self handlePointerMoveTo:[_firstTouch locationInView: [self view]]];
-			[self handleMouseButtonAction:kGameControllerMouseButtonLeft isPressed:YES at:[_firstTouch locationInView:[self view]]];
+			if (iOS7_touchpadModeEnabled()) {
+				// In touchpad mode the action should occur on the current pointer position
+				[self handleMouseButtonAction:kGameControllerMouseButtonLeft isPressed:YES at:[[self view] pointerPosition]];
+			} else {
+				// Only move the pointer to the new position if not in touchpadMode else it's very hard to click on items
+				[self handlePointerMoveTo:[_firstTouch locationInView: [self view]]];
+				[self handleMouseButtonAction:kGameControllerMouseButtonLeft isPressed:YES at:[_firstTouch locationInView:[self view]]];
+			}
 		}
 	} else if (allTouches.count == 2) {
 		_secondTouch = [self secondTouchOtherTouchThan:_firstTouch in:allTouches];
 		if (_secondTouch && _secondTouch.type == UITouchTypeDirect) {
-			[self handleMouseButtonAction:kGameControllerMouseButtonRight isPressed:YES at:[_firstTouch locationInView:[self view]]];
+			if (iOS7_touchpadModeEnabled()) {
+				// In touchpad mode the action should occur on the current pointer position
+				[self handleMouseButtonAction:kGameControllerMouseButtonRight isPressed:YES at:[[self view] pointerPosition]];
+			} else {
+				[self handleMouseButtonAction:kGameControllerMouseButtonRight isPressed:YES at:[_secondTouch locationInView:[self view]]];
+			}
 		}
 	}
 }
@@ -78,7 +88,17 @@
 		if (touch == _firstTouch ||
 			touch == _secondTouch) {
 			if (touch.type == UITouchTypeDirect) {
-				[self handlePointerMoveTo:[touch locationInView: [self view]]];
+				if (iOS7_touchpadModeEnabled()) {
+					// Calculate new position for the pointer based on delta of the current and previous location of the touch
+					CGPoint pointerLocation = [[self view] pointerPosition];
+					CGPoint touchLocation = [touch locationInView:[self view]];
+					CGPoint previousTouchLocation = [touch previousLocationInView:[self view]];
+					pointerLocation.y += touchLocation.y - previousTouchLocation.y;
+					pointerLocation.x += touchLocation.x - previousTouchLocation.x;
+					[self handlePointerMoveTo:pointerLocation];
+				} else {
+					[self handlePointerMoveTo:[touch locationInView: [self view]]];
+				}
 			}
 		}
 	}




More information about the Scummvm-git-logs mailing list