mirror of https://github.com/mgba-emu/mgba.git
Qt: Redo sensor binding to be less fragile
This commit is contained in:
parent
9a26c1a679
commit
de16ea49c7
1
CHANGES
1
CHANGES
|
@ -34,6 +34,7 @@ Other fixes:
|
||||||
- Qt: Fix applying savetype-only overrides
|
- Qt: Fix applying savetype-only overrides
|
||||||
- Qt: Fix crash in sprite view for partially out-of-bounds sprites (fixes mgba.io/i/2165)
|
- Qt: Fix crash in sprite view for partially out-of-bounds sprites (fixes mgba.io/i/2165)
|
||||||
- Qt: Fix having to press controller buttons twice for menu items (fixes mgba.io/i/2143)
|
- Qt: Fix having to press controller buttons twice for menu items (fixes mgba.io/i/2143)
|
||||||
|
- Qt: Redo sensor binding to be less fragile
|
||||||
- Util: Fix loading UPS patches that affect the last byte of the file
|
- Util: Fix loading UPS patches that affect the last byte of the file
|
||||||
Misc:
|
Misc:
|
||||||
- Core: Suspend runloop when a core crashes
|
- Core: Suspend runloop when a core crashes
|
||||||
|
|
|
@ -79,14 +79,11 @@ void SensorView::setController(std::shared_ptr<CoreController> controller) {
|
||||||
void SensorView::jiggerer(QAbstractButton* button, void (InputController::*setter)(int)) {
|
void SensorView::jiggerer(QAbstractButton* button, void (InputController::*setter)(int)) {
|
||||||
connect(button, &QAbstractButton::toggled, [this, button, setter](bool checked) {
|
connect(button, &QAbstractButton::toggled, [this, button, setter](bool checked) {
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
m_jiggered = nullptr;
|
m_button = nullptr;
|
||||||
} else {
|
} else {
|
||||||
button->setFocus();
|
button->setFocus();
|
||||||
m_jiggered = [this, button, setter](int axis) {
|
m_button = button;
|
||||||
(m_input->*setter)(axis);
|
m_setter = setter;
|
||||||
button->setChecked(false);
|
|
||||||
button->clearFocus();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button->installEventFilter(this);
|
button->installEventFilter(this);
|
||||||
|
@ -106,8 +103,12 @@ bool SensorView::eventFilter(QObject*, QEvent* event) {
|
||||||
if (event->type() == GamepadAxisEvent::Type()) {
|
if (event->type() == GamepadAxisEvent::Type()) {
|
||||||
GamepadAxisEvent* gae = static_cast<GamepadAxisEvent*>(event);
|
GamepadAxisEvent* gae = static_cast<GamepadAxisEvent*>(event);
|
||||||
gae->accept();
|
gae->accept();
|
||||||
if (m_jiggered && gae->direction() != GamepadAxisEvent::NEUTRAL && gae->isNew()) {
|
if (m_button && gae->direction() != GamepadAxisEvent::NEUTRAL && gae->isNew()) {
|
||||||
m_jiggered(gae->axis());
|
m_button->removeEventFilter(this);
|
||||||
|
m_button->clearFocus();
|
||||||
|
m_button->setChecked(false);
|
||||||
|
(m_input->*m_setter)(gae->axis());
|
||||||
|
m_button = nullptr;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,9 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Ui::SensorView m_ui;
|
Ui::SensorView m_ui;
|
||||||
|
|
||||||
std::function<void(int)> m_jiggered;
|
QAbstractButton* m_button = nullptr;
|
||||||
|
void (InputController::*m_setter)(int);
|
||||||
|
|
||||||
std::shared_ptr<CoreController> m_controller;
|
std::shared_ptr<CoreController> m_controller;
|
||||||
InputController* m_input;
|
InputController* m_input;
|
||||||
mRotationSource* m_rotation;
|
mRotationSource* m_rotation;
|
||||||
|
|
Loading…
Reference in New Issue