diff --git a/src/platform/qt/GBAKeyEditor.cpp b/src/platform/qt/GBAKeyEditor.cpp index 2611a8f11..9b696af32 100644 --- a/src/platform/qt/GBAKeyEditor.cpp +++ b/src/platform/qt/GBAKeyEditor.cpp @@ -219,10 +219,24 @@ void GBAKeyEditor::bindKey(const KeyEditor* keyEditor, GBAKey key) { } } +bool GBAKeyEditor::findFocus() { + if (m_currentKey != m_keyOrder.end() && (*m_currentKey)->hasFocus()) { + return true; + } + + for (auto key = m_keyOrder.begin(); key != m_keyOrder.end(); ++key) { + if ((*key)->hasFocus()) { + m_currentKey = key; + return true; + } + } + return false; +} + #ifdef BUILD_SDL void GBAKeyEditor::testGamepad() { m_gamepadTimer->setInterval(50); - if (m_currentKey == m_keyOrder.end() || !*m_currentKey) { + if (!findFocus()) { return; } KeyEditor* focused = *m_currentKey; diff --git a/src/platform/qt/GBAKeyEditor.h b/src/platform/qt/GBAKeyEditor.h index cc1a30abb..a6b66c74c 100644 --- a/src/platform/qt/GBAKeyEditor.h +++ b/src/platform/qt/GBAKeyEditor.h @@ -53,6 +53,8 @@ private: void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey); void bindKey(const KeyEditor*, GBAKey); + bool findFocus(); + #ifdef BUILD_SDL void lookupAxes(const GBAInputMap*); #endif