Qt: Fix clear button/analog buttons in gamepad mapper on some platforms

This commit is contained in:
Jeffrey Pfau 2015-10-27 22:22:15 -07:00
parent 9a19aaed59
commit f4b44451b0
3 changed files with 15 additions and 6 deletions

View File

@ -10,6 +10,7 @@ Bugfixes:
- 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

View File

@ -126,6 +126,7 @@ GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, const QString&
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 @@ bool GBAKeyEditor::event(QEvent* event) {
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 @@ void GBAKeyEditor::bindKey(const KeyEditor* keyEditor, GBAKey key) {
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

View File

@ -37,6 +37,7 @@ protected:
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 @@ private:
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*);