# SDL: Fixed bug #5322 - register virtual input devices as SDL\_Touch device because

**URL:** <https://discourse.libsdl.org/t/sdl-fixed-bug-5322-register-virtual-input-devices-as-sdl-touch-device-because/34801>\
**Category:** SDL Commits\
**Created:** [February 9, 2022, 8:40am UTC](https://discourse.libsdl.org/t/sdl-fixed-bug-5322-register-virtual-input-devices-as-sdl-touch-device-because/34801 "2022-02-09T08:40:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [February 9, 2022, 8:40am UTC](https://discourse.libsdl.org/t/sdl-fixed-bug-5322-register-virtual-input-devices-as-sdl-touch-device-because/34801/1 "2022-02-09T08:40:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/3a9bbf604e0d54ad36e5f7c1762f4bb52e911f5a>
>
> they can send SOURCE\_TOUCHSCREEN events even if getSources() doesn't declare the…m.

```diff
From 3a9bbf604e0d54ad36e5f7c1762f4bb52e911f5a Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Wed, 9 Feb 2022 09:37:36 +0100
Subject: [PATCH] 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.

---
 .../app/src/main/java/org/libsdl/app/SDLActivity.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 48006900328..3ee892b9063 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 static void initTouch() {
 
         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

```
