Qt: Focusing a button when mapping a gamepad now works

This commit is contained in:
Jeffrey Pfau 2014-12-18 01:31:20 -08:00
parent 61fc28e03e
commit 58d8cdde82
2 changed files with 17 additions and 1 deletions

View File

@ -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;

View File

@ -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