Qt: Focusing a button when mapping a gamepad now works
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Dec 2014 01:31:20 -0800
2 files changed,
17 insertions(+),
1 deletions(-)
M
src/platform/qt/GBAKeyEditor.cpp
→
src/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.h
→
src/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