summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/mouse.cpp27
-rw-r--r--src/input_common/input_mapping.cpp1
2 files changed, 19 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
12namespace InputCommon { 13namespace InputCommon {
13constexpr int update_time = 10; 14constexpr int update_time = 10;
14constexpr float default_stick_sensitivity = 0.022f; 15constexpr float default_stick_sensitivity = 0.0044f;
15constexpr float default_motion_sensitivity = 0.008f; 16constexpr float default_motion_sensitivity = 0.0003f;
17constexpr float maximum_rotation_speed = 2.0f;
16constexpr int mouse_axis_x = 0; 18constexpr int mouse_axis_x = 0;
17constexpr int mouse_axis_y = 1; 19constexpr int mouse_axis_y = 1;
18constexpr int wheel_axis_x = 2; 20constexpr 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
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp
index 2ff480ff9..9361b00c5 100644
--- a/src/input_common/input_mapping.cpp
+++ b/src/input_common/input_mapping.cpp
@@ -146,6 +146,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
146 if (data.engine == "mouse") { 146 if (data.engine == "mouse") {
147 new_input.Set("motion", 0); 147 new_input.Set("motion", 0);
148 new_input.Set("pad", 1); 148 new_input.Set("pad", 1);
149 new_input.Set("threshold", 0.001f);
149 input_queue.Push(new_input); 150 input_queue.Push(new_input);
150 return; 151 return;
151 } 152 }