all repos — mgba @ baccd4ef2f7e3b730c80c2a69edb92368ee5197c

mGBA Game Boy Advance Emulator

Qt: Fix some potential crashes with the gamepad mapping
Jeffrey Pfau jeffrey@endrift.com
Mon, 11 Jan 2016 00:45:02 -0800
commit

baccd4ef2f7e3b730c80c2a69edb92368ee5197c

parent

1f7616831799b550653b0aca61e6c714cba0383c

3 files changed, 9 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -27,6 +27,7 @@ - GBA Hardware: Fix GPIO on big endian

- Util: Fix excessive memory allocation when decoding a PNG - GBA: Fix Iridion II savetype - Libretro: Fix aspect ratio + - Qt: Fix some potential crashes with the gamepad mapping Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper
M src/platform/qt/GBAKeyEditor.cppsrc/platform/qt/GBAKeyEditor.cpp

@@ -280,7 +280,7 @@ #endif

void GBAKeyEditor::bindKey(const KeyEditor* keyEditor, GBAKey key) { #ifdef BUILD_SDL - if (m_type == SDL_BINDING_BUTTON) { + if (m_type == SDL_BINDING_BUTTON && keyEditor->axis() >= 0) { m_controller->bindAxis(m_type, keyEditor->axis(), keyEditor->direction(), key); } #endif
M src/platform/qt/InputController.cppsrc/platform/qt/InputController.cpp

@@ -399,14 +399,19 @@ GBAAxis description = { GBA_KEY_NONE, GBA_KEY_NONE, -AXIS_THRESHOLD, AXIS_THRESHOLD };

if (old) { description = *old; } + int deadzone = 0; + if (m_deadzones.size() > axis) { + deadzone = m_deadzones[axis]; + } switch (direction) { case GamepadAxisEvent::NEGATIVE: description.lowDirection = key; - description.deadLow = m_deadzones[axis] - AXIS_THRESHOLD; + + description.deadLow = deadzone - AXIS_THRESHOLD; break; case GamepadAxisEvent::POSITIVE: description.highDirection = key; - description.deadHigh = m_deadzones[axis] + AXIS_THRESHOLD; + description.deadHigh = deadzone + AXIS_THRESHOLD; break; default: return;