Qt: Fix mapping analog triggers (fixes #495)

This commit is contained in:
Vicki Pfau 2018-10-14 14:17:43 -07:00
parent 4d383b129d
commit a751cd5184
5 changed files with 6 additions and 14 deletions

View File

@ -129,6 +129,7 @@ Bugfixes:
- Qt: Fix focus issues with load/save state overlay - Qt: Fix focus issues with load/save state overlay
- GB Video: Fix SGB border hole size - GB Video: Fix SGB border hole size
- PSP2: Fix tearing issues (fixes mgba.io/i/1211) - PSP2: Fix tearing issues (fixes mgba.io/i/1211)
- Qt: Fix mapping analog triggers (fixes mgba.io/i/495)
Misc: Misc:
- mGUI: Add SGB border configuration option - mGUI: Add SGB border configuration option
- mGUI: Add support for different settings types - mGUI: Add support for different settings types

View File

@ -278,13 +278,13 @@ void GBAKeyEditor::lookupAxes(const mInputMap* map) {
if (description->highDirection != GBA_KEY_NONE) { if (description->highDirection != GBA_KEY_NONE) {
KeyEditor* key = self->keyById(static_cast<enum GBAKey>(description->highDirection)); KeyEditor* key = self->keyById(static_cast<enum GBAKey>(description->highDirection));
if (key) { if (key) {
key->setValueAxis(axis, description->deadHigh); key->setValueAxis(axis, GamepadAxisEvent::POSITIVE);
} }
} }
if (description->lowDirection != GBA_KEY_NONE) { if (description->lowDirection != GBA_KEY_NONE) {
KeyEditor* key = self->keyById(static_cast<enum GBAKey>(description->lowDirection)); KeyEditor* key = self->keyById(static_cast<enum GBAKey>(description->lowDirection));
if (key) { if (key) {
key->setValueAxis(axis, description->deadLow); key->setValueAxis(axis, GamepadAxisEvent::NEGATIVE);
} }
} }
}, this); }, this);
@ -350,14 +350,6 @@ bool GBAKeyEditor::findFocus(KeyEditor* needle) {
} }
#ifdef BUILD_SDL #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) { void GBAKeyEditor::selectGamepad(int index) {
m_controller->setGamepad(m_type, index); m_controller->setGamepad(m_type, index);
m_profile = m_profileSelect->currentText(); m_profile = m_profileSelect->currentText();

View File

@ -42,7 +42,6 @@ private slots:
void setNext(); void setNext();
void refresh(); void refresh();
#ifdef BUILD_SDL #ifdef BUILD_SDL
void setAxisValue(int axis, int32_t value);
void selectGamepad(int index); void selectGamepad(int index);
void updateJoysticks(); void updateJoysticks();
#endif #endif

View File

@ -48,10 +48,10 @@ void KeyEditor::setValueButton(int button) {
setValue(button); setValue(button);
} }
void KeyEditor::setValueAxis(int axis, int32_t value) { void KeyEditor::setValueAxis(int axis, GamepadAxisEvent::Direction direction) {
m_button = true; m_button = true;
m_axis = axis; m_axis = axis;
m_direction = value < 0 ? GamepadAxisEvent::NEGATIVE : GamepadAxisEvent::POSITIVE; m_direction = direction;
updateButtonText(); updateButtonText();
emit axisChanged(axis, m_direction); emit axisChanged(axis, m_direction);
} }

View File

@ -33,7 +33,7 @@ public slots:
void setValue(int key); void setValue(int key);
void setValueKey(int key); void setValueKey(int key);
void setValueButton(int button); 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 setValueHat(int hat, GamepadHatEvent::Direction value);
void clearButton(); void clearButton();
void clearAxis(); void clearAxis();