diff options
Diffstat (limited to 'src/input_common/drivers/mouse.cpp')
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index e92ea878f..dac29c78f 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -85,7 +85,7 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | void Mouse::UpdateStickInput() { | 87 | void Mouse::UpdateStickInput() { |
| 88 | if (!Settings::values.mouse_panning) { | 88 | if (!IsMousePanningEnabled()) { |
| 89 | return; | 89 | return; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| @@ -111,8 +111,8 @@ void Mouse::UpdateStickInput() { | |||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | void Mouse::UpdateMotionInput() { | 113 | void Mouse::UpdateMotionInput() { |
| 114 | const float sensitivity = Settings::values.mouse_panning ? default_motion_panning_sensitivity | 114 | const float sensitivity = |
| 115 | : default_motion_sensitivity; | 115 | IsMousePanningEnabled() ? default_motion_panning_sensitivity : default_motion_sensitivity; |
| 116 | 116 | ||
| 117 | const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + | 117 | const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + |
| 118 | last_motion_change.y * last_motion_change.y); | 118 | last_motion_change.y * last_motion_change.y); |
| @@ -134,7 +134,7 @@ void Mouse::UpdateMotionInput() { | |||
| 134 | .delta_timestamp = update_time * 1000, | 134 | .delta_timestamp = update_time * 1000, |
| 135 | }; | 135 | }; |
| 136 | 136 | ||
| 137 | if (Settings::values.mouse_panning) { | 137 | if (IsMousePanningEnabled()) { |
| 138 | last_motion_change.x = 0; | 138 | last_motion_change.x = 0; |
| 139 | last_motion_change.y = 0; | 139 | last_motion_change.y = 0; |
| 140 | } | 140 | } |
| @@ -144,7 +144,7 @@ void Mouse::UpdateMotionInput() { | |||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | void Mouse::Move(int x, int y, int center_x, int center_y) { | 146 | void Mouse::Move(int x, int y, int center_x, int center_y) { |
| 147 | if (Settings::values.mouse_panning) { | 147 | if (IsMousePanningEnabled()) { |
| 148 | const auto mouse_change = | 148 | const auto mouse_change = |
| 149 | (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); | 149 | (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); |
| 150 | const float x_sensitivity = | 150 | const float x_sensitivity = |
| @@ -219,7 +219,7 @@ void Mouse::ReleaseButton(MouseButton button) { | |||
| 219 | SetButton(real_mouse_identifier, static_cast<int>(button), false); | 219 | SetButton(real_mouse_identifier, static_cast<int>(button), false); |
| 220 | SetButton(touch_identifier, static_cast<int>(button), false); | 220 | SetButton(touch_identifier, static_cast<int>(button), false); |
| 221 | 221 | ||
| 222 | if (!Settings::values.mouse_panning) { | 222 | if (!IsMousePanningEnabled()) { |
| 223 | SetAxis(identifier, mouse_axis_x, 0); | 223 | SetAxis(identifier, mouse_axis_x, 0); |
| 224 | SetAxis(identifier, mouse_axis_y, 0); | 224 | SetAxis(identifier, mouse_axis_y, 0); |
| 225 | } | 225 | } |
| @@ -243,6 +243,11 @@ void Mouse::ReleaseAllButtons() { | |||
| 243 | button_pressed = false; | 243 | button_pressed = false; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | bool Mouse::IsMousePanningEnabled() { | ||
| 247 | // Disable mouse panning when a real mouse is connected | ||
| 248 | return Settings::values.mouse_panning && !Settings::values.mouse_enabled; | ||
| 249 | } | ||
| 250 | |||
| 246 | std::vector<Common::ParamPackage> Mouse::GetInputDevices() const { | 251 | std::vector<Common::ParamPackage> Mouse::GetInputDevices() const { |
| 247 | std::vector<Common::ParamPackage> devices; | 252 | std::vector<Common::ParamPackage> devices; |
| 248 | devices.emplace_back(Common::ParamPackage{ | 253 | devices.emplace_back(Common::ParamPackage{ |