diff options
| author | 2021-11-14 21:28:38 -0600 | |
|---|---|---|
| committer | 2021-11-24 20:30:28 -0600 | |
| commit | f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149 (patch) | |
| tree | 9e9f9114d9b7528e74e78102279411595632f048 /src/input_common/drivers/mouse.cpp | |
| parent | core/hid: Fully implement native mouse (diff) | |
| download | yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.gz yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.xz yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.zip | |
core/hid: Improve accuary of mouse implementation
Diffstat (limited to 'src/input_common/drivers/mouse.cpp')
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 478737db2..05fd7f9c0 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -39,7 +39,7 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 39 | Common::SetCurrentThreadName("yuzu:input:Mouse"); | 39 | Common::SetCurrentThreadName("yuzu:input:Mouse"); |
| 40 | constexpr int update_time = 10; | 40 | constexpr int update_time = 10; |
| 41 | while (!stop_token.stop_requested()) { | 41 | while (!stop_token.stop_requested()) { |
| 42 | if (Settings::values.mouse_panning) { | 42 | if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) { |
| 43 | // Slow movement by 4% | 43 | // Slow movement by 4% |
| 44 | last_mouse_change *= 0.96f; | 44 | last_mouse_change *= 0.96f; |
| 45 | const float sensitivity = | 45 | const float sensitivity = |
| @@ -52,14 +52,17 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 52 | StopPanning(); | 52 | StopPanning(); |
| 53 | } | 53 | } |
| 54 | std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); | 54 | std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); |
| 55 | |||
| 56 | // Reset wheel position | ||
| 57 | SetAxis(identifier, wheel_axis_x, 0); | ||
| 58 | SetAxis(identifier, wheel_axis_y, 0); | ||
| 59 | } | 55 | } |
| 60 | } | 56 | } |
| 61 | 57 | ||
| 62 | void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int center_y) { | 58 | void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int center_y) { |
| 59 | // If native mouse is enabled just set the screen coordinates | ||
| 60 | if (Settings::values.mouse_enabled) { | ||
| 61 | SetAxis(identifier, mouse_axis_x, touch_x); | ||
| 62 | SetAxis(identifier, mouse_axis_y, touch_y); | ||
| 63 | return; | ||
| 64 | } | ||
| 65 | |||
| 63 | SetAxis(identifier, touch_axis_x, touch_x); | 66 | SetAxis(identifier, touch_axis_x, touch_x); |
| 64 | SetAxis(identifier, touch_axis_y, touch_y); | 67 | SetAxis(identifier, touch_axis_y, touch_y); |
| 65 | 68 | ||
| @@ -121,7 +124,7 @@ void Mouse::PressButton(int x, int y, f32 touch_x, f32 touch_y, MouseButton butt | |||
| 121 | void Mouse::ReleaseButton(MouseButton button) { | 124 | void Mouse::ReleaseButton(MouseButton button) { |
| 122 | SetButton(identifier, static_cast<int>(button), false); | 125 | SetButton(identifier, static_cast<int>(button), false); |
| 123 | 126 | ||
| 124 | if (!Settings::values.mouse_panning) { | 127 | if (!Settings::values.mouse_panning && !Settings::values.mouse_enabled) { |
| 125 | SetAxis(identifier, mouse_axis_x, 0); | 128 | SetAxis(identifier, mouse_axis_x, 0); |
| 126 | SetAxis(identifier, mouse_axis_y, 0); | 129 | SetAxis(identifier, mouse_axis_y, 0); |
| 127 | } | 130 | } |
| @@ -129,8 +132,10 @@ void Mouse::ReleaseButton(MouseButton button) { | |||
| 129 | } | 132 | } |
| 130 | 133 | ||
| 131 | void Mouse::MouseWheelChange(int x, int y) { | 134 | void Mouse::MouseWheelChange(int x, int y) { |
| 132 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(x)); | 135 | wheel_position.x += x; |
| 133 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(y)); | 136 | wheel_position.y += y; |
| 137 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); | ||
| 138 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); | ||
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | void Mouse::ReleaseAllButtons() { | 141 | void Mouse::ReleaseAllButtons() { |