mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03:59 +02:00
add a guard in case SDL somehow forgets about axes
This commit is contained in:
parent
da531ac25e
commit
9289249df5
1 changed files with 6 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue