summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/mouse.cpp17
-rw-r--r--src/input_common/drivers/mouse.h2
2 files changed, 13 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) {
}
void Mouse::UpdateStickInput() {
- if (!Settings::values.mouse_panning) {
+ if (!IsMousePanningEnabled()) {
return;
}
@@ -111,8 +111,8 @@ void Mouse::UpdateStickInput() {
}
void Mouse::UpdateMotionInput() {
- const float sensitivity = Settings::values.mouse_panning ? default_motion_panning_sensitivity
- : default_motion_sensitivity;
+ const float sensitivity =
+ IsMousePanningEnabled() ? default_motion_panning_sensitivity : default_motion_sensitivity;
const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x +
last_motion_change.y * last_motion_change.y);
@@ -134,7 +134,7 @@ void Mouse::UpdateMotionInput() {
.delta_timestamp = update_time * 1000,
};
- if (Settings::values.mouse_panning) {
+ if (IsMousePanningEnabled()) {
last_motion_change.x = 0;
last_motion_change.y = 0;
}
@@ -144,7 +144,7 @@ void Mouse::UpdateMotionInput() {
}
void Mouse::Move(int x, int y, int center_x, int center_y) {
- if (Settings::values.mouse_panning) {
+ if (IsMousePanningEnabled()) {
const auto mouse_change =
(Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>();
const float x_sensitivity =
@@ -219,7 +219,7 @@ void Mouse::ReleaseButton(MouseButton button) {
SetButton(real_mouse_identifier, static_cast<int>(button), false);
SetButton(touch_identifier, static_cast<int>(button), false);
- if (!Settings::values.mouse_panning) {
+ if (!IsMousePanningEnabled()) {
SetAxis(identifier, mouse_axis_x, 0);
SetAxis(identifier, mouse_axis_y, 0);
}
@@ -243,6 +243,11 @@ void Mouse::ReleaseAllButtons() {
button_pressed = false;
}
+bool Mouse::IsMousePanningEnabled() {
+ // Disable mouse panning when a real mouse is connected
+ return Settings::values.mouse_panning && !Settings::values.mouse_enabled;
+}
+
std::vector<Common::ParamPackage> Mouse::GetInputDevices() const {
std::vector<Common::ParamPackage> devices;
devices.emplace_back(Common::ParamPackage{
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h
index 0e8edcce1..2b93a40b9 100644
--- a/src/input_common/drivers/mouse.h
+++ b/src/input_common/drivers/mouse.h
@@ -99,6 +99,8 @@ private:
void UpdateStickInput();
void UpdateMotionInput();
+ bool IsMousePanningEnabled();
+
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
Common::Vec2<int> mouse_origin;