add a guard in case SDL somehow forgets about axes

This commit is contained in:
Stephen Birarda 2014-10-24 15:06:18 -07:00
parent da531ac25e
commit 9289249df5

View file

@ -45,10 +45,12 @@ void Joystick::closeJoystick() {
#ifdef HAVE_SDL2
void Joystick::handleAxisEvent(const SDL_ControllerAxisEvent& event) {
float oldValue = _axes[event.axis];
float newValue = event.value / MAX_AXIS;
_axes[event.axis] = newValue;
emit axisValueChanged(event.axis, newValue, oldValue);
if (event.axis < _axes.size() - 1) {
float oldValue = _axes[event.axis];
float newValue = event.value / MAX_AXIS;
_axes[event.axis] = newValue;
emit axisValueChanged(event.axis, newValue, oldValue);
}
}
void Joystick::handleButtonEvent(const SDL_ControllerButtonEvent& event) {