diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_simple.cpp | 140 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_simple.h | 40 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_simple.ui | 97 | ||||
| -rw-r--r-- | src/yuzu/ui_settings.h | 2 |
8 files changed, 293 insertions, 1 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index cfca8f4a8..68448e564 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -31,6 +31,8 @@ add_executable(yuzu | |||
| 31 | configuration/configure_input.h | 31 | configuration/configure_input.h |
| 32 | configuration/configure_input_player.cpp | 32 | configuration/configure_input_player.cpp |
| 33 | configuration/configure_input_player.h | 33 | configuration/configure_input_player.h |
| 34 | configuration/configure_input_simple.cpp | ||
| 35 | configuration/configure_input_simple.h | ||
| 34 | configuration/configure_mouse_advanced.cpp | 36 | configuration/configure_mouse_advanced.cpp |
| 35 | configuration/configure_mouse_advanced.h | 37 | configuration/configure_mouse_advanced.h |
| 36 | configuration/configure_system.cpp | 38 | configuration/configure_system.cpp |
| @@ -85,6 +87,7 @@ set(UIS | |||
| 85 | configuration/configure_graphics.ui | 87 | configuration/configure_graphics.ui |
| 86 | configuration/configure_input.ui | 88 | configuration/configure_input.ui |
| 87 | configuration/configure_input_player.ui | 89 | configuration/configure_input_player.ui |
| 90 | configuration/configure_input_simple.ui | ||
| 88 | configuration/configure_mouse_advanced.ui | 91 | configuration/configure_mouse_advanced.ui |
| 89 | configuration/configure_system.ui | 92 | configuration/configure_system.ui |
| 90 | configuration/configure_touchscreen_advanced.ui | 93 | configuration/configure_touchscreen_advanced.ui |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index ef028cca3..5e0d149cd 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <QSettings> | 5 | #include <QSettings> |
| 6 | #include "common/file_util.h" | 6 | #include "common/file_util.h" |
| 7 | #include "configure_input_simple.h" | ||
| 7 | #include "core/hle/service/acc/profile_manager.h" | 8 | #include "core/hle/service/acc/profile_manager.h" |
| 8 | #include "core/hle/service/hid/controllers/npad.h" | 9 | #include "core/hle/service/hid/controllers/npad.h" |
| 9 | #include "input_common/main.h" | 10 | #include "input_common/main.h" |
| @@ -342,6 +343,13 @@ void Config::ReadTouchscreenValues() { | |||
| 342 | qt_config->endGroup(); | 343 | qt_config->endGroup(); |
| 343 | } | 344 | } |
| 344 | 345 | ||
| 346 | void Config::ApplyDefaultProfileIfInputInvalid() { | ||
| 347 | if (!std::any_of(Settings::values.players.begin(), Settings::values.players.end(), | ||
| 348 | [](const Settings::PlayerInput& in) { return in.connected; })) { | ||
| 349 | ApplyInputProfileConfiguration(UISettings::values.profile_index); | ||
| 350 | } | ||
| 351 | } | ||
| 352 | |||
| 345 | void Config::ReadValues() { | 353 | void Config::ReadValues() { |
| 346 | qt_config->beginGroup("Controls"); | 354 | qt_config->beginGroup("Controls"); |
| 347 | 355 | ||
| @@ -508,6 +516,8 @@ void Config::ReadValues() { | |||
| 508 | UISettings::values.show_console = qt_config->value("showConsole", false).toBool(); | 516 | UISettings::values.show_console = qt_config->value("showConsole", false).toBool(); |
| 509 | UISettings::values.profile_index = qt_config->value("profileIndex", 0).toUInt(); | 517 | UISettings::values.profile_index = qt_config->value("profileIndex", 0).toUInt(); |
| 510 | 518 | ||
| 519 | ApplyDefaultProfileIfInputInvalid(); | ||
| 520 | |||
| 511 | qt_config->endGroup(); | 521 | qt_config->endGroup(); |
| 512 | } | 522 | } |
| 513 | 523 | ||
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index a1c27bbf9..e73ad19bb 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -34,6 +34,7 @@ private: | |||
| 34 | void ReadKeyboardValues(); | 34 | void ReadKeyboardValues(); |
| 35 | void ReadMouseValues(); | 35 | void ReadMouseValues(); |
| 36 | void ReadTouchscreenValues(); | 36 | void ReadTouchscreenValues(); |
| 37 | void ApplyDefaultProfileIfInputInvalid(); | ||
| 37 | 38 | ||
| 38 | void SaveValues(); | 39 | void SaveValues(); |
| 39 | void SavePlayerValues(); | 40 | void SavePlayerValues(); |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 7dadd83c1..ba2b32c4f 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | #include <QColorDialog> | 8 | #include <QColorDialog> |
| 9 | #include <QGridLayout> | ||
| 9 | #include <QMenu> | 10 | #include <QMenu> |
| 10 | #include <QMessageBox> | 11 | #include <QMessageBox> |
| 11 | #include <QTimer> | 12 | #include <QTimer> |
diff --git a/src/yuzu/configuration/configure_input_simple.cpp b/src/yuzu/configuration/configure_input_simple.cpp new file mode 100644 index 000000000..10c804388 --- /dev/null +++ b/src/yuzu/configuration/configure_input_simple.cpp | |||
| @@ -0,0 +1,140 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <array> | ||
| 6 | #include <cstring> | ||
| 7 | #include <functional> | ||
| 8 | #include <tuple> | ||
| 9 | |||
| 10 | #include <QDialog> | ||
| 11 | |||
| 12 | #include "ui_configure_input_simple.h" | ||
| 13 | #include "yuzu/configuration/configure_input.h" | ||
| 14 | #include "yuzu/configuration/configure_input_player.h" | ||
| 15 | #include "yuzu/configuration/configure_input_simple.h" | ||
| 16 | #include "yuzu/ui_settings.h" | ||
| 17 | |||
| 18 | namespace { | ||
| 19 | |||
| 20 | template <typename Dialog, typename... Args> | ||
| 21 | void CallConfigureDialog(ConfigureInputSimple* caller, Args&&... args) { | ||
| 22 | caller->applyConfiguration(); | ||
| 23 | Dialog dialog(caller, std::forward<Args>(args)...); | ||
| 24 | |||
| 25 | const auto res = dialog.exec(); | ||
| 26 | if (res == QDialog::Accepted) { | ||
| 27 | dialog.applyConfiguration(); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | // OnProfileSelect functions should (when applicable): | ||
| 32 | // - Set controller types | ||
| 33 | // - Set controller enabled | ||
| 34 | // - Set docked mode | ||
| 35 | // - Set advanced controller config/enabled (i.e. debug, kbd, mouse, touch) | ||
| 36 | // | ||
| 37 | // OnProfileSelect function should NOT however: | ||
| 38 | // - Reset any button mappings | ||
| 39 | // - Open any dialogs | ||
| 40 | // - Block in any way | ||
| 41 | |||
| 42 | constexpr std::size_t HANDHELD_INDEX = 8; | ||
| 43 | |||
| 44 | void HandheldOnProfileSelect() { | ||
| 45 | Settings::values.players[HANDHELD_INDEX].connected = true; | ||
| 46 | Settings::values.players[HANDHELD_INDEX].type = Settings::ControllerType::DualJoycon; | ||
| 47 | |||
| 48 | for (std::size_t player = 0; player < HANDHELD_INDEX; ++player) { | ||
| 49 | Settings::values.players[player].connected = false; | ||
| 50 | } | ||
| 51 | |||
| 52 | Settings::values.use_docked_mode = false; | ||
| 53 | Settings::values.keyboard_enabled = false; | ||
| 54 | Settings::values.mouse_enabled = false; | ||
| 55 | Settings::values.debug_pad_enabled = false; | ||
| 56 | Settings::values.touchscreen.enabled = true; | ||
| 57 | } | ||
| 58 | |||
| 59 | void DualJoyconsDockedOnProfileSelect() { | ||
| 60 | Settings::values.players[0].connected = true; | ||
| 61 | Settings::values.players[0].type = Settings::ControllerType::DualJoycon; | ||
| 62 | |||
| 63 | for (std::size_t player = 1; player <= HANDHELD_INDEX; ++player) { | ||
| 64 | Settings::values.players[player].connected = false; | ||
| 65 | } | ||
| 66 | |||
| 67 | Settings::values.use_docked_mode = true; | ||
| 68 | Settings::values.keyboard_enabled = false; | ||
| 69 | Settings::values.mouse_enabled = false; | ||
| 70 | Settings::values.debug_pad_enabled = false; | ||
| 71 | Settings::values.touchscreen.enabled = false; | ||
| 72 | } | ||
| 73 | |||
| 74 | // Name, OnProfileSelect (called when selected in drop down), OnConfigure (called when configure | ||
| 75 | // is clicked) | ||
| 76 | using InputProfile = | ||
| 77 | std::tuple<QString, std::function<void()>, std::function<void(ConfigureInputSimple*)>>; | ||
| 78 | |||
| 79 | const std::array<InputProfile, 3> INPUT_PROFILES{{ | ||
| 80 | {ConfigureInputSimple::tr("Single Player - Handheld - Undocked"), HandheldOnProfileSelect, | ||
| 81 | [](ConfigureInputSimple* caller) { | ||
| 82 | CallConfigureDialog<ConfigureInputPlayer>(caller, HANDHELD_INDEX, false); | ||
| 83 | }}, | ||
| 84 | {ConfigureInputSimple::tr("Single Player - Dual Joycons - Docked"), | ||
| 85 | DualJoyconsDockedOnProfileSelect, | ||
| 86 | [](ConfigureInputSimple* caller) { | ||
| 87 | CallConfigureDialog<ConfigureInputPlayer>(caller, 1, false); | ||
| 88 | }}, | ||
| 89 | {ConfigureInputSimple::tr("Custom"), [] {}, CallConfigureDialog<ConfigureInput>}, | ||
| 90 | }}; | ||
| 91 | |||
| 92 | } // namespace | ||
| 93 | |||
| 94 | void ApplyInputProfileConfiguration(int profile_index) { | ||
| 95 | std::get<1>( | ||
| 96 | INPUT_PROFILES.at(std::min(profile_index, static_cast<int>(INPUT_PROFILES.size() - 1))))(); | ||
| 97 | } | ||
| 98 | |||
| 99 | ConfigureInputSimple::ConfigureInputSimple(QWidget* parent) | ||
| 100 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputSimple>()) { | ||
| 101 | ui->setupUi(this); | ||
| 102 | |||
| 103 | for (const auto& profile : INPUT_PROFILES) { | ||
| 104 | ui->profile_combobox->addItem(std::get<0>(profile), std::get<0>(profile)); | ||
| 105 | } | ||
| 106 | |||
| 107 | connect(ui->profile_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | ||
| 108 | &ConfigureInputSimple::OnSelectProfile); | ||
| 109 | connect(ui->profile_configure, &QPushButton::pressed, this, &ConfigureInputSimple::OnConfigure); | ||
| 110 | |||
| 111 | this->loadConfiguration(); | ||
| 112 | } | ||
| 113 | |||
| 114 | ConfigureInputSimple::~ConfigureInputSimple() = default; | ||
| 115 | |||
| 116 | void ConfigureInputSimple::applyConfiguration() { | ||
| 117 | auto index = ui->profile_combobox->currentIndex(); | ||
| 118 | // Make the stored index for "Custom" very large so that if new profiles are added it | ||
| 119 | // doesn't change. | ||
| 120 | if (index >= static_cast<int>(INPUT_PROFILES.size() - 1)) | ||
| 121 | index = std::numeric_limits<int>::max(); | ||
| 122 | |||
| 123 | UISettings::values.profile_index = index; | ||
| 124 | } | ||
| 125 | |||
| 126 | void ConfigureInputSimple::loadConfiguration() { | ||
| 127 | const auto index = UISettings::values.profile_index; | ||
| 128 | if (index >= static_cast<int>(INPUT_PROFILES.size()) || index < 0) | ||
| 129 | ui->profile_combobox->setCurrentIndex(static_cast<int>(INPUT_PROFILES.size() - 1)); | ||
| 130 | else | ||
| 131 | ui->profile_combobox->setCurrentIndex(index); | ||
| 132 | } | ||
| 133 | |||
| 134 | void ConfigureInputSimple::OnSelectProfile(int index) { | ||
| 135 | ApplyInputProfileConfiguration(index); | ||
| 136 | } | ||
| 137 | |||
| 138 | void ConfigureInputSimple::OnConfigure() { | ||
| 139 | std::get<2>(INPUT_PROFILES.at(ui->profile_combobox->currentIndex()))(this); | ||
| 140 | } | ||
diff --git a/src/yuzu/configuration/configure_input_simple.h b/src/yuzu/configuration/configure_input_simple.h new file mode 100644 index 000000000..5b6b69994 --- /dev/null +++ b/src/yuzu/configuration/configure_input_simple.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | |||
| 9 | #include <QWidget> | ||
| 10 | |||
| 11 | class QPushButton; | ||
| 12 | class QString; | ||
| 13 | class QTimer; | ||
| 14 | |||
| 15 | namespace Ui { | ||
| 16 | class ConfigureInputSimple; | ||
| 17 | } | ||
| 18 | |||
| 19 | // Used by configuration loader to apply a profile if the input is invalid. | ||
| 20 | void ApplyInputProfileConfiguration(int profile_index); | ||
| 21 | |||
| 22 | class ConfigureInputSimple : public QWidget { | ||
| 23 | Q_OBJECT | ||
| 24 | |||
| 25 | public: | ||
| 26 | explicit ConfigureInputSimple(QWidget* parent = nullptr); | ||
| 27 | ~ConfigureInputSimple() override; | ||
| 28 | |||
| 29 | /// Save all button configurations to settings file | ||
| 30 | void applyConfiguration(); | ||
| 31 | |||
| 32 | private: | ||
| 33 | /// Load configuration settings. | ||
| 34 | void loadConfiguration(); | ||
| 35 | |||
| 36 | void OnSelectProfile(int index); | ||
| 37 | void OnConfigure(); | ||
| 38 | |||
| 39 | std::unique_ptr<Ui::ConfigureInputSimple> ui; | ||
| 40 | }; | ||
diff --git a/src/yuzu/configuration/configure_input_simple.ui b/src/yuzu/configuration/configure_input_simple.ui new file mode 100644 index 000000000..c4889caa9 --- /dev/null +++ b/src/yuzu/configuration/configure_input_simple.ui | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ConfigureInputSimple</class> | ||
| 4 | <widget class="QWidget" name="ConfigureInputSimple"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>473</width> | ||
| 10 | <height>685</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>ConfigureInputSimple</string> | ||
| 15 | </property> | ||
| 16 | <layout class="QVBoxLayout" name="verticalLayout_5"> | ||
| 17 | <item> | ||
| 18 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 19 | <item> | ||
| 20 | <widget class="QGroupBox" name="gridGroupBox"> | ||
| 21 | <property name="title"> | ||
| 22 | <string>Profile</string> | ||
| 23 | </property> | ||
| 24 | <layout class="QGridLayout" name="gridLayout"> | ||
| 25 | <item row="1" column="2"> | ||
| 26 | <widget class="QPushButton" name="profile_configure"> | ||
| 27 | <property name="text"> | ||
| 28 | <string>Configure</string> | ||
| 29 | </property> | ||
| 30 | </widget> | ||
| 31 | </item> | ||
| 32 | <item row="1" column="0"> | ||
| 33 | <spacer name="horizontalSpacer"> | ||
| 34 | <property name="orientation"> | ||
| 35 | <enum>Qt::Horizontal</enum> | ||
| 36 | </property> | ||
| 37 | <property name="sizeHint" stdset="0"> | ||
| 38 | <size> | ||
| 39 | <width>40</width> | ||
| 40 | <height>20</height> | ||
| 41 | </size> | ||
| 42 | </property> | ||
| 43 | </spacer> | ||
| 44 | </item> | ||
| 45 | <item row="1" column="3"> | ||
| 46 | <spacer name="horizontalSpacer_2"> | ||
| 47 | <property name="orientation"> | ||
| 48 | <enum>Qt::Horizontal</enum> | ||
| 49 | </property> | ||
| 50 | <property name="sizeHint" stdset="0"> | ||
| 51 | <size> | ||
| 52 | <width>40</width> | ||
| 53 | <height>20</height> | ||
| 54 | </size> | ||
| 55 | </property> | ||
| 56 | </spacer> | ||
| 57 | </item> | ||
| 58 | <item row="1" column="1"> | ||
| 59 | <widget class="QComboBox" name="profile_combobox"> | ||
| 60 | <property name="minimumSize"> | ||
| 61 | <size> | ||
| 62 | <width>250</width> | ||
| 63 | <height>0</height> | ||
| 64 | </size> | ||
| 65 | </property> | ||
| 66 | </widget> | ||
| 67 | </item> | ||
| 68 | <item row="0" column="1" colspan="2"> | ||
| 69 | <widget class="QLabel" name="label"> | ||
| 70 | <property name="text"> | ||
| 71 | <string>Choose a controller configuration:</string> | ||
| 72 | </property> | ||
| 73 | </widget> | ||
| 74 | </item> | ||
| 75 | </layout> | ||
| 76 | </widget> | ||
| 77 | </item> | ||
| 78 | </layout> | ||
| 79 | </item> | ||
| 80 | <item> | ||
| 81 | <spacer name="verticalSpacer"> | ||
| 82 | <property name="orientation"> | ||
| 83 | <enum>Qt::Vertical</enum> | ||
| 84 | </property> | ||
| 85 | <property name="sizeHint" stdset="0"> | ||
| 86 | <size> | ||
| 87 | <width>20</width> | ||
| 88 | <height>40</height> | ||
| 89 | </size> | ||
| 90 | </property> | ||
| 91 | </spacer> | ||
| 92 | </item> | ||
| 93 | </layout> | ||
| 94 | </widget> | ||
| 95 | <resources/> | ||
| 96 | <connections/> | ||
| 97 | </ui> | ||
diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index 035192aeb..2f434eab0 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h | |||
| @@ -59,7 +59,7 @@ struct Values { | |||
| 59 | bool show_console; | 59 | bool show_console; |
| 60 | 60 | ||
| 61 | // Controllers | 61 | // Controllers |
| 62 | uint32_t profile_index; | 62 | int profile_index; |
| 63 | 63 | ||
| 64 | // Game List | 64 | // Game List |
| 65 | bool show_unknown; | 65 | bool show_unknown; |