[Scummvm-git-logs] scummvm master -> 8e97e8dff40f0cb517c62f6ab08a6dff23978edc
larsamannen
noreply at scummvm.org
Mon May 15 10:43:46 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:
5a0eccf337 IOS7: Rename mouse events to touch events
568b06940e IOS7: Add mouse input events
72518221d8 IOS7: Scale mouse movements
d397938107 IOS7: Implement support for setting mouse pointer speed
01b9f728de IOS7: Implement relative mouse movements for touches
8e97e8dff4 IOS7: Refactor touchpad mode to utilize delta mouse function
Commit: 5a0eccf337d04f4eee56dde92821c32c021e8bf1
https://github.com/scummvm/scummvm/commit/5a0eccf337d04f4eee56dde92821c32c021e8bf1
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Rename mouse events to touch events
The current mouse events are handling events created from both touch
and mouse input. The events have lots of logic to deal with gestures
and different modes (touchpad mode, click-and-drag etc) which are not
applicable for hardware inputs.
Rename the current "mouse events" to "touch events" to clarify which
input that triggered an event. As this is the first commit in multi-
commit change, the mouse input need to use the "touch events" until
a new "mouse event" is implemented.
Changed paths:
backends/platform/ios7/ios7_common.h
backends/platform/ios7/ios7_game_controller.mm
backends/platform/ios7/ios7_osys_events.cpp
backends/platform/ios7/ios7_osys_main.h
diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index 50b46117af5..c5d1c5f181c 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -26,12 +26,12 @@
enum InputEvent {
- kInputMouseDown,
- kInputMouseUp,
- kInputMouseDragged,
- kInputMouseSecondDragged,
- kInputMouseSecondDown,
- kInputMouseSecondUp,
+ kInputTouchFirstDown,
+ kInputTouchFirstUp,
+ kInputTouchFirstDragged,
+ kInputTouchSecondDragged,
+ kInputTouchSecondDown,
+ kInputTouchSecondUp,
kInputOrientationChanged,
kInputKeyPressed,
kInputApplicationSuspended,
diff --git a/backends/platform/ios7/ios7_game_controller.mm b/backends/platform/ios7/ios7_game_controller.mm
index 0695df281a8..cff3b745cff 100644
--- a/backends/platform/ios7/ios7_game_controller.mm
+++ b/backends/platform/ios7/ios7_game_controller.mm
@@ -62,11 +62,11 @@
[view setPointerPosition:point];
if (_firstButtonPressed) {
- [view addEvent:InternalEvent(kInputMouseDragged, x, y)];
+ [view addEvent:InternalEvent(kInputTouchFirstDragged, x, y)];
} else if (_secondButtonPressed) {
- [view addEvent:InternalEvent(kInputMouseSecondDragged, x, y)];
+ [view addEvent:InternalEvent(kInputTouchSecondDragged, x, y)];
} else {
- [view addEvent:InternalEvent(kInputMouseDragged, x, y)];
+ [view addEvent:InternalEvent(kInputTouchFirstDragged, x, y)];
}
}
@@ -84,20 +84,20 @@
case kGameControllerMouseButtonLeft:
if (pressed) {
_firstButtonPressed = YES;
- [view addEvent:InternalEvent(kInputMouseDown, x, y)];
+ [view addEvent:InternalEvent(kInputTouchFirstDown, x, y)];
} else {
_firstButtonPressed = NO;
- [view addEvent:InternalEvent(kInputMouseUp, x, y)];
+ [view addEvent:InternalEvent(kInputTouchFirstUp, x, y)];
}
break;
case kGameControllerMouseButtonRight:
if (pressed) {
_secondButtonPressed = YES;
- [view addEvent:InternalEvent(kInputMouseSecondDown, x, y)];
+ [view addEvent:InternalEvent(kInputTouchSecondDown, x, y)];
} else {
_secondButtonPressed = NO;
- [view addEvent:InternalEvent(kInputMouseSecondUp, x, y)];
+ [view addEvent:InternalEvent(kInputTouchSecondUp, x, y)];
}
break;
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index f0542fde8d6..1d0f08d1de8 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -45,18 +45,18 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
if (iOS7_fetchEvent(&internalEvent)) {
switch (internalEvent.type) {
- case kInputMouseDown:
- if (!handleEvent_mouseDown(event, internalEvent.value1, internalEvent.value2))
+ case kInputTouchFirstDown:
+ if (!handleEvent_touchFirstDown(event, internalEvent.value1, internalEvent.value2))
return false;
break;
- case kInputMouseUp:
- if (!handleEvent_mouseUp(event, internalEvent.value1, internalEvent.value2))
+ case kInputTouchFirstUp:
+ if (!handleEvent_touchFirstUp(event, internalEvent.value1, internalEvent.value2))
return false;
break;
- case kInputMouseDragged:
- if (!handleEvent_mouseDragged(event, internalEvent.value1, internalEvent.value2))
+ case kInputTouchFirstDragged:
+ if (!handleEvent_touchFirstDragged(event, internalEvent.value1, internalEvent.value2))
return false;
break;
@@ -84,18 +84,18 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
handleEvent_applicationClearState();
return false;
- case kInputMouseSecondDragged:
- if (!handleEvent_mouseSecondDragged(event, internalEvent.value1, internalEvent.value2))
+ case kInputTouchSecondDragged:
+ if (!handleEvent_touchSecondDragged(event, internalEvent.value1, internalEvent.value2))
return false;
break;
- case kInputMouseSecondDown:
+ case kInputTouchSecondDown:
_secondaryTapped = true;
- if (!handleEvent_secondMouseDown(event, internalEvent.value1, internalEvent.value2))
+ if (!handleEvent_touchSecondDown(event, internalEvent.value1, internalEvent.value2))
return false;
break;
- case kInputMouseSecondUp:
+ case kInputTouchSecondUp:
_secondaryTapped = false;
- if (!handleEvent_secondMouseUp(event, internalEvent.value1, internalEvent.value2))
+ if (!handleEvent_touchSecondUp(event, internalEvent.value1, internalEvent.value2))
return false;
break;
@@ -150,7 +150,7 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
return false;
}
-bool OSystem_iOS7::handleEvent_mouseDown(Common::Event &event, int x, int y) {
+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
@@ -174,12 +174,12 @@ bool OSystem_iOS7::handleEvent_mouseDown(Common::Event &event, int x, int y) {
return false;
}
-bool OSystem_iOS7::handleEvent_mouseUp(Common::Event &event, int x, int y) {
+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_secondMouseUp(event, x, y))
+ if (!handleEvent_touchSecondUp(event, x, y))
return false;
} else if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
@@ -203,7 +203,7 @@ bool OSystem_iOS7::handleEvent_mouseUp(Common::Event &event, int x, int y) {
return true;
}
-bool OSystem_iOS7::handleEvent_secondMouseDown(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchSecondDown(Common::Event &event, int x, int y) {
_lastSecondaryDown = getMillis();
if (_mouseClickAndDragEnabled) {
@@ -220,7 +220,7 @@ bool OSystem_iOS7::handleEvent_secondMouseDown(Common::Event &event, int x, int
return true;
}
-bool OSystem_iOS7::handleEvent_secondMouseUp(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchSecondUp(Common::Event &event, int x, int y) {
int curTime = getMillis();
if (curTime - _lastSecondaryDown < 400) {
@@ -259,7 +259,7 @@ bool OSystem_iOS7::handleEvent_secondMouseUp(Common::Event &event, int x, int y)
return true;
}
-bool OSystem_iOS7::handleEvent_mouseDragged(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, int y) {
if (_lastDragPosX == x && _lastDragPosY == y)
return false;
@@ -304,7 +304,7 @@ bool OSystem_iOS7::handleEvent_mouseDragged(Common::Event &event, int x, int y)
return true;
}
-bool OSystem_iOS7::handleEvent_mouseSecondDragged(Common::Event &event, int x, int y) {
+bool OSystem_iOS7::handleEvent_touchSecondDragged(Common::Event &event, int x, int y) {
return false;
}
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 019b49cc2e8..16f2be24e13 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -243,14 +243,14 @@ protected:
void handleEvent_applicationRestoreState();
void handleEvent_applicationClearState();
- bool handleEvent_mouseDown(Common::Event &event, int x, int y);
- bool handleEvent_mouseUp(Common::Event &event, int x, int y);
+ bool handleEvent_touchFirstDown(Common::Event &event, int x, int y);
+ bool handleEvent_touchFirstUp(Common::Event &event, int x, int y);
- bool handleEvent_secondMouseDown(Common::Event &event, int x, int y);
- bool handleEvent_secondMouseUp(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_mouseDragged(Common::Event &event, int x, int y);
- bool handleEvent_mouseSecondDragged(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);
void rebuildSurface();
};
Commit: 568b06940eb974ba28777546e61a43079a18d8ab
https://github.com/scummvm/scummvm/commit/568b06940eb974ba28777546e61a43079a18d8ab
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Add mouse input events
Add input events that can be used by mouse devices, e.g. mices and
touchpads. This event sends the raw input actions and doesn't care
about different controller modes such as click-and-drag.
Make the mouse controller utilize the new mouse input events.
Changed paths:
backends/platform/ios7/ios7_common.h
backends/platform/ios7/ios7_mouse_controller.mm
backends/platform/ios7/ios7_osys_events.cpp
backends/platform/ios7/ios7_osys_main.h
diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index c5d1c5f181c..57d1a979e2b 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -32,6 +32,11 @@ enum InputEvent {
kInputTouchSecondDragged,
kInputTouchSecondDown,
kInputTouchSecondUp,
+ kInputMouseLeftButtonDown,
+ kInputMouseLeftButtonUp,
+ kInputMouseRightButtonDown,
+ kInputMouseRightButtonUp,
+ kInputMouseDelta,
kInputOrientationChanged,
kInputKeyPressed,
kInputApplicationSuspended,
diff --git a/backends/platform/ios7/ios7_mouse_controller.mm b/backends/platform/ios7/ios7_mouse_controller.mm
index 0cef9bf7d77..b7a8d3fc99b 100644
--- a/backends/platform/ios7/ios7_mouse_controller.mm
+++ b/backends/platform/ios7/ios7_mouse_controller.mm
@@ -54,18 +54,15 @@
_mouse = (GCMouse*)notification.object;
_mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
- CGPoint newPosition = [[self view] pointerPosition];
- newPosition.x += deltaX;
- newPosition.y += 0-deltaY;
- [self handlePointerMoveTo:newPosition];
+ [[self view] addEvent:InternalEvent(kInputMouseDelta, (int)-deltaX, (int)deltaY)];
};
_mouse.mouseInput.leftButton.valueChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
- [self handleMouseButtonAction:kGameControllerMouseButtonLeft isPressed:pressed at:[[self view] pointerPosition]];
+ [[self view] addEvent:InternalEvent(pressed ? kInputMouseLeftButtonDown : kInputMouseLeftButtonUp, 0, 0)];
};
_mouse.mouseInput.rightButton.valueChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
- [self handleMouseButtonAction:kGameControllerMouseButtonRight isPressed:pressed at:[[self view] pointerPosition]];
+ [[self view] addEvent:InternalEvent(pressed ? kInputMouseRightButtonDown : kInputMouseRightButtonUp, 0, 0)];
};
#endif
}
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index 1d0f08d1de8..be625dcaf36 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -60,6 +60,26 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
return false;
break;
+ case kInputMouseLeftButtonDown:
+ handleEvent_mouseLeftButtonDown(event, internalEvent.value1, internalEvent.value2);
+ break;
+
+ case kInputMouseLeftButtonUp:
+ handleEvent_mouseLeftButtonUp(event, internalEvent.value1, internalEvent.value2);
+ break;
+
+ case kInputMouseRightButtonDown:
+ handleEvent_mouseRightButtonDown(event, internalEvent.value1, internalEvent.value2);
+ break;
+
+ case kInputMouseRightButtonUp:
+ handleEvent_mouseRightButtonUp(event, internalEvent.value1, internalEvent.value2);
+ break;
+
+ case kInputMouseDelta:
+ handleEvent_mouseDelta(event, internalEvent.value1, internalEvent.value2);
+ break;
+
case kInputOrientationChanged:
handleEvent_orientationChanged(internalEvent.value1);
return false;
@@ -308,6 +328,57 @@ bool OSystem_iOS7::handleEvent_touchSecondDragged(Common::Event &event, int x, i
return false;
}
+void OSystem_iOS7::handleEvent_mouseLeftButtonDown(Common::Event &event, int x, int y) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
+}
+
+void OSystem_iOS7::handleEvent_mouseLeftButtonUp(Common::Event &event, int x, int y) {
+ event.type = Common::EVENT_LBUTTONUP;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
+}
+
+void OSystem_iOS7::handleEvent_mouseRightButtonDown(Common::Event &event, int x, int y) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
+}
+
+void OSystem_iOS7::handleEvent_mouseRightButtonUp(Common::Event &event, int x, int y) {
+ event.type = Common::EVENT_RBUTTONUP;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
+}
+
+void OSystem_iOS7::handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY) {
+ int mouseNewPosX = (int)(_videoContext->mouseX - deltaX);
+ int mouseNewPosY = (int)(_videoContext->mouseY - deltaY);
+
+ int widthCap = _videoContext->overlayInGUI ? _videoContext->overlayWidth : _videoContext->screenWidth;
+ int heightCap = _videoContext->overlayInGUI ? _videoContext->overlayHeight : _videoContext->screenHeight;
+
+ // Make sure the mouse position is valid
+ if (mouseNewPosX < 0)
+ mouseNewPosX = 0;
+ else if (mouseNewPosX > widthCap)
+ mouseNewPosX = widthCap;
+ if (mouseNewPosY < 0)
+ mouseNewPosY = 0;
+ else if (mouseNewPosY > heightCap)
+ mouseNewPosY = heightCap;
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.relMouse.x = deltaX;
+ event.relMouse.y = deltaY;
+ event.mouse.x = mouseNewPosX;
+ event.mouse.y = mouseNewPosY;
+
+ // Move the mouse on screen
+ warpMouse(mouseNewPosX, mouseNewPosY);
+}
+
void OSystem_iOS7::handleEvent_orientationChanged(int orientation) {
//printf("Orientation: %i\n", orientation);
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 16f2be24e13..65705488489 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -252,6 +252,12 @@ protected:
bool handleEvent_touchFirstDragged(Common::Event &event, int x, int y);
bool handleEvent_touchSecondDragged(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);
+ void handleEvent_mouseRightButtonDown(Common::Event &event, int x, int y);
+ void handleEvent_mouseRightButtonUp(Common::Event &event, int x, int y);
+ void handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY);
+
void rebuildSurface();
};
Commit: 72518221d8ce1532d13b7349cb1052e87cf1a3ac
https://github.com/scummvm/scummvm/commit/72518221d8ce1532d13b7349cb1052e87cf1a3ac
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Scale mouse movements
The delta values are in number of pixels on the native screen
resolution. Need to scale down the delta values based on the
game resolution. Store reminders that are added to next deltas
to mitigate "dead zones" if doing small movements.
Changed paths:
backends/platform/ios7/ios7_mouse_controller.mm
backends/platform/ios7/ios7_video.h
backends/platform/ios7/ios7_video.mm
diff --git a/backends/platform/ios7/ios7_mouse_controller.mm b/backends/platform/ios7/ios7_mouse_controller.mm
index b7a8d3fc99b..e59f0cb98d2 100644
--- a/backends/platform/ios7/ios7_mouse_controller.mm
+++ b/backends/platform/ios7/ios7_mouse_controller.mm
@@ -29,6 +29,7 @@
@implementation MouseController {
#ifdef __IPHONE_14_0
GCMouse *_mouse;
+ CGFloat _dxReminder, _dyReminder;
#endif
}
@@ -45,6 +46,9 @@
object:nil];
}
+ _dxReminder = 0.0;
+ _dyReminder = 0.0;
+
return self;
}
@@ -54,7 +58,18 @@
_mouse = (GCMouse*)notification.object;
_mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
- [[self view] addEvent:InternalEvent(kInputMouseDelta, (int)-deltaX, (int)deltaY)];
+ CGFloat scaleX, scaleY;
+ [[self view] getMouseScaleFactorX:&scaleX andY:&scaleY];
+ CGFloat scaledDeltaX = deltaX * scaleX + _dxReminder;
+ CGFloat scaledDeltaY = deltaY * scaleY + _dyReminder;
+ // Add any reminding delta values to be summed up and get the integer part of the delta
+ int dx = (int)(scaledDeltaX);
+ int dy = (int)(scaledDeltaY);
+ // Save the new reminders
+ _dxReminder = scaledDeltaX - (CGFloat)dx;
+ _dyReminder = scaledDeltaY - (CGFloat)dy;
+
+ [[self view] addEvent:InternalEvent(kInputMouseDelta, -dx, dy)];
};
_mouse.mouseInput.leftButton.valueChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h
index 55e8e100eb6..f790110a0cd 100644
--- a/backends/platform/ios7/ios7_video.h
+++ b/backends/platform/ios7/ios7_video.h
@@ -139,6 +139,7 @@ uint getSizeNextPOT(uint size);
- (void)addEvent:(InternalEvent)event;
- (bool)fetchEvent:(InternalEvent *)event;
+- (void)getMouseScaleFactorX:(CGFloat *)x andY:(CGFloat *)y;
- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y;
- (BOOL)isTouchControllerConnected;
- (BOOL)isMouseControllerConnected;
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 71e97f2248f..6d12886efd5 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -866,6 +866,17 @@ uint getSizeNextPOT(uint size) {
return true;
}
+- (void)getMouseScaleFactorX:(CGFloat *)x andY:(CGFloat *)y {
+ if (_videoContext.overlayInGUI) {
+ // No scaling in overlay
+ *x = (CGFloat)_videoContext.overlayWidth / self.bounds.size.width;
+ *y = (CGFloat)_videoContext.overlayHeight / self.bounds.size.height;
+ } else {
+ *x = (CGFloat)_videoContext.screenWidth / self.bounds.size.width;
+ *y = (CGFloat)_videoContext.screenHeight / self.bounds.size.height;
+ }
+}
+
- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y {
// We scale the input according to our scale factor to get actual screen
// coordinates.
Commit: d397938107560a5eb982e5d526c8c85e2f2b3df8
https://github.com/scummvm/scummvm/commit/d397938107560a5eb982e5d526c8c85e2f2b3df8
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Implement support for setting mouse pointer speed
Implement support to set the mouse pointer speed in settings.
The mouse pointer speed is applied to both mouse input and touch
input when in touchpad-mode.
Changed paths:
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_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index be625dcaf36..ff5fcbbe20e 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -295,8 +295,8 @@ bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, in
_lastPadX = x;
_lastPadY = y;
- mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f);
- mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f);
+ mouseNewPosX = (int)(_videoContext->mouseX - (int)((float)deltaX * getMouseSpeed()));
+ mouseNewPosY = (int)(_videoContext->mouseY - (int)((float)deltaY * getMouseSpeed()));
int widthCap = _videoContext->overlayInGUI ? _videoContext->overlayWidth : _videoContext->screenWidth;
int heightCap = _videoContext->overlayInGUI ? _videoContext->overlayHeight : _videoContext->screenHeight;
@@ -353,8 +353,8 @@ void OSystem_iOS7::handleEvent_mouseRightButtonUp(Common::Event &event, int x, i
}
void OSystem_iOS7::handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY) {
- int mouseNewPosX = (int)(_videoContext->mouseX - deltaX);
- int mouseNewPosY = (int)(_videoContext->mouseY - deltaY);
+ int mouseNewPosX = (int)(_videoContext->mouseX - (int)((float)deltaX * getMouseSpeed()));
+ int mouseNewPosY = (int)(_videoContext->mouseY - (int)((float)deltaY * getMouseSpeed()));
int widthCap = _videoContext->overlayInGUI ? _videoContext->overlayWidth : _videoContext->screenWidth;
int heightCap = _videoContext->overlayInGUI ? _videoContext->overlayHeight : _videoContext->screenHeight;
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 5378f81ed31..a3d397989e2 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -162,6 +162,7 @@ bool OSystem_iOS7::hasFeature(Feature f) {
#endif
case kFeatureOpenUrl:
case kFeatureNoQuit:
+ case kFeatureKbdMouseSpeed:
return true;
default:
@@ -301,6 +302,29 @@ void OSystem_iOS7::delayMillis(uint msecs) {
usleep(msecs * 1000);
}
+float OSystem_iOS7::getMouseSpeed() {
+ switch (ConfMan.getInt("kbdmouse_speed")) {
+ case 0:
+ return 0.25;
+ case 1:
+ return 0.5;
+ case 2:
+ return 0.75;
+ case 3:
+ return 1.0;
+ case 4:
+ return 1.25;
+ case 5:
+ return 1.5;
+ case 6:
+ return 1.75;
+ case 7:
+ return 2.0;
+ default:
+ return 1.0;
+ }
+}
+
void OSystem_iOS7::setTimerCallback(TimerProc callback, int interval) {
//printf("setTimerCallback()\n");
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 65705488489..affd73a123b 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -259,6 +259,7 @@ protected:
void handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY);
void rebuildSurface();
+ float getMouseSpeed();
};
#endif
Commit: 01b9f728de961779f4e0b26233e41eabe45fd065
https://github.com/scummvm/scummvm/commit/01b9f728de961779f4e0b26233e41eabe45fd065
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Implement relative mouse movements for touches
Send relative mouse movements from backend for touch events. The
relative x and y values are necessary for some games, e.g. Myst3.
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 ff5fcbbe20e..691305efa35 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -177,11 +177,12 @@ bool OSystem_iOS7::handleEvent_touchFirstDown(Common::Event &event, int x, int y
// secondary finger is lifted. Need to make sure we get out of that mode.
_secondaryTapped = false;
- if (_touchpadModeEnabled) {
- _lastPadX = x;
- _lastPadY = y;
- } else
+ _lastPadX = x;
+ _lastPadY = y;
+
+ if (!_touchpadModeEnabled) {
warpMouse(x, y);
+ }
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONDOWN;
@@ -289,12 +290,12 @@ bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, in
//printf("Mouse dragged at (%u, %u)\n", x, y);
int mouseNewPosX;
int mouseNewPosY;
- if (_touchpadModeEnabled) {
- int deltaX = _lastPadX - x;
- int deltaY = _lastPadY - y;
- _lastPadX = x;
- _lastPadY = y;
+ int deltaX = _lastPadX - x;
+ int deltaY = _lastPadY - y;
+ _lastPadX = x;
+ _lastPadY = y;
+ if (_touchpadModeEnabled) {
mouseNewPosX = (int)(_videoContext->mouseX - (int)((float)deltaX * getMouseSpeed()));
mouseNewPosY = (int)(_videoContext->mouseY - (int)((float)deltaY * getMouseSpeed()));
@@ -317,6 +318,8 @@ bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, in
}
event.type = Common::EVENT_MOUSEMOVE;
+ event.relMouse.x = deltaX;
+ event.relMouse.y = deltaY;
event.mouse.x = mouseNewPosX;
event.mouse.y = mouseNewPosY;
warpMouse(mouseNewPosX, mouseNewPosY);
Commit: 8e97e8dff40f0cb517c62f6ab08a6dff23978edc
https://github.com/scummvm/scummvm/commit/8e97e8dff40f0cb517c62f6ab08a6dff23978edc
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-05-15T12:43:39+02:00
Commit Message:
IOS7: Refactor touchpad mode to utilize delta mouse function
Instead of having duplicated code, utilize the delta mouse function
also for touches when in touchpad mode.
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 691305efa35..79ee8bf5733 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -288,42 +288,22 @@ bool OSystem_iOS7::handleEvent_touchFirstDragged(Common::Event &event, int x, in
_lastDragPosY = y;
//printf("Mouse dragged at (%u, %u)\n", x, y);
- int mouseNewPosX;
- int mouseNewPosY;
int deltaX = _lastPadX - x;
int deltaY = _lastPadY - y;
_lastPadX = x;
_lastPadY = y;
if (_touchpadModeEnabled) {
- mouseNewPosX = (int)(_videoContext->mouseX - (int)((float)deltaX * getMouseSpeed()));
- mouseNewPosY = (int)(_videoContext->mouseY - (int)((float)deltaY * getMouseSpeed()));
-
- int widthCap = _videoContext->overlayInGUI ? _videoContext->overlayWidth : _videoContext->screenWidth;
- int heightCap = _videoContext->overlayInGUI ? _videoContext->overlayHeight : _videoContext->screenHeight;
-
- if (mouseNewPosX < 0)
- mouseNewPosX = 0;
- else if (mouseNewPosX > widthCap)
- mouseNewPosX = widthCap;
-
- if (mouseNewPosY < 0)
- mouseNewPosY = 0;
- else if (mouseNewPosY > heightCap)
- mouseNewPosY = heightCap;
-
+ handleEvent_mouseDelta(event, deltaX, deltaY);
} else {
- mouseNewPosX = x;
- mouseNewPosY = y;
- }
-
- event.type = Common::EVENT_MOUSEMOVE;
- event.relMouse.x = deltaX;
- event.relMouse.y = deltaY;
- event.mouse.x = mouseNewPosX;
- event.mouse.y = mouseNewPosY;
- warpMouse(mouseNewPosX, mouseNewPosY);
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.relMouse.x = deltaX;
+ event.relMouse.y = deltaY;
+ event.mouse.x = x;
+ event.mouse.y = y;
+ warpMouse(x, y);
+ }
return true;
}
More information about the Scummvm-git-logs
mailing list