diff options
author | german77 <juangerman-13@hotmail.com> | 2023-07-01 02:39:55 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-07-01 02:59:39 +0200 |
commit | da8df6488dbdd164a5b5d00a2e230e4d9550c533 (patch) | |
tree | b555be0331977adbae1a0ef29607c0bd3858b0d7 | |
parent | input_common: Tune mouse controls (diff) | |
download | yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar.gz yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar.bz2 yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar.lz yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar.xz yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.tar.zst yuzu-da8df6488dbdd164a5b5d00a2e230e4d9550c533.zip |
-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) { } 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; 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 @@ </property> <item> <widget class="QPushButton" name="mousePanningButton"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">min-width: 68px;</string> - </property> <property name="text"> <string>Configure</string> </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 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <QCloseEvent> +#include <QMessageBox> #include "common/settings.h" #include "ui_configure_mouse_panning.h" @@ -33,13 +34,20 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue()); if (right_stick_deadzone > 0.0f || right_stick_range != 1.0f) { - ui->warning_label->setText(QString::fromStdString( - "Mouse panning works better with a deadzone of 0% and a range of 100%.\n" - "Current values are " + - std::to_string(static_cast<int>(right_stick_deadzone * 100.0f)) + "% and " + - std::to_string(static_cast<int>(right_stick_range * 100.0f)) + "% respectively.")); - } else { - ui->warning_label->hide(); + const QString right_stick_deadzone_str = + QString::fromStdString(std::to_string(static_cast<int>(right_stick_deadzone * 100.0f))); + const QString right_stick_range_str = + QString::fromStdString(std::to_string(static_cast<int>(right_stick_range * 100.0f))); + + ui->warning_label->setText( + tr("Mouse panning works better with a deadzone of 0% and a range of 100%.\nCurrent " + "values are %1% and %2% respectively.") + .arg(right_stick_deadzone_str, right_stick_range_str)); + } + + if (Settings::values.mouse_enabled) { + ui->warning_label->setText( + tr("Emulated mouse is enabled. This is incompatible with mouse panning.")); } } @@ -69,5 +77,14 @@ void ConfigureMousePanning::ApplyConfiguration() { Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value()); Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value()); + if (Settings::values.mouse_enabled && Settings::values.mouse_panning) { + Settings::values.mouse_panning = false; + QMessageBox::critical( + this, tr("Emulated mouse is enabled"), + tr("Real mouse input and mouse panning are incompatible. Please disable the " + "emulated mouse in input advanced settings to allow mouse panning.")); + return; + } + accept(); } 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 @@ <item> <widget class="QCheckBox" name="enable"> <property name="text"> - <string>Enable</string> + <string>Enable mouse panning</string> </property> <property name="toolTip"> - <string>Can be toggled via a hotkey</string> + <string>Can be toggled via a hotkey. Default hotkey is Ctrl + F9</string> </property> </widget> </item> |