Qt: Fix crash if no axes are found
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Apr 2015 02:46:56 -0700
1 files changed,
7 insertions(+),
1 deletions(-)
M
src/platform/qt/InputController.cpp
→
src/platform/qt/InputController.cpp
@@ -233,6 +233,9 @@ void InputController::recalibrateAxes() {
SDL_Joystick* joystick = m_sdlPlayer.joystick; SDL_JoystickUpdate(); int numAxes = SDL_JoystickNumAxes(joystick); + if (numAxes < 1) { + return; + } m_deadzones.resize(numAxes); int i; for (i = 0; i < numAxes; ++i) {@@ -244,8 +247,11 @@ QSet<QPair<int, GamepadAxisEvent::Direction>> InputController::activeGamepadAxes() {
SDL_Joystick* joystick = m_sdlPlayer.joystick; SDL_JoystickUpdate(); int numAxes = SDL_JoystickNumAxes(joystick); + QSet<QPair<int, GamepadAxisEvent::Direction>> activeAxes; + if (numAxes < 1) { + return activeAxes; + } m_deadzones.resize(numAxes); - QSet<QPair<int, GamepadAxisEvent::Direction>> activeAxes; int i; for (i = 0; i < numAxes; ++i) { int32_t axis = SDL_JoystickGetAxis(joystick, i);