mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Merge pull request #3660 from birarda/xbox-controller
add a guard in case SDL misreports number of axes
This commit is contained in:
commit
33204b0d27
1 changed files with 5 additions and 0 deletions
|
@ -45,9 +45,14 @@ void Joystick::closeJoystick() {
|
|||
|
||||
#ifdef HAVE_SDL2
|
||||
void Joystick::handleAxisEvent(const SDL_ControllerAxisEvent& event) {
|
||||
if (_axes.size() <= event.axis) {
|
||||
_axes.resize(event.axis + 1);
|
||||
}
|
||||
|
||||
float oldValue = _axes[event.axis];
|
||||
float newValue = event.value / MAX_AXIS;
|
||||
_axes[event.axis] = newValue;
|
||||
|
||||
emit axisValueChanged(event.axis, newValue, oldValue);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue