diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-11-04 16:18:59 +0100 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-11-19 05:22:36 +0100 |
commit | e58c951a59d7f3851fd3a71ae6f99933fba8cdbb (patch) | |
tree | c4a90063f114439c9860db718d1fd3d3ad58f55a /src | |
parent | hid: Use player-defined controller type as PREFERRED_CONTROLLER (diff) | |
download | yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar.gz yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar.bz2 yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar.lz yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar.xz yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.tar.zst yuzu-e58c951a59d7f3851fd3a71ae6f99933fba8cdbb.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/yuzu/configuration/config.cpp | 8 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 36 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.h | 1 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.ui | 9 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 113 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input.h | 7 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input.ui | 120 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 1 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_mouse_advanced.cpp | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_mouse_advanced.h | 1 |
11 files changed, 148 insertions, 152 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 652f6a0b7..e24ed5f2b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -5,6 +5,7 @@ #include <QSettings> #include "common/file_util.h" #include "core/hle/service/acc/profile_manager.h" +#include "core/hle/service/hid/controllers/npad.h" #include "input_common/main.h" #include "yuzu/configuration/config.h" #include "yuzu/ui_settings.h" @@ -262,8 +263,11 @@ void Config::ReadPlayerValues() { } } - std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), - [](const auto& player) { return player.connected; }); + std::stable_partition( + Settings::values.players.begin(), + Settings::values.players.begin() + + Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD), + [](const auto& player) { return player.connected; }); } void Config::ReadDebugValues() { diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index c22742007..92a441308 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -3,10 +3,6 @@ // Refer to the license.txt file included. #include "core/core.h" -#include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_ae.h" -#include "core/hle/service/am/applet_oe.h" -#include "core/hle/service/sm/sm.h" #include "core/settings.h" #include "ui_configure_general.h" #include "yuzu/configuration/configure_general.h" @@ -36,7 +32,6 @@ void ConfigureGeneral::setConfiguration() { ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit); - ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); ui->enable_nfc->setChecked(Settings::values.enable_nfc); } @@ -44,33 +39,6 @@ void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) { ui->widget->Populate(registry); } -void ConfigureGeneral::OnDockedModeChanged(bool last_state, bool new_state) { - if (last_state == new_state) { - return; - } - - Core::System& system{Core::System::GetInstance()}; - if (!system.IsPoweredOn()) { - return; - } - Service::SM::ServiceManager& sm = system.ServiceManager(); - - // Message queue is shared between these services, we just need to signal an operation - // change to one and it will handle both automatically - auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); - auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); - bool has_signalled = false; - - if (applet_oe != nullptr) { - applet_oe->GetMessageQueue()->OperationModeChanged(); - has_signalled = true; - } - - if (applet_ae != nullptr && !has_signalled) { - applet_ae->GetMessageQueue()->OperationModeChanged(); - } -} - void ConfigureGeneral::applyConfiguration() { UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); @@ -78,9 +46,5 @@ void ConfigureGeneral::applyConfiguration() { ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); - const bool pre_docked_mode = Settings::values.use_docked_mode; - Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); - OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode); - Settings::values.enable_nfc = ui->enable_nfc->isChecked(); } diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 2210d48da..4770034cc 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h @@ -25,7 +25,6 @@ public: private: void setConfiguration(); - void OnDockedModeChanged(bool last_state, bool new_state); std::unique_ptr<Ui::ConfigureGeneral> ui; }; diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index b82fffde8..bf37446c6 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>300</width> - <height>377</height> + <height>407</height> </rect> </property> <property name="windowTitle"> @@ -72,13 +72,6 @@ <item> <layout class="QVBoxLayout" name="EmulationVerticalLayout"> <item> - <widget class="QCheckBox" name="use_docked_mode"> - <property name="text"> - <string>Enable docked mode</string> - </property> - </widget> - </item> - <item> <widget class="QCheckBox" name="enable_nfc"> <property name="text"> <string>Enable NFC</string> diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index a52abdd8f..25066d4d9 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -11,7 +11,11 @@ #include "common/param_package.h" #include "configuration/configure_touchscreen_advanced.h" #include "core/core.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/am/applet_ae.h" +#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/hid/controllers/npad.h" +#include "core/hle/service/sm/sm.h" #include "input_common/main.h" #include "ui_configure_input.h" #include "ui_configure_input_player.h" @@ -26,24 +30,19 @@ ConfigureInput::ConfigureInput(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()) { ui->setupUi(this); - players_enabled = { - ui->player1_checkbox, ui->player2_checkbox, ui->player3_checkbox, ui->player4_checkbox, - ui->player5_checkbox, ui->player6_checkbox, ui->player7_checkbox, ui->player8_checkbox, - }; - - player_controller = { + players_controller = { ui->player1_combobox, ui->player2_combobox, ui->player3_combobox, ui->player4_combobox, ui->player5_combobox, ui->player6_combobox, ui->player7_combobox, ui->player8_combobox, }; - player_configure = { + players_configure = { ui->player1_configure, ui->player2_configure, ui->player3_configure, ui->player4_configure, ui->player5_configure, ui->player6_configure, ui->player7_configure, ui->player8_configure, }; - for (auto* controller_box : player_controller) { - controller_box->addItems( - {"Pro Controller", "Dual Joycons", "Single Right Joycon", "Single Left Joycon"}); + for (auto* controller_box : players_controller) { + controller_box->addItems({"None", "Pro Controller", "Dual Joycons", "Single Right Joycon", + "Single Left Joycon"}); } this->loadConfiguration(); @@ -52,8 +51,9 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(ui->restore_defaults_button, &QPushButton::pressed, this, &ConfigureInput::restoreDefaults); - for (auto* enabled : players_enabled) - connect(enabled, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); + for (auto* enabled : players_controller) + connect(enabled, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &ConfigureInput::updateUIEnabled); connect(ui->use_docked_mode, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); connect(ui->handheld_connected, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); @@ -63,8 +63,8 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this, &ConfigureInput::updateUIEnabled); - for (std::size_t i = 0; i < player_configure.size(); ++i) { - connect(player_configure[i], &QPushButton::pressed, this, + for (std::size_t i = 0; i < players_configure.size(); ++i) { + connect(players_configure[i], &QPushButton::pressed, this, [this, i]() { CallConfigureDialog<ConfigureInputPlayer>(i, false); }); } @@ -79,8 +79,6 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(ui->touchscreen_advanced, &QPushButton::pressed, this, [this]() { CallConfigureDialog<ConfigureTouchscreenAdvanced>(); }); - - ui->use_docked_mode->setEnabled(!Core::System::GetInstance().IsPoweredOn()); } template <typename Dialog, typename... Args> @@ -94,14 +92,50 @@ void ConfigureInput::CallConfigureDialog(Args&&... args) { } } +void ConfigureInput::OnDockedModeChanged(bool last_state, bool new_state) { + if (last_state == new_state) { + return; + } + + Core::System& system{Core::System::GetInstance()}; + if (!system.IsPoweredOn()) { + return; + } + Service::SM::ServiceManager& sm = system.ServiceManager(); + + // Message queue is shared between these services, we just need to signal an operation + // change to one and it will handle both automatically + auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); + auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); + bool has_signalled = false; + + if (applet_oe != nullptr) { + applet_oe->GetMessageQueue()->OperationModeChanged(); + has_signalled = true; + } + + if (applet_ae != nullptr && !has_signalled) { + applet_ae->GetMessageQueue()->OperationModeChanged(); + } +} + void ConfigureInput::applyConfiguration() { - for (std::size_t i = 0; i < players_enabled.size(); ++i) { - Settings::values.players[i].connected = players_enabled[i]->isChecked(); - Settings::values.players[i].type = - static_cast<Settings::ControllerType>(player_controller[i]->currentIndex()); + for (std::size_t i = 0; i < players_controller.size(); ++i) { + const auto controller_type_index = players_controller[i]->currentIndex(); + + Settings::values.players[i].connected = controller_type_index != 0; + + if (controller_type_index > 0) { + Settings::values.players[i].type = + static_cast<Settings::ControllerType>(controller_type_index - 1); + } else { + Settings::values.players[i].type = Settings::ControllerType::DualJoycon; + } } + const bool pre_docked_mode = Settings::values.use_docked_mode; Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); + OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode); Settings::values .players[Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD)] .connected = ui->handheld_connected->isChecked(); @@ -112,20 +146,17 @@ void ConfigureInput::applyConfiguration() { } void ConfigureInput::updateUIEnabled() { - for (std::size_t i = 0; i < players_enabled.size(); ++i) { - const auto enabled = players_enabled[i]->checkState() == Qt::Checked; - - player_controller[i]->setEnabled(enabled); - player_configure[i]->setEnabled(enabled); - } - bool hit_disabled = false; - for (auto* player : players_enabled) { + for (auto* player : players_controller) { player->setDisabled(hit_disabled); - if (!player->isChecked()) + if (!hit_disabled && player->currentIndex() == 0) hit_disabled = true; } + for (std::size_t i = 0; i < players_controller.size(); ++i) { + players_configure[i]->setEnabled(players_controller[i]->currentIndex() != 0); + } + ui->handheld_connected->setEnabled(!ui->use_docked_mode->isChecked()); ui->handheld_configure->setEnabled(ui->handheld_connected->isChecked() && !ui->use_docked_mode->isChecked()); @@ -135,12 +166,16 @@ void ConfigureInput::updateUIEnabled() { } void ConfigureInput::loadConfiguration() { - std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), - [](const auto& player) { return player.connected; }); - - for (std::size_t i = 0; i < players_enabled.size(); ++i) { - players_enabled[i]->setChecked(Settings::values.players[i].connected); - player_controller[i]->setCurrentIndex(static_cast<u8>(Settings::values.players[i].type)); + std::stable_partition( + Settings::values.players.begin(), + Settings::values.players.begin() + + Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD), + [](const auto& player) { return player.connected; }); + + for (std::size_t i = 0; i < players_controller.size(); ++i) { + const auto connected = Settings::values.players[i].connected; + players_controller[i]->setCurrentIndex( + connected ? static_cast<u8>(Settings::values.players[i].type) + 1 : 0); } ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); @@ -157,12 +192,10 @@ void ConfigureInput::loadConfiguration() { } void ConfigureInput::restoreDefaults() { - players_enabled[0]->setCheckState(Qt::Checked); - player_controller[0]->setCurrentIndex(1); + players_controller[0]->setCurrentIndex(2); - for (std::size_t i = 1; i < players_enabled.size(); ++i) { - players_enabled[i]->setCheckState(Qt::Unchecked); - player_controller[i]->setCurrentIndex(0); + for (std::size_t i = 1; i < players_controller.size(); ++i) { + players_controller[i]->setCurrentIndex(0); } ui->use_docked_mode->setCheckState(Qt::Unchecked); diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index 51b8e609c..29a8a03f8 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h @@ -43,6 +43,8 @@ private: template <typename Dialog, typename... Args> void CallConfigureDialog(Args&&... args); + void OnDockedModeChanged(bool last_state, bool new_state); + /// Load configuration settings. void loadConfiguration(); /// Restore all buttons to their default values. @@ -50,7 +52,6 @@ private: std::unique_ptr<Ui::ConfigureInput> ui; - std::array<QCheckBox*, 8> players_enabled; - std::array<QComboBox*, 8> player_controller; - std::array<QPushButton*, 8> player_configure; + std::array<QComboBox*, 8> players_controller; + std::array<QPushButton*, 8> players_configure; }; diff --git a/src/yuzu/configuration/configure_input.ui b/src/yuzu/configuration/configure_input.ui index f12896b47..8beae959e 100644 --- a/src/yuzu/configuration/configure_input.ui +++ b/src/yuzu/configuration/configure_input.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>473</width> - <height>677</height> + <height>685</height> </rect> </property> <property name="windowTitle"> @@ -49,62 +49,6 @@ </property> </widget> </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="player1_checkbox"> - <property name="text"> - <string>Player 1</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QCheckBox" name="player7_checkbox"> - <property name="text"> - <string>Player 7</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="player4_checkbox"> - <property name="text"> - <string>Player 4</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QCheckBox" name="player5_checkbox"> - <property name="text"> - <string>Player 5</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QCheckBox" name="player6_checkbox"> - <property name="text"> - <string>Player 6</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="QCheckBox" name="player8_checkbox"> - <property name="text"> - <string>Player 8</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QCheckBox" name="player3_checkbox"> - <property name="text"> - <string>Player 3</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="player2_checkbox"> - <property name="text"> - <string>Player 2</string> - </property> - </widget> - </item> <item row="2" column="2"> <widget class="QComboBox" name="player2_combobox"> <property name="minimumSize"> @@ -250,13 +194,65 @@ </property> </spacer> </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_2"> + <item row="1" column="1"> + <widget class="QLabel" name="label_3"> + <property name="minimumSize"> + <size> + <width>55</width> + <height>0</height> + </size> + </property> <property name="text"> - <string>Enabled</string> + <string>Player 1</string> </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Player 2</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Player 3</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Player 4</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Player 5</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Player 6</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Player 7</string> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Player 8</string> </property> </widget> </item> diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 995725b0f..ba6e09368 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -325,6 +325,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, u8 player_index, boo ui->buttonHome->setEnabled(false); } +ConfigureInputPlayer::~ConfigureInputPlayer() = default; + void ConfigureInputPlayer::applyConfiguration() { auto& buttons = debug ? Settings::values.debug_pad_buttons : Settings::values.players[player_index].buttons; diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 8248cd7de..b0e5550c5 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h @@ -30,6 +30,7 @@ class ConfigureInputPlayer : public QDialog { public: explicit ConfigureInputPlayer(QWidget* parent, u8 player_index, bool debug = false); + ~ConfigureInputPlayer() override; /// Save all button configurations to settings file void applyConfiguration(); diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index ac9c84096..dab58fbaa 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp @@ -112,6 +112,8 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent) resize(0, 0); } +ConfigureMouseAdvanced::~ConfigureMouseAdvanced() = default; + void ConfigureMouseAdvanced::applyConfiguration() { std::transform(buttons_param.begin(), buttons_param.end(), Settings::values.mouse_buttons.begin(), diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h index 983ac4158..218df2bda 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.h +++ b/src/yuzu/configuration/configure_mouse_advanced.h @@ -23,6 +23,7 @@ class ConfigureMouseAdvanced : public QDialog { public: explicit ConfigureMouseAdvanced(QWidget* parent); + ~ConfigureMouseAdvanced() override; void applyConfiguration(); |