mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
just resize axis vector is sdl decides to lie about the number of axes
This commit is contained in:
parent
9289249df5
commit
c57fc314f0
1 changed files with 8 additions and 5 deletions
|
@ -45,12 +45,15 @@ void Joystick::closeJoystick() {
|
|||
|
||||
#ifdef HAVE_SDL2
|
||||
void Joystick::handleAxisEvent(const SDL_ControllerAxisEvent& event) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
void Joystick::handleButtonEvent(const SDL_ControllerButtonEvent& event) {
|
||||
|
|
Loading…
Reference in a new issue