Fixes Bug 1944 - Linux events, joysticks having only hat are not read
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 06 Nov 2013 09:48:45 -0300
changeset 79094434ab25abf3
parent 7908 b339af982b62
child 7910 261addaa47d0
Fixes Bug 1944 - Linux events, joysticks having only hat are not read
src/joystick/linux/SDL_sysjoystick.c
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Tue Nov 05 21:01:25 2013 -0800
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Wed Nov 06 09:48:45 2013 -0300
     1.3 @@ -85,11 +85,14 @@
     1.4  static int
     1.5  IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *guid)
     1.6  {
     1.7 +    struct input_id inpid;
     1.8 +    Uint16 *guid16 = (Uint16 *) ((char *) &guid->data);
     1.9 +
    1.10 +#if !SDL_USE_LIBUDEV
    1.11 +    /* When udev is enabled we only get joystick devices here, so there's no need to test them */
    1.12      unsigned long evbit[NBITS(EV_MAX)] = { 0 };
    1.13      unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
    1.14      unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
    1.15 -    struct input_id inpid;
    1.16 -    Uint16 *guid16 = (Uint16 *) ((char *) &guid->data);
    1.17  
    1.18      if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
    1.19          (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
    1.20 @@ -101,6 +104,7 @@
    1.21            test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) {
    1.22          return 0;
    1.23      }
    1.24 +#endif
    1.25  
    1.26      if (ioctl(fd, EVIOCGNAME(namebuflen), namebuf) < 0) {
    1.27          return 0;