[udev] Fixes #2654, ID_INPUT_KEY devices are ignored.
authorGabriel Jacobo <gabomdq@gmail.com>
Thu, 16 Oct 2014 09:41:42 -0300
changeset 9168 b8e85a5ac99a
parent 9167 3d2c0f659ad3
child 9169 70e5da67cf9d
[udev] Fixes #2654, ID_INPUT_KEY devices are ignored. Also added some references to udev code where these flags are set.
src/core/linux/SDL_udev.c
--- a/src/core/linux/SDL_udev.c	Wed Oct 15 18:33:43 2014 -0300
+++ b/src/core/linux/SDL_udev.c	Thu Oct 16 09:41:42 2014 -0300
@@ -398,6 +398,8 @@
     if (SDL_strcmp(subsystem, "sound") == 0) {
         devclass = SDL_UDEV_DEVICE_SOUND;
     } else if (SDL_strcmp(subsystem, "input") == 0) {
+        /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
+        
         val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
             devclass |= SDL_UDEV_DEVICE_JOYSTICK;
@@ -408,7 +410,13 @@
             devclass |= SDL_UDEV_DEVICE_MOUSE;
         }
 
-        val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
+        /* The undocumented rule is:
+           - All devices with keys get ID_INPUT_KEY
+           - From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD
+           
+           Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
+        */
+        val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEY");
         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
             devclass |= SDL_UDEV_DEVICE_KEYBOARD;
         }