summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Narr the Reg2023-02-26 14:39:13 -0600
committerGravatar GitHub2023-02-26 14:39:13 -0600
commitff11fdb07e7264f21b45e23b852bc1c51c870f5c (patch)
tree0be3e8dfec5f9df92c38e3bba7b632751ad57379 /src
parentMerge pull request #9849 from ameerj/async-astc (diff)
downloadyuzu-ff11fdb07e7264f21b45e23b852bc1c51c870f5c.tar.gz
yuzu-ff11fdb07e7264f21b45e23b852bc1c51c870f5c.tar.xz
yuzu-ff11fdb07e7264f21b45e23b852bc1c51c870f5c.zip
Revert "yuzu: config: Remove player 8 and 9 from config file"
Diffstat (limited to 'src')
-rw-r--r--src/common/settings.h2
-rw-r--r--src/core/hid/emulated_controller.cpp78
-rw-r--r--src/core/hid/emulated_controller.h7
-rw-r--r--src/core/hid/hid_types.h26
-rw-r--r--src/yuzu/applets/qt_controller.cpp9
-rw-r--r--src/yuzu/configuration/config.cpp7
-rw-r--r--src/yuzu/configuration/configure_input_per_game.cpp5
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp8
8 files changed, 38 insertions, 104 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 4d0694b7d..512ecff69 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -482,7 +482,7 @@ struct Values {
482 SwitchableSetting<s32, true> sound_index{1, 0, 2, "sound_index"}; 482 SwitchableSetting<s32, true> sound_index{1, 0, 2, "sound_index"};
483 483
484 // Controls 484 // Controls
485 InputSetting<std::array<PlayerInput, 8>> players; 485 InputSetting<std::array<PlayerInput, 10>> players;
486 486
487 SwitchableSetting<bool> use_docked_mode{true, "use_docked_mode"}; 487 SwitchableSetting<bool> use_docked_mode{true, "use_docked_mode"};
488 488
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 9f0ceca49..a29c9a6f8 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -82,12 +82,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde
82} 82}
83 83
84void EmulatedController::ReloadFromSettings() { 84void EmulatedController::ReloadFromSettings() {
85 if (npad_id_type == NpadIdType::Other) { 85 const auto player_index = NpadIdTypeToIndex(npad_id_type);
86 ReloadDebugPadFromSettings();
87 return;
88 }
89
90 const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
91 const auto& player = Settings::values.players.GetValue()[player_index]; 86 const auto& player = Settings::values.players.GetValue()[player_index];
92 87
93 for (std::size_t index = 0; index < player.buttons.size(); ++index) { 88 for (std::size_t index = 0; index < player.buttons.size(); ++index) {
@@ -116,21 +111,13 @@ void EmulatedController::ReloadFromSettings() {
116 111
117 ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); 112 ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
118 113
119 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); 114 // Other or debug controller should always be a pro controller
120 original_npad_type = npad_type; 115 if (npad_id_type != NpadIdType::Other) {
121 116 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
122 // Player 1 shares config with handheld. Disable controller when handheld is selected 117 original_npad_type = npad_type;
123 if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) { 118 } else {
124 Disconnect(); 119 SetNpadStyleIndex(NpadStyleIndex::ProController);
125 ReloadInput(); 120 original_npad_type = npad_type;
126 return;
127 }
128
129 // Handheld shares config with player 1. Disable controller when handheld isn't selected
130 if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
131 Disconnect();
132 ReloadInput();
133 return;
134 } 121 }
135 122
136 Disconnect(); 123 Disconnect();
@@ -141,33 +128,6 @@ void EmulatedController::ReloadFromSettings() {
141 ReloadInput(); 128 ReloadInput();
142} 129}
143 130
144void EmulatedController::ReloadDebugPadFromSettings() {
145 for (std::size_t index = 0; index < Settings::values.debug_pad_buttons.size(); ++index) {
146 button_params[index] = Common::ParamPackage(Settings::values.debug_pad_buttons[index]);
147 }
148 for (std::size_t index = 0; index < Settings::values.debug_pad_analogs.size(); ++index) {
149 stick_params[index] = Common::ParamPackage(Settings::values.debug_pad_analogs[index]);
150 }
151 for (std::size_t index = 0; index < motion_params.size(); ++index) {
152 motion_params[index] = {};
153 }
154
155 controller.color_values = {};
156 controller.colors_state.fullkey = {};
157 controller.colors_state.left = {};
158 controller.colors_state.right = {};
159 ring_params[0] = {};
160 SetNpadStyleIndex(NpadStyleIndex::ProController);
161 original_npad_type = npad_type;
162
163 Disconnect();
164 if (Settings::values.debug_pad_enabled) {
165 Connect();
166 }
167
168 ReloadInput();
169}
170
171void EmulatedController::LoadDevices() { 131void EmulatedController::LoadDevices() {
172 // TODO(german77): Use more buttons to detect the correct device 132 // TODO(german77): Use more buttons to detect the correct device
173 const auto left_joycon = button_params[Settings::NativeButton::DRight]; 133 const auto left_joycon = button_params[Settings::NativeButton::DRight];
@@ -600,23 +560,9 @@ bool EmulatedController::IsConfiguring() const {
600} 560}
601 561
602void EmulatedController::SaveCurrentConfig() { 562void EmulatedController::SaveCurrentConfig() {
603 // Other can't alter the config from here 563 const auto player_index = NpadIdTypeToIndex(npad_id_type);
604 if (npad_id_type == NpadIdType::Other) {
605 return;
606 }
607
608 const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
609 auto& player = Settings::values.players.GetValue()[player_index]; 564 auto& player = Settings::values.players.GetValue()[player_index];
610 565 player.connected = is_connected;
611 // Only save the connected status when handheld is connected
612 if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
613 player.connected = is_connected;
614 }
615
616 if (npad_id_type != NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
617 player.connected = is_connected;
618 }
619
620 player.controller_type = MapNPadToSettingsType(npad_type); 566 player.controller_type = MapNPadToSettingsType(npad_type);
621 for (std::size_t index = 0; index < player.buttons.size(); ++index) { 567 for (std::size_t index = 0; index < player.buttons.size(); ++index) {
622 player.buttons[index] = button_params[index].Serialize(); 568 player.buttons[index] = button_params[index].Serialize();
@@ -1206,7 +1152,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
1206 if (!output_devices[device_index]) { 1152 if (!output_devices[device_index]) {
1207 return false; 1153 return false;
1208 } 1154 }
1209 const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); 1155 const auto player_index = NpadIdTypeToIndex(npad_id_type);
1210 const auto& player = Settings::values.players.GetValue()[player_index]; 1156 const auto& player = Settings::values.players.GetValue()[player_index];
1211 const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; 1157 const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f;
1212 1158
@@ -1232,7 +1178,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
1232} 1178}
1233 1179
1234bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { 1180bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
1235 const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); 1181 const auto player_index = NpadIdTypeToIndex(npad_id_type);
1236 const auto& player = Settings::values.players.GetValue()[player_index]; 1182 const auto& player = Settings::values.players.GetValue()[player_index];
1237 1183
1238 if (!player.vibration_enabled) { 1184 if (!player.vibration_enabled) {
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index 99572b3bd..a9da465a2 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -250,14 +250,9 @@ public:
250 /// Reload all input devices 250 /// Reload all input devices
251 void ReloadInput(); 251 void ReloadInput();
252 252
253 /// Overrides current mapped devices with the stored configuration and reloads all input 253 /// Overrides current mapped devices with the stored configuration and reloads all input devices
254 /// callbacks
255 void ReloadFromSettings(); 254 void ReloadFromSettings();
256 255
257 /// Overrides current mapped debug pad with the stored configuration and reloads all input
258 /// callbacks
259 void ReloadDebugPadFromSettings();
260
261 /// Saves the current mapped configuration 256 /// Saves the current mapped configuration
262 void SaveCurrentConfig(); 257 void SaveCurrentConfig();
263 258
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index 983f0addd..6b35f448c 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -690,32 +690,6 @@ constexpr size_t NpadIdTypeToIndex(NpadIdType npad_id_type) {
690 } 690 }
691} 691}
692 692
693/// Converts a NpadIdType to a config array index.
694constexpr size_t NpadIdTypeToConfigIndex(NpadIdType npad_id_type) {
695 switch (npad_id_type) {
696 case NpadIdType::Player1:
697 return 0;
698 case NpadIdType::Player2:
699 return 1;
700 case NpadIdType::Player3:
701 return 2;
702 case NpadIdType::Player4:
703 return 3;
704 case NpadIdType::Player5:
705 return 4;
706 case NpadIdType::Player6:
707 return 5;
708 case NpadIdType::Player7:
709 return 6;
710 case NpadIdType::Player8:
711 return 7;
712 case NpadIdType::Other:
713 case NpadIdType::Handheld:
714 default:
715 return 0;
716 }
717}
718
719/// Converts an array index to a NpadIdType 693/// Converts an array index to a NpadIdType
720constexpr NpadIdType IndexToNpadIdType(size_t index) { 694constexpr NpadIdType IndexToNpadIdType(size_t index) {
721 switch (index) { 695 switch (index) {
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index d22db9f6b..c30b54499 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -542,14 +542,19 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index)
542 const auto player_connected = player_groupboxes[player_index]->isChecked() && 542 const auto player_connected = player_groupboxes[player_index]->isChecked() &&
543 controller_type != Core::HID::NpadStyleIndex::Handheld; 543 controller_type != Core::HID::NpadStyleIndex::Handheld;
544 544
545 if (controller->GetNpadStyleIndex(true) == controller_type &&
546 controller->IsConnected(true) == player_connected) {
547 return;
548 }
549
545 // Disconnect the controller first. 550 // Disconnect the controller first.
546 UpdateController(controller, controller_type, false); 551 UpdateController(controller, controller_type, false);
547 552
548 // Handheld 553 // Handheld
549 if (player_index == 0) { 554 if (player_index == 0) {
550 auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
551 UpdateController(handheld, controller_type, false);
552 if (controller_type == Core::HID::NpadStyleIndex::Handheld) { 555 if (controller_type == Core::HID::NpadStyleIndex::Handheld) {
556 auto* handheld =
557 system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
553 UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld, 558 UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld,
554 player_groupboxes[player_index]->isChecked()); 559 player_groupboxes[player_index]->isChecked());
555 } 560 }
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 4dad83b75..bb731276e 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -212,11 +212,16 @@ void Config::ReadPlayerValue(std::size_t player_index) {
212 } 212 }
213 213
214 if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) { 214 if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) {
215 player.controller_type = static_cast<Settings::ControllerType>( 215 const auto controller = static_cast<Settings::ControllerType>(
216 qt_config 216 qt_config
217 ->value(QStringLiteral("%1type").arg(player_prefix), 217 ->value(QStringLiteral("%1type").arg(player_prefix),
218 static_cast<u8>(Settings::ControllerType::ProController)) 218 static_cast<u8>(Settings::ControllerType::ProController))
219 .toUInt()); 219 .toUInt());
220
221 if (controller == Settings::ControllerType::LeftJoycon ||
222 controller == Settings::ControllerType::RightJoycon) {
223 player.controller_type = controller;
224 }
220 } else { 225 } else {
221 player.connected = 226 player.connected =
222 ReadSetting(QStringLiteral("%1connected").arg(player_prefix), player_index == 0) 227 ReadSetting(QStringLiteral("%1connected").arg(player_prefix), player_index == 0)
diff --git a/src/yuzu/configuration/configure_input_per_game.cpp b/src/yuzu/configuration/configure_input_per_game.cpp
index 4e77fe00b..78e65d468 100644
--- a/src/yuzu/configuration/configure_input_per_game.cpp
+++ b/src/yuzu/configuration/configure_input_per_game.cpp
@@ -57,7 +57,7 @@ void ConfigureInputPerGame::ApplyConfiguration() {
57} 57}
58 58
59void ConfigureInputPerGame::LoadConfiguration() { 59void ConfigureInputPerGame::LoadConfiguration() {
60 static constexpr size_t HANDHELD_INDEX = 0; 60 static constexpr size_t HANDHELD_INDEX = 8;
61 61
62 auto& hid_core = system.HIDCore(); 62 auto& hid_core = system.HIDCore();
63 for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) { 63 for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) {
@@ -69,6 +69,9 @@ void ConfigureInputPerGame::LoadConfiguration() {
69 const auto selection_index = player_combobox->currentIndex(); 69 const auto selection_index = player_combobox->currentIndex();
70 if (selection_index == 0) { 70 if (selection_index == 0) {
71 Settings::values.players.GetValue()[player_index].profile_name = ""; 71 Settings::values.players.GetValue()[player_index].profile_name = "";
72 if (player_index == 0) {
73 Settings::values.players.GetValue()[HANDHELD_INDEX] = {};
74 }
72 Settings::values.players.SetGlobal(true); 75 Settings::values.players.SetGlobal(true);
73 emulated_controller->ReloadFromSettings(); 76 emulated_controller->ReloadFromSettings();
74 continue; 77 continue;
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 93eb10ceb..50b62293e 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -1589,6 +1589,7 @@ void ConfigureInputPlayer::LoadProfile() {
1589} 1589}
1590 1590
1591void ConfigureInputPlayer::SaveProfile() { 1591void ConfigureInputPlayer::SaveProfile() {
1592 static constexpr size_t HANDHELD_INDEX = 8;
1592 const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex()); 1593 const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex());
1593 1594
1594 if (profile_name.isEmpty()) { 1595 if (profile_name.isEmpty()) {
@@ -1597,7 +1598,12 @@ void ConfigureInputPlayer::SaveProfile() {
1597 1598
1598 ApplyConfiguration(); 1599 ApplyConfiguration();
1599 1600
1600 if (!profiles->SaveProfile(profile_name.toStdString(), player_index)) { 1601 // When we're in handheld mode, only the handheld emulated controller bindings are updated
1602 const bool is_handheld = player_index == 0 && emulated_controller->GetNpadIdType() ==
1603 Core::HID::NpadIdType::Handheld;
1604 const auto profile_player_index = is_handheld ? HANDHELD_INDEX : player_index;
1605
1606 if (!profiles->SaveProfile(profile_name.toStdString(), profile_player_index)) {
1601 QMessageBox::critical(this, tr("Save Input Profile"), 1607 QMessageBox::critical(this, tr("Save Input Profile"),
1602 tr("Failed to save the input profile \"%1\"").arg(profile_name)); 1608 tr("Failed to save the input profile \"%1\"").arg(profile_name));
1603 UpdateInputProfiles(); 1609 UpdateInputProfiles();