Commit 3a9bbf604e0d54ad36e5f7c1762f4bb52e911f5a

Sylvain 2022-02-09T09:37:36

Fixed bug #5322 - register virtual input devices as SDL_Touch device because they can send SOURCE_TOUCHSCREEN events even if getSources() doesn't declare them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 4800690..3ee892b 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -1304,7 +1304,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
 
         for (int id : ids) {
             InputDevice device = InputDevice.getDevice(id);
-            if (device != null && (device.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
+            /* Allow SOURCE_TOUCHSCREEN and also Virtual InputDevices because they can send TOUCHSCREEN events */
+            if (device != null && ((device.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN
+                    || device.isVirtual()) {
+
                 int touchDevId = device.getId();
                 /*
                  * Prevent id to be -1, since it's used in SDL internal for synthetic events