[Scummvm-git-logs] scummvm master -> 64797234e679f647b9eb1e3b4b8a8c122db15622

antoniou79 noreply at scummvm.org
Sun Apr 2 18:56:22 UTC 2023


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:
64797234e6 ANDROID: Add Control tab for mouse pointer speed


Commit: 64797234e679f647b9eb1e3b4b8a8c122db15622
    https://github.com/scummvm/scummvm/commit/64797234e679f647b9eb1e3b4b8a8c122db15622
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-04-02T21:55:56+03:00

Commit Message:
ANDROID: Add Control tab for mouse pointer speed

and joystick deadzone. By supporting kFeatureKbdMouseSpeed and kFeatureJoystickDeadzone and registering default values

Both of these config settings (kbdmouse_speed, joystick_deadzone) factor in virtual mouse movement.

Helps handle virtual mouse pointer speed when controlled with DPAD or is too fast for the user

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/events.cpp
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java


diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 850da09f8c4..abfa957af7f 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -470,6 +470,10 @@ void OSystem_Android::initBackend() {
 	ConfMan.registerDefault("aspect_ratio", true);
 	ConfMan.registerDefault("filtering", false);
 	ConfMan.registerDefault("autosave_period", 0);
+	// slow down a bit virtual mouse speed (typical default seems to be "3") - eg. when controlling the virtual mouse cursor with DPAD keys
+	// Also see declaration of support for feature kFeatureKbdMouseSpeed bellow
+	ConfMan.registerDefault("kbdmouse_speed", 2);
+	ConfMan.registerDefault("joystick_deadzone", 3);
 
 	// explicitly set this, since fullscreen cannot be changed from GUI
 	// and for Android it should be persisted (and ConfMan.hasKey("fullscreen") check should return true for it)
@@ -623,7 +627,9 @@ bool OSystem_Android::hasFeature(Feature f) {
 		return false;
 	if (f == kFeatureVirtualKeyboard ||
 			f == kFeatureOpenUrl ||
-			f == kFeatureClipboardSupport) {
+			f == kFeatureClipboardSupport ||
+			f == kFeatureKbdMouseSpeed ||
+			f == kFeatureJoystickDeadzone) {
 		return true;
 	}
 	/* Even if we are using the 2D graphics manager,
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index d53cf3194ac..414b3ee2180 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -1154,6 +1154,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 		return;
 
 	case JE_MOUSE_WHEEL_UP:
+		// Rolling wheel upwards
 		e.type = Common::EVENT_WHEELUP;
 		e.mouse.x = arg1;
 		e.mouse.y = arg2;
@@ -1164,6 +1165,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 		return;
 
 	case JE_MOUSE_WHEEL_DOWN:
+		// Rolling wheel downwards
 		e.type = Common::EVENT_WHEELDOWN;
 		e.mouse.x = arg1;
 		e.mouse.y = arg2;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
index 969e71238f3..a340fe7fa5a 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
@@ -68,31 +68,36 @@ public class ScummVMEventsModern extends ScummVMEventsBase {
 	private float repeatingX = 0.0f;
 	private float repeatingY = 0.0f;
 
-	private static float getCenteredAxis(MotionEvent event, InputDevice device, int axis, int historyPos) {
-		final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
+	private static float getCenteredAxis(MotionEvent event, InputDevice device, int axisId, int historyPos) {
+		final InputDevice.MotionRange range = device.getMotionRange(axisId, event.getSource());
 		final int actionPointerIndex = event.getActionIndex();
 
 		// A joystick at rest does not always report an absolute position of
 		// (0,0). Use the getFlat() method to determine the range of values
 		// bounding the joystick axis center.
 		if (range != null) {
-			final float flat = range.getFlat();
-
-//			if (axis == MotionEvent.AXIS_X
-//				|| axis == MotionEvent.AXIS_HAT_X
-//				|| axis == MotionEvent.AXIS_Z) {
-//				Log.d(ScummVM.LOG_TAG, "Flat X= " + flat);
+			final float axisFlat = range.getFlat();
+			final float axisMin = range.getMin();
+//			final float axisMax = range.getMax();
+			final float axisRange = range.getRange();
+//			final float axisRes = range.getResolution();
+//			final float axisFuzz = range.getFuzz();
+
+//			if (axisId == MotionEvent.AXIS_X
+//				|| axisId == MotionEvent.AXIS_HAT_X
+//				|| axisId == MotionEvent.AXIS_Z) {
+//				Log.d(ScummVM.LOG_TAG, "Flat X= " + axisFlat);
 //			} else {
-//				Log.d(ScummVM.LOG_TAG, "Flat Y= " + flat);
+//				Log.d(ScummVM.LOG_TAG, "Flat Y= " + axisFlat);
 //			}
 
-			float axisVal = (historyPos < 0) ? event.getAxisValue( range.getAxis(), actionPointerIndex) : event.getHistoricalAxisValue( range.getAxis(), actionPointerIndex, historyPos);
+			float axisVal = (historyPos < 0) ? event.getAxisValue( axisId, actionPointerIndex) : event.getHistoricalAxisValue( axisId, actionPointerIndex, historyPos);
 			// Normalize
-			final float value =  (axisVal - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
+			final float value =  (axisVal - axisMin ) / axisRange * 2.0f - 1.0f;
 
 			// Ignore axis values that are within the 'flat' region of the
 			// joystick axis center.
-			if (Math.abs(value) > flat) {
+			if (Math.abs(value) > axisFlat) {
 				return value;
 			}
 		}
@@ -205,11 +210,14 @@ public class ScummVMEventsModern extends ScummVMEventsBase {
 				break;
 			}
 		} else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
-			// TODO Check if we need to handle other cases of InputDevice SOURCE_CLASS_POINTER for GenericMotionEvent, that are not ACTION_SCROLL
 			//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - onGenericMotionEvent(m) ");
 			//
-			// Check that the event might be a mouse scroll wheel
+			// Check that the event might be a mouse scroll wheel (ACTION_SCROLL)
 			// Code inspired from https://stackoverflow.com/a/33086042
+			//
+			// NOTE Other GenericMotionEvent are also triggered for InputDevice of SOURCE_CLASS_POINTER (eg. physical mouse).
+			// These seem to be for button down/up events, which are handled along with pushing a JE_MOVE event
+			// in MouseHelper's onMouseEvent() called from ScummVMEventsBase onTouch().
 			switch (event.getActionMasked()) {
 			case MotionEvent.ACTION_SCROLL:
 				//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - ACTION SCROLL");




More information about the Scummvm-git-logs mailing list