input_common: Increase mouse sensitivity range

This commit is contained in:
german77 2023-03-05 11:00:00 -06:00 committed by Narr the Reg
parent fdae95efaa
commit 9a9e5844d3
3 changed files with 20 additions and 10 deletions

View file

@ -503,7 +503,7 @@ struct Values {
Setting<bool> tas_loop{false, "tas_loop"}; Setting<bool> tas_loop{false, "tas_loop"};
Setting<bool> mouse_panning{false, "mouse_panning"}; 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> mouse_enabled{false, "mouse_enabled"};
Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"};

View file

@ -3,6 +3,7 @@
#include <thread> #include <thread>
#include <fmt/format.h> #include <fmt/format.h>
#include <math.h>
#include "common/param_package.h" #include "common/param_package.h"
#include "common/settings.h" #include "common/settings.h"
@ -11,8 +12,9 @@
namespace InputCommon { namespace InputCommon {
constexpr int update_time = 10; constexpr int update_time = 10;
constexpr float default_stick_sensitivity = 0.022f; constexpr float default_stick_sensitivity = 0.0044f;
constexpr float default_motion_sensitivity = 0.008f; constexpr float default_motion_sensitivity = 0.0003f;
constexpr float maximum_rotation_speed = 2.0f;
constexpr int mouse_axis_x = 0; constexpr int mouse_axis_x = 0;
constexpr int mouse_axis_y = 1; constexpr int mouse_axis_y = 1;
constexpr int wheel_axis_x = 2; constexpr int wheel_axis_x = 2;
@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() {
const float sensitivity = const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity;
// Slow movement by 7% const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x +
if (Settings::values.mouse_panning) { last_motion_change.y * last_motion_change.y);
last_motion_change *= 0.93f;
} else { if (rotation_velocity > maximum_rotation_speed / sensitivity) {
last_motion_change.z *= 0.93f; 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{ const BasicMotion motion_data{
@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() {
.delta_timestamp = update_time * 1000, .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); 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 = auto mouse_change =
(Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); (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(); const auto move_distance = mouse_change.Length();
if (move_distance == 0) { if (move_distance == 0) {
@ -141,7 +151,6 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
// Average mouse movements // Average mouse movements
last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); 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(); const auto last_move_distance = last_mouse_change.Length();

View file

@ -146,6 +146,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
if (data.engine == "mouse") { if (data.engine == "mouse") {
new_input.Set("motion", 0); new_input.Set("motion", 0);
new_input.Set("pad", 1); new_input.Set("pad", 1);
new_input.Set("threshold", 0.001f);
input_queue.Push(new_input); input_queue.Push(new_input);
return; return;
} }