From a751cd51841f7f00dfd148df13f13c877a5d7074 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 14 Oct 2018 14:17:43 -0700 Subject: [PATCH] Qt: Fix mapping analog triggers (fixes #495) --- CHANGES | 1 + src/platform/qt/GBAKeyEditor.cpp | 12 ++---------- src/platform/qt/GBAKeyEditor.h | 1 - src/platform/qt/KeyEditor.cpp | 4 ++-- src/platform/qt/KeyEditor.h | 2 +- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index db4c41e89..1dcb44d03 100644 --- a/CHANGES +++ b/CHANGES @@ -129,6 +129,7 @@ Bugfixes: - Qt: Fix focus issues with load/save state overlay - GB Video: Fix SGB border hole size - PSP2: Fix tearing issues (fixes mgba.io/i/1211) + - Qt: Fix mapping analog triggers (fixes mgba.io/i/495) Misc: - mGUI: Add SGB border configuration option - mGUI: Add support for different settings types diff --git a/src/platform/qt/GBAKeyEditor.cpp b/src/platform/qt/GBAKeyEditor.cpp index 064bd0f58..03d0769e2 100644 --- a/src/platform/qt/GBAKeyEditor.cpp +++ b/src/platform/qt/GBAKeyEditor.cpp @@ -278,13 +278,13 @@ void GBAKeyEditor::lookupAxes(const mInputMap* map) { if (description->highDirection != GBA_KEY_NONE) { KeyEditor* key = self->keyById(static_cast(description->highDirection)); if (key) { - key->setValueAxis(axis, description->deadHigh); + key->setValueAxis(axis, GamepadAxisEvent::POSITIVE); } } if (description->lowDirection != GBA_KEY_NONE) { KeyEditor* key = self->keyById(static_cast(description->lowDirection)); if (key) { - key->setValueAxis(axis, description->deadLow); + key->setValueAxis(axis, GamepadAxisEvent::NEGATIVE); } } }, this); @@ -350,14 +350,6 @@ bool GBAKeyEditor::findFocus(KeyEditor* needle) { } #ifdef BUILD_SDL -void GBAKeyEditor::setAxisValue(int axis, int32_t value) { - if (!findFocus()) { - return; - } - KeyEditor* focused = *m_currentKey; - focused->setValueAxis(axis, value); -} - void GBAKeyEditor::selectGamepad(int index) { m_controller->setGamepad(m_type, index); m_profile = m_profileSelect->currentText(); diff --git a/src/platform/qt/GBAKeyEditor.h b/src/platform/qt/GBAKeyEditor.h index 22720ab3c..24b1e5c4a 100644 --- a/src/platform/qt/GBAKeyEditor.h +++ b/src/platform/qt/GBAKeyEditor.h @@ -42,7 +42,6 @@ private slots: void setNext(); void refresh(); #ifdef BUILD_SDL - void setAxisValue(int axis, int32_t value); void selectGamepad(int index); void updateJoysticks(); #endif diff --git a/src/platform/qt/KeyEditor.cpp b/src/platform/qt/KeyEditor.cpp index 002ba490f..f77dceb9b 100644 --- a/src/platform/qt/KeyEditor.cpp +++ b/src/platform/qt/KeyEditor.cpp @@ -48,10 +48,10 @@ void KeyEditor::setValueButton(int button) { setValue(button); } -void KeyEditor::setValueAxis(int axis, int32_t value) { +void KeyEditor::setValueAxis(int axis, GamepadAxisEvent::Direction direction) { m_button = true; m_axis = axis; - m_direction = value < 0 ? GamepadAxisEvent::NEGATIVE : GamepadAxisEvent::POSITIVE; + m_direction = direction; updateButtonText(); emit axisChanged(axis, m_direction); } diff --git a/src/platform/qt/KeyEditor.h b/src/platform/qt/KeyEditor.h index 00798c56f..e74df7f27 100644 --- a/src/platform/qt/KeyEditor.h +++ b/src/platform/qt/KeyEditor.h @@ -33,7 +33,7 @@ public slots: void setValue(int key); void setValueKey(int key); void setValueButton(int button); - void setValueAxis(int axis, int32_t value); + void setValueAxis(int axis, GamepadAxisEvent::Direction value); void setValueHat(int hat, GamepadHatEvent::Direction value); void clearButton(); void clearAxis();