diff options
author | german77 <juangerman-13@hotmail.com> | 2023-03-05 18:00:00 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-03-08 02:31:52 +0100 |
commit | 9a9e5844d3865c923afc1238ce7a79b3ec111410 (patch) | |
tree | 022add86bcb2e79d4f0560bd0e164820372d3ae2 /src/input_common/drivers | |
parent | Merge pull request #9786 from FernandoS27/the-gaia-is-a-lie (diff) | |
download | yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar.gz yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar.bz2 yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar.lz yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar.xz yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.tar.zst yuzu-9a9e5844d3865c923afc1238ce7a79b3ec111410.zip |
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r-- | src/input_common/drivers/mouse.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 8b7f9aee9..94e92c37d 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -3,6 +3,7 @@ #include <thread> #include <fmt/format.h> +#include <math.h> #include "common/param_package.h" #include "common/settings.h" @@ -11,8 +12,9 @@ namespace InputCommon { constexpr int update_time = 10; -constexpr float default_stick_sensitivity = 0.022f; -constexpr float default_motion_sensitivity = 0.008f; +constexpr float default_stick_sensitivity = 0.0044f; +constexpr float default_motion_sensitivity = 0.0003f; +constexpr float maximum_rotation_speed = 2.0f; constexpr int mouse_axis_x = 0; constexpr int mouse_axis_y = 1; constexpr int wheel_axis_x = 2; @@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() { const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; - // Slow movement by 7% - if (Settings::values.mouse_panning) { - last_motion_change *= 0.93f; - } else { - last_motion_change.z *= 0.93f; + const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + + last_motion_change.y * last_motion_change.y); + + if (rotation_velocity > maximum_rotation_speed / sensitivity) { + const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity; + last_motion_change.x = last_motion_change.x * multiplier; + last_motion_change.y = last_motion_change.y * multiplier; } const BasicMotion motion_data{ @@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() { .delta_timestamp = update_time * 1000, }; + if (Settings::values.mouse_panning) { + last_motion_change.x = 0; + last_motion_change.y = 0; + } + last_motion_change.z = 0; + SetMotion(motion_identifier, 0, motion_data); } @@ -125,7 +135,7 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { auto mouse_change = (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); - Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z}; + last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z}; const auto move_distance = mouse_change.Length(); if (move_distance == 0) { @@ -141,7 +151,6 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { // Average mouse movements last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); - last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f); const auto last_move_distance = last_mouse_change.Length(); |