diff options
| author | bunnei <bunneidev@gmail.com> | 2021-05-03 12:50:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-03 12:50:19 -0700 |
| commit | 0a7fe85409e49ccc361a039c2ec7d2c9b047bf81 (patch) | |
| tree | 73c9803fabc9b170b11bff6a73e9b4030afbbce6 /src/input_common | |
| parent | abf7bc52b4ee76e546f5bdb6c2ea999cf43a2ea6 (diff) | |
| parent | 15628589633733020bcaf89a8a352f2e35501c6a (diff) | |
Merge pull request #6275 from german77/mousefocus
input_common: Release mouse buttons on out of focus
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/mouse/mouse_input.cpp | 9 | ||||
| -rw-r--r-- | src/input_common/mouse/mouse_input.h | 8 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp index fff1c6b45e..a335e6da1e 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 750d9b0114..5a971ad67f 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_); |
