src/core/linux/SDL_udev.c
changeset 9168 b8e85a5ac99a
parent 9160 25a97df364fb
equal deleted inserted replaced
9167:3d2c0f659ad3 9168:b8e85a5ac99a
   396     
   396     
   397     subsystem = _this->udev_device_get_subsystem(dev);
   397     subsystem = _this->udev_device_get_subsystem(dev);
   398     if (SDL_strcmp(subsystem, "sound") == 0) {
   398     if (SDL_strcmp(subsystem, "sound") == 0) {
   399         devclass = SDL_UDEV_DEVICE_SOUND;
   399         devclass = SDL_UDEV_DEVICE_SOUND;
   400     } else if (SDL_strcmp(subsystem, "input") == 0) {
   400     } else if (SDL_strcmp(subsystem, "input") == 0) {
       
   401         /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
       
   402         
   401         val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
   403         val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
   402         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   404         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   403             devclass |= SDL_UDEV_DEVICE_JOYSTICK;
   405             devclass |= SDL_UDEV_DEVICE_JOYSTICK;
   404         }
   406         }
   405         
   407         
   406         val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
   408         val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
   407         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   409         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   408             devclass |= SDL_UDEV_DEVICE_MOUSE;
   410             devclass |= SDL_UDEV_DEVICE_MOUSE;
   409         }
   411         }
   410 
   412 
   411         val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
   413         /* The undocumented rule is:
       
   414            - All devices with keys get ID_INPUT_KEY
       
   415            - From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD
       
   416            
       
   417            Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
       
   418         */
       
   419         val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEY");
   412         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   420         if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
   413             devclass |= SDL_UDEV_DEVICE_KEYBOARD;
   421             devclass |= SDL_UDEV_DEVICE_KEYBOARD;
   414         }
   422         }
   415 
   423 
   416         if (devclass == 0) {
   424         if (devclass == 0) {