all repos — mgba @ 58d8cdde820628f29230d861a21d0bddc564b18e

mGBA Game Boy Advance Emulator

Qt: Focusing a button when mapping a gamepad now works
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Dec 2014 01:31:20 -0800
commit

58d8cdde820628f29230d861a21d0bddc564b18e

parent

61fc28e03e4f4c352a11bc27b4baa463af0b1e8c

2 files changed, 17 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/GBAKeyEditor.cppsrc/platform/qt/GBAKeyEditor.cpp

@@ -219,10 +219,24 @@ m_controller->bindKey(m_type, keyEditor->value(), 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;
M src/platform/qt/GBAKeyEditor.hsrc/platform/qt/GBAKeyEditor.h

@@ -53,6 +53,8 @@

void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey); void bindKey(const KeyEditor*, GBAKey); + bool findFocus(); + #ifdef BUILD_SDL void lookupAxes(const GBAInputMap*); #endif