Qt: Fix some potential crashes with the gamepad mapping
Jeffrey Pfau jeffrey@endrift.com
Mon, 11 Jan 2016 00:45:02 -0800
3 files changed,
9 insertions(+),
3 deletions(-)
M
CHANGES
→
CHANGES
@@ -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.cpp
→
src/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.cpp
→
src/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;