diff options
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 @@ | |||
| 3 | 3 | ||
| 4 | #include <thread> | 4 | #include <thread> |
| 5 | #include <fmt/format.h> | 5 | #include <fmt/format.h> |
| 6 | #include <math.h> | ||
| 6 | 7 | ||
| 7 | #include "common/param_package.h" | 8 | #include "common/param_package.h" |
| 8 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| @@ -11,8 +12,9 @@ | |||
| 11 | 12 | ||
| 12 | namespace InputCommon { | 13 | namespace InputCommon { |
| 13 | constexpr int update_time = 10; | 14 | constexpr int update_time = 10; |
| 14 | constexpr float default_stick_sensitivity = 0.022f; | 15 | constexpr float default_stick_sensitivity = 0.0044f; |
| 15 | constexpr float default_motion_sensitivity = 0.008f; | 16 | constexpr float default_motion_sensitivity = 0.0003f; |
| 17 | constexpr float maximum_rotation_speed = 2.0f; | ||
| 16 | constexpr int mouse_axis_x = 0; | 18 | constexpr int mouse_axis_x = 0; |
| 17 | constexpr int mouse_axis_y = 1; | 19 | constexpr int mouse_axis_y = 1; |
| 18 | constexpr int wheel_axis_x = 2; | 20 | constexpr int wheel_axis_x = 2; |
| @@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() { | |||
| 99 | const float sensitivity = | 101 | const float sensitivity = |
| 100 | Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; | 102 | Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; |
| 101 | 103 | ||
| 102 | // Slow movement by 7% | 104 | const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + |
| 103 | if (Settings::values.mouse_panning) { | 105 | last_motion_change.y * last_motion_change.y); |
| 104 | last_motion_change *= 0.93f; | 106 | |
| 105 | } else { | 107 | if (rotation_velocity > maximum_rotation_speed / sensitivity) { |
| 106 | last_motion_change.z *= 0.93f; | 108 | const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity; |
| 109 | last_motion_change.x = last_motion_change.x * multiplier; | ||
| 110 | last_motion_change.y = last_motion_change.y * multiplier; | ||
| 107 | } | 111 | } |
| 108 | 112 | ||
| 109 | const BasicMotion motion_data{ | 113 | const BasicMotion motion_data{ |
| @@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() { | |||
| 116 | .delta_timestamp = update_time * 1000, | 120 | .delta_timestamp = update_time * 1000, |
| 117 | }; | 121 | }; |
| 118 | 122 | ||
| 123 | if (Settings::values.mouse_panning) { | ||
| 124 | last_motion_change.x = 0; | ||
| 125 | last_motion_change.y = 0; | ||
| 126 | } | ||
| 127 | last_motion_change.z = 0; | ||
| 128 | |||
| 119 | SetMotion(motion_identifier, 0, motion_data); | 129 | SetMotion(motion_identifier, 0, motion_data); |
| 120 | } | 130 | } |
| 121 | 131 | ||
| @@ -125,7 +135,7 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { | |||
| 125 | 135 | ||
| 126 | auto mouse_change = | 136 | auto mouse_change = |
| 127 | (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); | 137 | (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); |
| 128 | Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z}; | 138 | last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z}; |
| 129 | 139 | ||
| 130 | const auto move_distance = mouse_change.Length(); | 140 | const auto move_distance = mouse_change.Length(); |
| 131 | if (move_distance == 0) { | 141 | if (move_distance == 0) { |
| @@ -141,7 +151,6 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { | |||
| 141 | 151 | ||
| 142 | // Average mouse movements | 152 | // Average mouse movements |
| 143 | last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); | 153 | last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); |
| 144 | last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f); | ||
| 145 | 154 | ||
| 146 | const auto last_move_distance = last_mouse_change.Length(); | 155 | const auto last_move_distance = last_mouse_change.Length(); |
| 147 | 156 | ||