Skip to content

Commit

Permalink
linux/SDL_sysjoystick.c: Fix bug #3193:
Browse files Browse the repository at this point in the history
Protect against any axis that isn't reported by EVIOCGBIT but still
sends EV_ABS events; patch from <maxxus@gmail.com>.  Original issue
and description:

The Dualshock 3's motion sensors don't seem to be reported by the call
to EVIOCGBIT but they still send EV_ABS events.  Because they're not
reported by EVIOCGBIT they're not assigned a proper axis ids and the
default of 0 is used, which is the valid id for the left analog sticks
left/right axis. The attached patch sets the default axis id to ABS_MAX
and then checks the axis id before performing the update.  This will
protect against EV_ABS events for axes that aren't reported or handled
correctly.
  • Loading branch information
sezero committed Aug 7, 2018
1 parent f10b27c commit 1b548a8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -826,6 +826,9 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
return(-1);
}
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
#if SDL_INPUT_LINUXEV
SDL_memset(joystick->hwdata->abs_map, ABS_MAX, sizeof(*joystick->hwdata->abs_map)*ABS_MAX);
#endif
joystick->hwdata->fd = fd;

/* Set the joystick to non-blocking read mode */
Expand Down Expand Up @@ -1123,15 +1126,17 @@ static __inline__ void EV_HandleEvents(SDL_Joystick *joystick)
events[i].value);
break;
default:
events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
if (joystick->hwdata->abs_map[code] != ABS_MAX ) {
events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
#ifndef NO_LOGICAL_JOYSTICKS
if (!LogicalJoystickAxis(joystick,
if (!LogicalJoystickAxis(joystick,
joystick->hwdata->abs_map[code],
events[i].value))
#endif
SDL_PrivateJoystickAxis(joystick,
SDL_PrivateJoystickAxis(joystick,
joystick->hwdata->abs_map[code],
events[i].value);
}
break;
}
break;
Expand Down

0 comments on commit 1b548a8

Please sign in to comment.