summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-05-03 21:50:19 +0200
committerGitHub <noreply@github.com>2021-05-03 21:50:19 +0200
commit898aa5fb6612e8c009fa65224ef9ea404448db59 (patch)
tree73c9803fabc9b170b11bff6a73e9b4030afbbce6
parentMerge pull request #6277 from german77/touchsetting2 (diff)
parentinput_common: Release mouse buttons on out of focus (diff)
downloadyuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar.gz
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar.bz2
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar.lz
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar.xz
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.tar.zst
yuzu-898aa5fb6612e8c009fa65224ef9ea404448db59.zip
-rw-r--r--src/input_common/mouse/mouse_input.cpp9
-rw-r--r--src/input_common/mouse/mouse_input.h8
-rw-r--r--src/yuzu/bootmanager.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp
index fff1c6b45..a335e6da1 100644
--- a/src/input_common/mouse/mouse_input.cpp
+++ b/src/input_common/mouse/mouse_input.cpp
@@ -143,6 +143,15 @@ void Mouse::ReleaseButton(MouseButton button_) {
mouse_info[button_index].data.axis = {0, 0};
}
+void Mouse::ReleaseAllButtons() {
+ buttons = 0;
+ for (auto& info : mouse_info) {
+ info.tilt_speed = 0;
+ info.data.pressed = false;
+ info.data.axis = {0, 0};
+ }
+}
+
void Mouse::BeginConfiguration() {
buttons = 0;
last_button = MouseButton::Undefined;
diff --git a/src/input_common/mouse/mouse_input.h b/src/input_common/mouse/mouse_input.h
index 750d9b011..5a971ad67 100644
--- a/src/input_common/mouse/mouse_input.h
+++ b/src/input_common/mouse/mouse_input.h
@@ -65,10 +65,16 @@ public:
void MouseMove(int x, int y, int center_x, int center_y);
/**
- * Signals that a motion sensor tilt has ended.
+ * Signals that a button is released.
+ * @param button_ the button pressed
*/
void ReleaseButton(MouseButton button_);
+ /**
+ * Signals that all buttons are released
+ */
+ void ReleaseAllButtons();
+
[[nodiscard]] bool ToggleButton(std::size_t button_);
[[nodiscard]] bool UnlockButton(std::size_t button_);
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 9c7daeac7..7ff9491f4 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -539,6 +539,8 @@ bool GRenderWindow::event(QEvent* event) {
void GRenderWindow::focusOutEvent(QFocusEvent* event) {
QWidget::focusOutEvent(event);
input_subsystem->GetKeyboard()->ReleaseAllKeys();
+ input_subsystem->GetMouse()->ReleaseAllButtons();
+ this->TouchReleased(0);
}
void GRenderWindow::resizeEvent(QResizeEvent* event) {