summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-03-08 19:43:38 +0100
committerGitHub <noreply@github.com>2023-03-08 19:43:38 +0100
commit4562f7af9a367e45fc28b16e266da04ce30f6bde (patch)
tree5a432f6eec5496c84aa3d33dd4fac62e8d41a49c
parentMerge pull request #9912 from liamwhite/err (diff)
parentinput_common: Increase mouse sensitivity range (diff)
downloadyuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar.gz
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar.bz2
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar.lz
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar.xz
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.tar.zst
yuzu-4562f7af9a367e45fc28b16e266da04ce30f6bde.zip
-rw-r--r--src/common/settings.h2
-rw-r--r--src/input_common/drivers/mouse.cpp27
-rw-r--r--src/input_common/input_mapping.cpp1
3 files changed, 20 insertions, 10 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 1ae28ce93..b77a1580a 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -503,7 +503,7 @@ struct Values {
Setting<bool> tas_loop{false, "tas_loop"};
Setting<bool> mouse_panning{false, "mouse_panning"};
- Setting<u8, true> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"};
+ Setting<u8, true> mouse_panning_sensitivity{50, 1, 100, "mouse_panning_sensitivity"};
Setting<bool> mouse_enabled{false, "mouse_enabled"};
Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"};
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();
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) {
if (data.engine == "mouse") {
new_input.Set("motion", 0);
new_input.Set("pad", 1);
+ new_input.Set("threshold", 0.001f);
input_queue.Push(new_input);
return;
}