diff options
| author | 2022-01-18 18:16:27 -0800 | |
|---|---|---|
| committer | 2022-01-18 18:16:27 -0800 | |
| commit | eceee8e5f484772c80e00092b76b42ab42ef9826 (patch) | |
| tree | 5fbfe7d08ccd2b05aacad5ead06e589cb8e92772 /src/input_common/drivers/mouse.cpp | |
| parent | Merge pull request #7712 from bunnei/fix-thread-exit (diff) | |
| parent | input_common: Reintroduce motion from mouse and use button names (diff) | |
| download | yuzu-eceee8e5f484772c80e00092b76b42ab42ef9826.tar.gz yuzu-eceee8e5f484772c80e00092b76b42ab42ef9826.tar.xz yuzu-eceee8e5f484772c80e00092b76b42ab42ef9826.zip | |
Merge pull request #7725 from german77/mouse_in_motion
input_common: Reintroduce motion from mouse and use button names
Diffstat (limited to 'src/input_common/drivers/mouse.cpp')
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index ac61591b0..d8ae7f0c1 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -16,6 +16,7 @@ constexpr int mouse_axis_x = 0; | |||
| 16 | constexpr int mouse_axis_y = 1; | 16 | constexpr int mouse_axis_y = 1; |
| 17 | constexpr int wheel_axis_x = 2; | 17 | constexpr int wheel_axis_x = 2; |
| 18 | constexpr int wheel_axis_y = 3; | 18 | constexpr int wheel_axis_y = 3; |
| 19 | constexpr int motion_wheel_y = 4; | ||
| 19 | constexpr int touch_axis_x = 10; | 20 | constexpr int touch_axis_x = 10; |
| 20 | constexpr int touch_axis_y = 11; | 21 | constexpr int touch_axis_y = 11; |
| 21 | constexpr PadIdentifier identifier = { | 22 | constexpr PadIdentifier identifier = { |
| @@ -30,6 +31,7 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) | |||
| 30 | PreSetAxis(identifier, mouse_axis_y); | 31 | PreSetAxis(identifier, mouse_axis_y); |
| 31 | PreSetAxis(identifier, wheel_axis_x); | 32 | PreSetAxis(identifier, wheel_axis_x); |
| 32 | PreSetAxis(identifier, wheel_axis_y); | 33 | PreSetAxis(identifier, wheel_axis_y); |
| 34 | PreSetAxis(identifier, motion_wheel_y); | ||
| 33 | PreSetAxis(identifier, touch_axis_x); | 35 | PreSetAxis(identifier, touch_axis_x); |
| 34 | PreSetAxis(identifier, touch_axis_y); | 36 | PreSetAxis(identifier, touch_axis_y); |
| 35 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); | 37 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); |
| @@ -48,6 +50,8 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 48 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); | 50 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 53 | SetAxis(identifier, motion_wheel_y, 0.0f); | ||
| 54 | |||
| 51 | if (mouse_panning_timout++ > 20) { | 55 | if (mouse_panning_timout++ > 20) { |
| 52 | StopPanning(); | 56 | StopPanning(); |
| 53 | } | 57 | } |
| @@ -136,6 +140,7 @@ void Mouse::MouseWheelChange(int x, int y) { | |||
| 136 | wheel_position.y += y; | 140 | wheel_position.y += y; |
| 137 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); | 141 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); |
| 138 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); | 142 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); |
| 143 | SetAxis(identifier, motion_wheel_y, static_cast<f32>(y) / 100.0f); | ||
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | void Mouse::ReleaseAllButtons() { | 146 | void Mouse::ReleaseAllButtons() { |
| @@ -171,13 +176,39 @@ AnalogMapping Mouse::GetAnalogMappingForDevice( | |||
| 171 | return mapping; | 176 | return mapping; |
| 172 | } | 177 | } |
| 173 | 178 | ||
| 179 | Common::Input::ButtonNames Mouse::GetUIButtonName(const Common::ParamPackage& params) const { | ||
| 180 | const auto button = static_cast<MouseButton>(params.Get("button", 0)); | ||
| 181 | switch (button) { | ||
| 182 | case MouseButton::Left: | ||
| 183 | return Common::Input::ButtonNames::ButtonLeft; | ||
| 184 | case MouseButton::Right: | ||
| 185 | return Common::Input::ButtonNames::ButtonRight; | ||
| 186 | case MouseButton::Wheel: | ||
| 187 | return Common::Input::ButtonNames::ButtonMouseWheel; | ||
| 188 | case MouseButton::Backward: | ||
| 189 | return Common::Input::ButtonNames::ButtonBackward; | ||
| 190 | case MouseButton::Forward: | ||
| 191 | return Common::Input::ButtonNames::ButtonForward; | ||
| 192 | case MouseButton::Task: | ||
| 193 | return Common::Input::ButtonNames::ButtonTask; | ||
| 194 | case MouseButton::Extra: | ||
| 195 | return Common::Input::ButtonNames::ButtonExtra; | ||
| 196 | case MouseButton::Undefined: | ||
| 197 | default: | ||
| 198 | return Common::Input::ButtonNames::Undefined; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 174 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { | 202 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { |
| 175 | if (params.Has("button")) { | 203 | if (params.Has("button")) { |
| 176 | return Common::Input::ButtonNames::Value; | 204 | return GetUIButtonName(params); |
| 177 | } | 205 | } |
| 178 | if (params.Has("axis")) { | 206 | if (params.Has("axis")) { |
| 179 | return Common::Input::ButtonNames::Value; | 207 | return Common::Input::ButtonNames::Value; |
| 180 | } | 208 | } |
| 209 | if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { | ||
| 210 | return Common::Input::ButtonNames::Engine; | ||
| 211 | } | ||
| 181 | 212 | ||
| 182 | return Common::Input::ButtonNames::Invalid; | 213 | return Common::Input::ButtonNames::Invalid; |
| 183 | } | 214 | } |