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 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: Redo sensor binding to be less fragile
|
||||
- Util: Fix loading UPS patches that affect the last byte of the file
|
||||
Misc:
|
||||
- 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)) {
|
||||
connect(button, &QAbstractButton::toggled, [this, button, setter](bool checked) {
|
||||
if (!checked) {
|
||||
m_jiggered = nullptr;
|
||||
m_button = nullptr;
|
||||
} else {
|
||||
button->setFocus();
|
||||
m_jiggered = [this, button, setter](int axis) {
|
||||
(m_input->*setter)(axis);
|
||||
button->setChecked(false);
|
||||
button->clearFocus();
|
||||
};
|
||||
m_button = button;
|
||||
m_setter = setter;
|
||||
}
|
||||
});
|
||||
button->installEventFilter(this);
|
||||
|
@ -106,8 +103,12 @@ bool SensorView::eventFilter(QObject*, QEvent* event) {
|
|||
if (event->type() == GamepadAxisEvent::Type()) {
|
||||
GamepadAxisEvent* gae = static_cast<GamepadAxisEvent*>(event);
|
||||
gae->accept();
|
||||
if (m_jiggered && gae->direction() != GamepadAxisEvent::NEUTRAL && gae->isNew()) {
|
||||
m_jiggered(gae->axis());
|
||||
if (m_button && gae->direction() != GamepadAxisEvent::NEUTRAL && gae->isNew()) {
|
||||
m_button->removeEventFilter(this);
|
||||
m_button->clearFocus();
|
||||
m_button->setChecked(false);
|
||||
(m_input->*m_setter)(gae->axis());
|
||||
m_button = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ private slots:
|
|||
private:
|
||||
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;
|
||||
InputController* m_input;
|
||||
mRotationSource* m_rotation;
|
||||
|
|
Loading…
Reference in New Issue