diff --git a/src/core/linux/SDL_evdev_capabilities.c b/src/core/linux/SDL_evdev_capabilities.c index d96b9edb6..82b11188f 100644 --- a/src/core/linux/SDL_evdev_capabilities.c +++ b/src/core/linux/SDL_evdev_capabilities.c @@ -22,7 +22,7 @@ #include "SDL_evdev_capabilities.h" -#if HAVE_LIBUDEV_H +#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], diff --git a/src/core/linux/SDL_evdev_capabilities.h b/src/core/linux/SDL_evdev_capabilities.h index cef151331..10bceb5a2 100644 --- a/src/core/linux/SDL_evdev_capabilities.h +++ b/src/core/linux/SDL_evdev_capabilities.h @@ -25,7 +25,7 @@ #ifndef SDL_evdev_capabilities_h_ #define SDL_evdev_capabilities_h_ -#if HAVE_LIBUDEV_H +#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) #include @@ -51,7 +51,7 @@ extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], unsigned long bitmask_key[NBITS(KEY_MAX)], unsigned long bitmask_rel[NBITS(REL_MAX)]); -#endif /* HAVE_LIBUDEV_H */ +#endif /* HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) */ #endif /* SDL_evdev_capabilities_h_ */ diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index a94bfe39f..fc145e9ca 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -160,19 +160,23 @@ GuessIsJoystick(int fd) unsigned long evbit[NBITS(EV_MAX)] = { 0 }; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; unsigned long absbit[NBITS(ABS_MAX)] = { 0 }; + unsigned long relbit[NBITS(REL_MAX)] = { 0 }; + int devclass; if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) || (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) || + (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) < 0) || (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) { return (0); } - if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && - test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) { - return 0; + devclass = SDL_EVDEV_GuessDeviceClass(evbit, absbit, keybit, relbit); + + if (devclass & SDL_UDEV_DEVICE_JOYSTICK) { + return 1; } - return 1; + return 0; } static int