all repos — mgba @ f4b44451b012ead55e5cc7ed93672ed2cb1231fb

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

f4b44451b012ead55e5cc7ed93672ed2cb1231fb

parent

9a19aaed5933859fb8b0ed8910a93ab96e117f51

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

jump to
M CHANGESCHANGES

@@ -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.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*);