From e58c951a59d7f3851fd3a71ae6f99933fba8cdbb Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 4 Nov 2018 10:18:59 -0500 Subject: configure_input: Make None a controller option instead of checkbox --- src/yuzu/configuration/config.cpp | 8 +- src/yuzu/configuration/configure_general.cpp | 36 ------- src/yuzu/configuration/configure_general.h | 1 - src/yuzu/configuration/configure_general.ui | 9 +- src/yuzu/configuration/configure_input.cpp | 113 ++++++++++++------- src/yuzu/configuration/configure_input.h | 7 +- src/yuzu/configuration/configure_input.ui | 120 ++++++++++----------- src/yuzu/configuration/configure_input_player.cpp | 2 + src/yuzu/configuration/configure_input_player.h | 1 + .../configuration/configure_mouse_advanced.cpp | 2 + src/yuzu/configuration/configure_mouse_advanced.h | 1 + 11 files changed, 148 insertions(+), 152 deletions(-) (limited to 'src') 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 #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("appletOE"); - auto applet_ae = sm.GetService("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; }; 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 @@ 0 0 300 - 377 + 407 @@ -71,13 +71,6 @@ - - - - Enable docked mode - - - 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->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::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(i, false); }); } @@ -79,8 +79,6 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(ui->touchscreen_advanced, &QPushButton::pressed, this, [this]() { CallConfigureDialog(); }); - - ui->use_docked_mode->setEnabled(!Core::System::GetInstance().IsPoweredOn()); } template @@ -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("appletOE"); + auto applet_ae = sm.GetService("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(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(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(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(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 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; - std::array players_enabled; - std::array player_controller; - std::array player_configure; + std::array players_controller; + std::array 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 @@ 0 0 473 - 677 + 685 @@ -49,62 +49,6 @@ - - - - Player 1 - - - - - - - Player 7 - - - - - - - Player 4 - - - - - - - Player 5 - - - - - - - Player 6 - - - - - - - Player 8 - - - - - - - Player 3 - - - - - - - Player 2 - - - @@ -250,13 +194,65 @@ - - + + + + + 55 + 0 + + - Enabled + Player 1 - - Qt::AlignCenter + + + + + + Player 2 + + + + + + + Player 3 + + + + + + + Player 4 + + + + + + + Player 5 + + + + + + + Player 6 + + + + + + + Player 7 + + + + + + + Player 8 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(); -- cgit v1.2.3