SDL: evdev INPUT_PROP_SEMI_MT devices should be early-detected as touchpads

From 19445339b8915728210659434684725fdf6faacc Mon Sep 17 00:00:00 2001
From: Vicki Pfau <[EMAIL REDACTED]>
Date: Tue, 9 Apr 2024 18:43:01 -0700
Subject: [PATCH] evdev INPUT_PROP_SEMI_MT devices should be early-detected as
 touchpads

Some psmouse touchpads were being misdetected as joysticks due to only having
INPUT_PROP_SEMI_MT and INPUT_PROP_POINTER as well as having BTN_1
---
 src/core/linux/SDL_evdev_capabilities.c | 3 ++-
 src/core/linux/SDL_evdev_capabilities.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/core/linux/SDL_evdev_capabilities.c b/src/core/linux/SDL_evdev_capabilities.c
index 865abf4feb978..6c146ab10c0c7 100644
--- a/src/core/linux/SDL_evdev_capabilities.c
+++ b/src/core/linux/SDL_evdev_capabilities.c
@@ -70,7 +70,8 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
 
     /* We treat buttonpads as equivalent to touchpads */
     if (test_bit(INPUT_PROP_TOPBUTTONPAD, bitmask_props) ||
-        test_bit(INPUT_PROP_BUTTONPAD, bitmask_props)) {
+        test_bit(INPUT_PROP_BUTTONPAD, bitmask_props) ||
+        test_bit(INPUT_PROP_SEMI_MT, bitmask_props)) {
         return SDL_UDEV_DEVICE_TOUCHPAD;
     }
 
diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h
index 49df8da79dec0..ae09b68c31fe8 100644
--- a/src/core/linux/SDL_evdev_capabilities.h
+++ b/src/core/linux/SDL_evdev_capabilities.h
@@ -28,6 +28,9 @@
 
 #include <linux/input.h>
 
+#ifndef INPUT_PROP_SEMI_MT
+#define INPUT_PROP_SEMI_MT          0x03
+#endif
 #ifndef INPUT_PROP_TOPBUTTONPAD
 #define INPUT_PROP_TOPBUTTONPAD     0x04
 #endif