Qt: Fix clear button/analog buttons in gamepad mapper on some platforms
Jeffrey Pfau jeffrey@endrift.com
Tue, 27 Oct 2015 22:22:15 -0700
3 files changed,
15 insertions(+),
6 deletions(-)
M
CHANGES
→
CHANGES
@@ -10,6 +10,7 @@ - Qt: Use safer isLoaded check in GameController
- GBA Memory: Fix DMAs from BIOS while not in BIOS - GBA: Fix idle skip state being retained between games - Qt: Fix a race condition in PainterGL that could lead to a crash + - Qt: Fix clear button/analog buttons in gamepad mapper on some platforms Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper
M
src/platform/qt/GBAKeyEditor.cpp
→
src/platform/qt/GBAKeyEditor.cpp
@@ -126,6 +126,7 @@
for (auto& key : m_keyOrder) { connect(key, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(key, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); + key->installEventFilter(this); } m_currentKey = m_keyOrder.end();@@ -181,9 +182,15 @@ }
return QWidget::event(event); } -void GBAKeyEditor::setNext() { - findFocus(); +bool GBAKeyEditor::eventFilter(QObject* obj, QEvent* event) { + if (event->type() != QEvent::FocusIn) { + return false; + } + findFocus(static_cast<KeyEditor*>(obj)); + return true; +} +void GBAKeyEditor::setNext() { if (m_currentKey == m_keyOrder.end()) { return; }@@ -280,18 +287,18 @@ #endif
m_controller->bindKey(m_type, keyEditor->value(), key); } -bool GBAKeyEditor::findFocus() { +bool GBAKeyEditor::findFocus(KeyEditor* needle) { 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()) { + if ((*key)->hasFocus() || needle == *key) { m_currentKey = key; return true; } } - return false; + return m_currentKey != m_keyOrder.end(); } #ifdef BUILD_SDL
M
src/platform/qt/GBAKeyEditor.h
→
src/platform/qt/GBAKeyEditor.h
@@ -37,6 +37,7 @@ virtual void resizeEvent(QResizeEvent*) override;
virtual void paintEvent(QPaintEvent*) override; virtual bool event(QEvent*) override; virtual void closeEvent(QCloseEvent*) override; + virtual bool eventFilter(QObject* obj, QEvent* event) override; private slots: void setNext();@@ -57,7 +58,7 @@
void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey); void bindKey(const KeyEditor*, GBAKey); - bool findFocus(); + bool findFocus(KeyEditor* needle = nullptr); #ifdef BUILD_SDL void lookupAxes(const GBAInputMap*);