all repos — mgba @ d535d0cfac65187f48f70137b2f6860f42f4ecb1

mGBA Game Boy Advance Emulator

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
commit

d535d0cfac65187f48f70137b2f6860f42f4ecb1

parent

86b8b1ce3b46cea8e92a052a05cc5f8d10b63ca8

3 files changed, 15 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -3,6 +3,7 @@ Bugfixes:

- Qt: Use safer isLoaded check in GameController - 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: - GBA Audio: Implement missing flags on SOUNDCNT_X register
M src/platform/qt/GBAKeyEditor.cppsrc/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.hsrc/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*);