diff options
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/joystick_linux.cpp | 8 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index 5007976f0d..1a11876d5d 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -38,8 +38,9 @@ #include <fcntl.h> #include <errno.h> -#define test_bit(nr, addr) (((1UL << ((nr) % (sizeof(long) * 8))) & ((addr)[(nr) / (sizeof(long) * 8)])) != 0) -#define NBITS(x) ((((x)-1)/(sizeof(long) * 8))+1) +#define LONG_BITS (sizeof(long) * 8) +#define test_bit(nr, addr) (((1UL << ((nr) % LONG_BITS)) & ((addr)[(nr) / LONG_BITS])) != 0) +#define NBITS(x) ((((x)-1)/LONG_BITS)+1) static const char* ignore_str = "/dev/input/js"; @@ -304,13 +305,14 @@ void joystick_linux::open_joystick(const char *p_path) { if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) || (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) || (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) { + close(fd); return; } //check if the device supports basic gamepad events, prevents certain keyboards from //being detected as joysticks if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && - ((test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit)) || + ((test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit)) && (test_bit(BTN_A, keybit) || test_bit(BTN_THUMBL, keybit))))) { close(fd); return; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 89c674d537..34abfc1078 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -65,7 +65,6 @@ #include <X11/Xatom.h> -//#include "os/pc_joystick_map.h" #undef CursorShape |