From 9a80383a8ff99f7e633e4011e03236bbef60503c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 16 May 2004 22:48:06 +0000 Subject: [PATCH] Date: Tue, 16 Mar 2004 12:40:33 +0000 From: Alan Swanson Subject: [SDL] [PATCH] Linux joystick evdev axis count fix The event device configuration under Linux does not check the returned ioctl value when reading the axis information. This means extra undefined axes are returned. Note, in EV_HandleEvents, the default for case EV_ABS is to return any axis information which is fine as we have already checked for all valid absolute axes. No new axes should be returned after opening the device. (Unless, of course, the evdev allows closing and reassigning a new device while in use and I can't believe that happens.) --- src/joystick/linux/SDL_sysjoystick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 1b95cb27f..aa8700439 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -594,7 +594,8 @@ static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd) if ( test_bit(i, absbit) ) { int values[5]; - ioctl(fd, EVIOCGABS(i), values); + if ( ioctl(fd, EVIOCGABS(i), values) < 0 ) + continue; #ifdef DEBUG_INPUT_EVENTS printf("Joystick has absolute axis: %x\n", i); printf("Values = { %d, %d, %d, %d, %d }\n",