Qt: Fix some potential crashes with the gamepad mapping

This commit is contained in:
Jeffrey Pfau 2016-01-11 00:45:02 -08:00
parent 1f76168317
commit baccd4ef2f
3 changed files with 9 additions and 3 deletions

View File

@ -27,6 +27,7 @@ Bugfixes:
- 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

View File

@ -280,7 +280,7 @@ void GBAKeyEditor::lookupAxes(const GBAInputMap* map) {
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

View File

@ -399,14 +399,19 @@ void InputController::bindAxis(uint32_t type, int axis, GamepadAxisEvent::Direct
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;