[Scummvm-git-logs] scummvm master -> 6931714c2f2472bd046373d158f2ecf29a0ac2e7

lephilousophe noreply at scummvm.org
Sun Oct 23 17:33:25 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:
6931714c2f ANDROID: Fix touchscreen stylus check


Commit: 6931714c2f2472bd046373d158f2ecf29a0ac2e7
    https://github.com/scummvm/scummvm/commit/6931714c2f2472bd046373d158f2ecf29a0ac2e7
Author: jacobhyman (jacobhyman at gmail.com)
Date: 2022-10-23T19:33:21+02:00

Commit Message:
ANDROID: Fix touchscreen stylus check

Changed paths:
    backends/platform/android/org/scummvm/scummvm/MouseHelper.java


diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
index f808d393584..5647cac8a5e 100644
--- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
+++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
@@ -99,6 +99,23 @@ public class MouseHelper implements View.OnHoverListener {
 
 	}
 
+	// "Checking against SOURCE_STYLUS only indicates "an input device is capable of obtaining input
+	// from a stylus. To determine whether a given touch event was produced by a stylus, examine
+	// the tool type returned by MotionEvent#getToolType(int) for each individual pointer."
+	// https://developer.android.com/reference/android/view/InputDevice#SOURCE_STYLUS
+	public static boolean isStylus(MotionEvent e){
+		if (e == null) {
+			return false;
+		}
+
+		for(int idx = 0; idx < e.getPointerCount(); idx++) {
+			if (e.getToolType(idx) == MotionEvent.TOOL_TYPE_STYLUS)
+				return true;
+		}
+
+		return false;
+	}
+
 	public static boolean isMouse(KeyEvent e) {
 		if (e == null) {
 			return false;
@@ -131,9 +148,10 @@ public class MouseHelper implements View.OnHoverListener {
 
 		// SOURCE_MOUSE_RELATIVE is sent when mouse is detected as trackball
 		// TODO: why does this happen? Do we need to also check for SOURCE_TRACKBALL here?
+		// TODO: should these all be checks against TOOL_TYPEs instead of SOURCEs?
 		return ((sources & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE)
-		       || ((sources & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS)
 		       || ((sources & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD)
+		       ||  isStylus(e)
 		       ||  isTrackball(e);
 	}
 




More information about the Scummvm-git-logs mailing list