diff options
| author | 2020-12-08 10:30:21 +0800 | |
|---|---|---|
| committer | 2020-12-08 10:30:21 +0800 | |
| commit | 607bb8d14b3713afde6ff25e87678842fc28c2eb (patch) | |
| tree | 6dcdab147b659307276d64bd6ba6af6efc0f88bb /src | |
| parent | Merge pull request #5164 from lioncash/contains (diff) | |
| parent | Disable analog joystick from buttons by default (diff) | |
| download | yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.gz yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.xz yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.zip | |
Merge pull request #5020 from german77/AnalogfromButtonFix
Disable analog joystick from buttons by default
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/settings.h | 2 | ||||
| -rwxr-xr-x | src/input_common/analog_from_button.cpp | 22 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_advanced.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_advanced.ui | 31 |
5 files changed, 52 insertions, 10 deletions
diff --git a/src/core/settings.h b/src/core/settings.h index 8e076f7ef..d5f8d2b7e 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -180,6 +180,8 @@ struct Values { | |||
| 180 | std::string motion_device; | 180 | std::string motion_device; |
| 181 | std::string udp_input_servers; | 181 | std::string udp_input_servers; |
| 182 | 182 | ||
| 183 | bool emulate_analog_keyboard; | ||
| 184 | |||
| 183 | bool mouse_enabled; | 185 | bool mouse_enabled; |
| 184 | std::string mouse_device; | 186 | std::string mouse_device; |
| 185 | MouseButtonsRaw mouse_buttons; | 187 | MouseButtonsRaw mouse_buttons; |
diff --git a/src/input_common/analog_from_button.cpp b/src/input_common/analog_from_button.cpp index d748c1c04..40b516f85 100755 --- a/src/input_common/analog_from_button.cpp +++ b/src/input_common/analog_from_button.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <cmath> | 6 | #include <cmath> |
| 7 | #include <thread> | 7 | #include <thread> |
| 8 | #include "common/math_util.h" | 8 | #include "common/math_util.h" |
| 9 | #include "core/settings.h" | ||
| 9 | #include "input_common/analog_from_button.h" | 10 | #include "input_common/analog_from_button.h" |
| 10 | 11 | ||
| 11 | namespace InputCommon { | 12 | namespace InputCommon { |
| @@ -112,7 +113,26 @@ public: | |||
| 112 | } | 113 | } |
| 113 | 114 | ||
| 114 | std::tuple<float, float> GetStatus() const override { | 115 | std::tuple<float, float> GetStatus() const override { |
| 115 | return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); | 116 | if (Settings::values.emulate_analog_keyboard) { |
| 117 | return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); | ||
| 118 | } | ||
| 119 | constexpr float SQRT_HALF = 0.707106781f; | ||
| 120 | int x = 0, y = 0; | ||
| 121 | if (right->GetStatus()) { | ||
| 122 | ++x; | ||
| 123 | } | ||
| 124 | if (left->GetStatus()) { | ||
| 125 | --x; | ||
| 126 | } | ||
| 127 | if (up->GetStatus()) { | ||
| 128 | ++y; | ||
| 129 | } | ||
| 130 | if (down->GetStatus()) { | ||
| 131 | --y; | ||
| 132 | } | ||
| 133 | const float coef = modifier->GetStatus() ? modifier_scale : 1.0f; | ||
| 134 | return std::make_tuple(static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF), | ||
| 135 | static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF)); | ||
| 116 | } | 136 | } |
| 117 | 137 | ||
| 118 | bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override { | 138 | bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override { |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index fcc38b3af..0ec5b861a 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -511,6 +511,9 @@ void Config::ReadControlValues() { | |||
| 511 | ReadTouchscreenValues(); | 511 | ReadTouchscreenValues(); |
| 512 | ReadMotionTouchValues(); | 512 | ReadMotionTouchValues(); |
| 513 | 513 | ||
| 514 | Settings::values.emulate_analog_keyboard = | ||
| 515 | ReadSetting(QStringLiteral("emulate_analog_keyboard"), false).toBool(); | ||
| 516 | |||
| 514 | ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), false); | 517 | ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), false); |
| 515 | ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"), | 518 | ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"), |
| 516 | true); | 519 | true); |
| @@ -1186,6 +1189,8 @@ void Config::SaveControlValues() { | |||
| 1186 | QString::fromStdString(Settings::values.touch_device), | 1189 | QString::fromStdString(Settings::values.touch_device), |
| 1187 | QStringLiteral("engine:emu_window")); | 1190 | QStringLiteral("engine:emu_window")); |
| 1188 | WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false); | 1191 | WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false); |
| 1192 | WriteSetting(QStringLiteral("emulate_analog_keyboard"), | ||
| 1193 | Settings::values.emulate_analog_keyboard, false); | ||
| 1189 | 1194 | ||
| 1190 | qt_config->endGroup(); | 1195 | qt_config->endGroup(); |
| 1191 | } | 1196 | } |
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index abaf03630..4e557bc6f 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp | |||
| @@ -121,6 +121,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() { | |||
| 121 | Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); | 121 | Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); |
| 122 | Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); | 122 | Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); |
| 123 | Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); | 123 | Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); |
| 124 | Settings::values.emulate_analog_keyboard = ui->emulate_analog_keyboard->isChecked(); | ||
| 124 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); | 125 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); |
| 125 | } | 126 | } |
| 126 | 127 | ||
| @@ -147,6 +148,7 @@ void ConfigureInputAdvanced::LoadConfiguration() { | |||
| 147 | ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled); | 148 | ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled); |
| 148 | ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); | 149 | ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); |
| 149 | ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); | 150 | ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); |
| 151 | ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard); | ||
| 150 | ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); | 152 | ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); |
| 151 | 153 | ||
| 152 | UpdateUIEnabled(); | 154 | UpdateUIEnabled(); |
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index a880a7c68..f207e5d3b 100644 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui | |||
| @@ -2546,14 +2546,27 @@ | |||
| 2546 | </property> | 2546 | </property> |
| 2547 | </widget> | 2547 | </widget> |
| 2548 | </item> | 2548 | </item> |
| 2549 | <item row="4" column="2"> | 2549 | <item row="1" column="0"> |
| 2550 | <widget class="QCheckBox" name="emulate_analog_keyboard"> | ||
| 2551 | <property name="minimumSize"> | ||
| 2552 | <size> | ||
| 2553 | <width>0</width> | ||
| 2554 | <height>23</height> | ||
| 2555 | </size> | ||
| 2556 | </property> | ||
| 2557 | <property name="text"> | ||
| 2558 | <string>Emulate Analog with Keyboard Input</string> | ||
| 2559 | </property> | ||
| 2560 | </widget> | ||
| 2561 | </item> | ||
| 2562 | <item row="5" column="2"> | ||
| 2550 | <widget class="QPushButton" name="touchscreen_advanced"> | 2563 | <widget class="QPushButton" name="touchscreen_advanced"> |
| 2551 | <property name="text"> | 2564 | <property name="text"> |
| 2552 | <string>Advanced</string> | 2565 | <string>Advanced</string> |
| 2553 | </property> | 2566 | </property> |
| 2554 | </widget> | 2567 | </widget> |
| 2555 | </item> | 2568 | </item> |
| 2556 | <item row="1" column="1"> | 2569 | <item row="2" column="1"> |
| 2557 | <spacer name="horizontalSpacer_8"> | 2570 | <spacer name="horizontalSpacer_8"> |
| 2558 | <property name="orientation"> | 2571 | <property name="orientation"> |
| 2559 | <enum>Qt::Horizontal</enum> | 2572 | <enum>Qt::Horizontal</enum> |
| @@ -2569,21 +2582,21 @@ | |||
| 2569 | </property> | 2582 | </property> |
| 2570 | </spacer> | 2583 | </spacer> |
| 2571 | </item> | 2584 | </item> |
| 2572 | <item row="1" column="2"> | 2585 | <item row="2" column="2"> |
| 2573 | <widget class="QPushButton" name="mouse_advanced"> | 2586 | <widget class="QPushButton" name="mouse_advanced"> |
| 2574 | <property name="text"> | 2587 | <property name="text"> |
| 2575 | <string>Advanced</string> | 2588 | <string>Advanced</string> |
| 2576 | </property> | 2589 | </property> |
| 2577 | </widget> | 2590 | </widget> |
| 2578 | </item> | 2591 | </item> |
| 2579 | <item row="4" column="0"> | 2592 | <item row="5" column="0"> |
| 2580 | <widget class="QCheckBox" name="touchscreen_enabled"> | 2593 | <widget class="QCheckBox" name="touchscreen_enabled"> |
| 2581 | <property name="text"> | 2594 | <property name="text"> |
| 2582 | <string>Touchscreen</string> | 2595 | <string>Touchscreen</string> |
| 2583 | </property> | 2596 | </property> |
| 2584 | </widget> | 2597 | </widget> |
| 2585 | </item> | 2598 | </item> |
| 2586 | <item row="1" column="0"> | 2599 | <item row="2" column="0"> |
| 2587 | <widget class="QCheckBox" name="mouse_enabled"> | 2600 | <widget class="QCheckBox" name="mouse_enabled"> |
| 2588 | <property name="minimumSize"> | 2601 | <property name="minimumSize"> |
| 2589 | <size> | 2602 | <size> |
| @@ -2596,28 +2609,28 @@ | |||
| 2596 | </property> | 2609 | </property> |
| 2597 | </widget> | 2610 | </widget> |
| 2598 | </item> | 2611 | </item> |
| 2599 | <item row="6" column="0"> | 2612 | <item row="7" column="0"> |
| 2600 | <widget class="QLabel" name="motion_touch"> | 2613 | <widget class="QLabel" name="motion_touch"> |
| 2601 | <property name="text"> | 2614 | <property name="text"> |
| 2602 | <string>Motion / Touch</string> | 2615 | <string>Motion / Touch</string> |
| 2603 | </property> | 2616 | </property> |
| 2604 | </widget> | 2617 | </widget> |
| 2605 | </item> | 2618 | </item> |
| 2606 | <item row="6" column="2"> | 2619 | <item row="7" column="2"> |
| 2607 | <widget class="QPushButton" name="buttonMotionTouch"> | 2620 | <widget class="QPushButton" name="buttonMotionTouch"> |
| 2608 | <property name="text"> | 2621 | <property name="text"> |
| 2609 | <string>Configure</string> | 2622 | <string>Configure</string> |
| 2610 | </property> | 2623 | </property> |
| 2611 | </widget> | 2624 | </widget> |
| 2612 | </item> | 2625 | </item> |
| 2613 | <item row="5" column="0"> | 2626 | <item row="6" column="0"> |
| 2614 | <widget class="QCheckBox" name="debug_enabled"> | 2627 | <widget class="QCheckBox" name="debug_enabled"> |
| 2615 | <property name="text"> | 2628 | <property name="text"> |
| 2616 | <string>Debug Controller</string> | 2629 | <string>Debug Controller</string> |
| 2617 | </property> | 2630 | </property> |
| 2618 | </widget> | 2631 | </widget> |
| 2619 | </item> | 2632 | </item> |
| 2620 | <item row="5" column="2"> | 2633 | <item row="6" column="2"> |
| 2621 | <widget class="QPushButton" name="debug_configure"> | 2634 | <widget class="QPushButton" name="debug_configure"> |
| 2622 | <property name="text"> | 2635 | <property name="text"> |
| 2623 | <string>Configure</string> | 2636 | <string>Configure</string> |