Fixed an issue with mouse/keyboard removal
authorSam Lantinga <slouken@libsdl.org>
Wed, 24 Jun 2015 17:54:39 -0700
changeset 977949b5a975a238
parent 9778 e7de5f41bb79
child 9780 7f9b74280df6
Fixed an issue with mouse/keyboard removal

Sometimes, on removal SDL_EVDEV_udev_callback() gets called with zero udev_class. This in turn seems to be caused the SDL_udev.c:guess_device_class() failing to find the attributes of the parent device.

Apparently this is normal, attributes are not guaranteed to be in place during removal, depending on timing. This lack of attributes causes guess_device_class() to return zero.

This fix mimics the code in linux/SDL_sysjoystick.c:joystick_udev_callback() which effectively has the same fix already in place.
src/core/linux/SDL_evdev.c
     1.1 --- a/src/core/linux/SDL_evdev.c	Wed Jun 24 10:56:51 2015 -0700
     1.2 +++ b/src/core/linux/SDL_evdev.c	Wed Jun 24 17:54:39 2015 -0700
     1.3 @@ -547,12 +547,11 @@
     1.4          return;
     1.5      }
     1.6      
     1.7 -    if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE|SDL_UDEV_DEVICE_KEYBOARD))) {
     1.8 -        return;
     1.9 -    }
    1.10 -
    1.11 -    switch( udev_type ) {
    1.12 +    switch(udev_type) {
    1.13      case SDL_UDEV_DEVICEADDED:
    1.14 +        if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE|SDL_UDEV_DEVICE_KEYBOARD))) {
    1.15 +            return;
    1.16 +        }
    1.17          SDL_EVDEV_device_added(devpath);
    1.18          break;
    1.19