Commit 373216ae5be62b710ad68524777ae38ca712c53d

Sam Lantinga 2021-10-07T18:14:16

Added support for touchpads in the Linux evdev code (thanks Francisco!)

diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 3635920..9d7c39a 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -218,8 +218,11 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
 
     switch(udev_event) {
     case SDL_UDEV_DEVICEADDED:
-        if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD |
-            SDL_UDEV_DEVICE_TOUCHSCREEN)))
+        if (udev_class & SDL_UDEV_DEVICE_TOUCHPAD) {
+            udev_class |= SDL_UDEV_DEVICE_TOUCHSCREEN;
+        }
+
+        if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN)))
             return;
 
         if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK))
diff --git a/src/core/linux/SDL_evdev_capabilities.c b/src/core/linux/SDL_evdev_capabilities.c
index 1373f0e..72bdba1 100644
--- a/src/core/linux/SDL_evdev_capabilities.c
+++ b/src/core/linux/SDL_evdev_capabilities.c
@@ -78,7 +78,7 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
         if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
             ; /* ID_INPUT_TABLET */
         } else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
-            ; /* ID_INPUT_TOUCHPAD */
+            devclass |= SDL_UDEV_DEVICE_TOUCHPAD; /* ID_INPUT_TOUCHPAD */
         } else if (test_bit(BTN_MOUSE, bitmask_key)) {
             devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
         } else if (test_bit(BTN_TOUCH, bitmask_key)) {
diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h
index 6822425..6167ebb 100644
--- a/src/core/linux/SDL_evdev_capabilities.h
+++ b/src/core/linux/SDL_evdev_capabilities.h
@@ -38,7 +38,8 @@ typedef enum
     SDL_UDEV_DEVICE_JOYSTICK    = 0x0004,
     SDL_UDEV_DEVICE_SOUND       = 0x0008,
     SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010,
-    SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020
+    SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020,
+    SDL_UDEV_DEVICE_TOUCHPAD    = 0x0040
 } SDL_UDEV_deviceclass;
 
 #define BITS_PER_LONG           (sizeof(unsigned long) * 8)