diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 17 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 15 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_mouse_panning.cpp | 31 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_mouse_panning.ui | 4 |
5 files changed, 39 insertions, 30 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{ |
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: | |||
| 99 | void UpdateStickInput(); | 99 | void UpdateStickInput(); |
| 100 | void UpdateMotionInput(); | 100 | void UpdateMotionInput(); |
| 101 | 101 | ||
| 102 | bool IsMousePanningEnabled(); | ||
| 103 | |||
| 102 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; | 104 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; |
| 103 | 105 | ||
| 104 | Common::Vec2<int> mouse_origin; | 106 | Common::Vec2<int> mouse_origin; |
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui index 43f6c7b50..611a79477 100644 --- a/src/yuzu/configuration/configure_input_player.ui +++ b/src/yuzu/configuration/configure_input_player.ui | |||
| @@ -3105,21 +3105,6 @@ | |||
| 3105 | </property> | 3105 | </property> |
| 3106 | <item> | 3106 | <item> |
| 3107 | <widget class="QPushButton" name="mousePanningButton"> | 3107 | <widget class="QPushButton" name="mousePanningButton"> |
| 3108 | <property name="minimumSize"> | ||
| 3109 | <size> | ||
| 3110 | <width>68</width> | ||
| 3111 | <height>0</height> | ||
| 3112 | </size> | ||
| 3113 | </property> | ||
| 3114 | <property name="maximumSize"> | ||
| 3115 | <size> | ||
| 3116 | <width>68</width> | ||
| 3117 | <height>16777215</height> | ||
| 3118 | </size> | ||
| 3119 | </property> | ||
| 3120 | <property name="styleSheet"> | ||
| 3121 | <string notr="true">min-width: 68px;</string> | ||
| 3122 | </property> | ||
| 3123 | <property name="text"> | 3108 | <property name="text"> |
| 3124 | <string>Configure</string> | 3109 | <string>Configure</string> |
| 3125 | </property> | 3110 | </property> |
diff --git a/src/yuzu/configuration/configure_mouse_panning.cpp b/src/yuzu/configuration/configure_mouse_panning.cpp index b3386347e..e37c546b0 100644 --- a/src/yuzu/configuration/configure_mouse_panning.cpp +++ b/src/yuzu/configuration/configure_mouse_panning.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <QCloseEvent> | 4 | #include <QCloseEvent> |
| 5 | #include <QMessageBox> | ||
| 5 | 6 | ||
| 6 | #include "common/settings.h" | 7 | #include "common/settings.h" |
| 7 | #include "ui_configure_mouse_panning.h" | 8 | #include "ui_configure_mouse_panning.h" |
| @@ -33,13 +34,20 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r | |||
| 33 | ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue()); | 34 | ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue()); |
| 34 | 35 | ||
| 35 | if (right_stick_deadzone > 0.0f || right_stick_range != 1.0f) { | 36 | if (right_stick_deadzone > 0.0f || right_stick_range != 1.0f) { |
| 36 | ui->warning_label->setText(QString::fromStdString( | 37 | const QString right_stick_deadzone_str = |
| 37 | "Mouse panning works better with a deadzone of 0% and a range of 100%.\n" | 38 | QString::fromStdString(std::to_string(static_cast<int>(right_stick_deadzone * 100.0f))); |
| 38 | "Current values are " + | 39 | const QString right_stick_range_str = |
| 39 | std::to_string(static_cast<int>(right_stick_deadzone * 100.0f)) + "% and " + | 40 | QString::fromStdString(std::to_string(static_cast<int>(right_stick_range * 100.0f))); |
| 40 | std::to_string(static_cast<int>(right_stick_range * 100.0f)) + "% respectively.")); | 41 | |
| 41 | } else { | 42 | ui->warning_label->setText( |
| 42 | ui->warning_label->hide(); | 43 | tr("Mouse panning works better with a deadzone of 0% and a range of 100%.\nCurrent " |
| 44 | "values are %1% and %2% respectively.") | ||
| 45 | .arg(right_stick_deadzone_str, right_stick_range_str)); | ||
| 46 | } | ||
| 47 | |||
| 48 | if (Settings::values.mouse_enabled) { | ||
| 49 | ui->warning_label->setText( | ||
| 50 | tr("Emulated mouse is enabled. This is incompatible with mouse panning.")); | ||
| 43 | } | 51 | } |
| 44 | } | 52 | } |
| 45 | 53 | ||
| @@ -69,5 +77,14 @@ void ConfigureMousePanning::ApplyConfiguration() { | |||
| 69 | Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value()); | 77 | Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value()); |
| 70 | Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value()); | 78 | Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value()); |
| 71 | 79 | ||
| 80 | if (Settings::values.mouse_enabled && Settings::values.mouse_panning) { | ||
| 81 | Settings::values.mouse_panning = false; | ||
| 82 | QMessageBox::critical( | ||
| 83 | this, tr("Emulated mouse is enabled"), | ||
| 84 | tr("Real mouse input and mouse panning are incompatible. Please disable the " | ||
| 85 | "emulated mouse in input advanced settings to allow mouse panning.")); | ||
| 86 | return; | ||
| 87 | } | ||
| 88 | |||
| 72 | accept(); | 89 | accept(); |
| 73 | } | 90 | } |
diff --git a/src/yuzu/configuration/configure_mouse_panning.ui b/src/yuzu/configuration/configure_mouse_panning.ui index 33615be54..84fb7ee80 100644 --- a/src/yuzu/configuration/configure_mouse_panning.ui +++ b/src/yuzu/configuration/configure_mouse_panning.ui | |||
| @@ -9,10 +9,10 @@ | |||
| 9 | <item> | 9 | <item> |
| 10 | <widget class="QCheckBox" name="enable"> | 10 | <widget class="QCheckBox" name="enable"> |
| 11 | <property name="text"> | 11 | <property name="text"> |
| 12 | <string>Enable</string> | 12 | <string>Enable mouse panning</string> |
| 13 | </property> | 13 | </property> |
| 14 | <property name="toolTip"> | 14 | <property name="toolTip"> |
| 15 | <string>Can be toggled via a hotkey</string> | 15 | <string>Can be toggled via a hotkey. Default hotkey is Ctrl + F9</string> |
| 16 | </property> | 16 | </property> |
| 17 | </widget> | 17 | </widget> |
| 18 | </item> | 18 | </item> |