all repos — mgba @ 34512371bb3269c3d3b8c863978deb2eedce7871

mGBA Game Boy Advance Emulator

Qt: Fix crash if no axes are found
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Apr 2015 02:46:56 -0700
commit

34512371bb3269c3d3b8c863978deb2eedce7871

parent

c42c08c5e1c2d2642637565cce4eba5742513bac

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/InputController.cppsrc/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);