1
0
Fork 0
forked from suyu/suyu

Merge pull request #9871 from yuzu-emu/revert-9824-burning-profiles

Revert "yuzu: config: Remove player 8 and 9 from config file"
This commit is contained in:
bunnei 2023-02-26 22:18:25 -08:00 committed by GitHub
commit 2b4ba90329
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 104 deletions

View file

@ -482,7 +482,7 @@ struct Values {
SwitchableSetting<s32, true> sound_index{1, 0, 2, "sound_index"}; SwitchableSetting<s32, true> sound_index{1, 0, 2, "sound_index"};
// Controls // Controls
InputSetting<std::array<PlayerInput, 8>> players; InputSetting<std::array<PlayerInput, 10>> players;
SwitchableSetting<bool> use_docked_mode{true, "use_docked_mode"}; SwitchableSetting<bool> use_docked_mode{true, "use_docked_mode"};

View file

@ -82,12 +82,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde
} }
void EmulatedController::ReloadFromSettings() { void EmulatedController::ReloadFromSettings() {
if (npad_id_type == NpadIdType::Other) { const auto player_index = NpadIdTypeToIndex(npad_id_type);
ReloadDebugPadFromSettings();
return;
}
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index]; const auto& player = Settings::values.players.GetValue()[player_index];
for (std::size_t index = 0; index < player.buttons.size(); ++index) { for (std::size_t index = 0; index < player.buttons.size(); ++index) {
@ -116,21 +111,13 @@ void EmulatedController::ReloadFromSettings() {
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); // Other or debug controller should always be a pro controller
original_npad_type = npad_type; if (npad_id_type != NpadIdType::Other) {
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
// Player 1 shares config with handheld. Disable controller when handheld is selected original_npad_type = npad_type;
if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) { } else {
Disconnect(); SetNpadStyleIndex(NpadStyleIndex::ProController);
ReloadInput(); original_npad_type = npad_type;
return;
}
// Handheld shares config with player 1. Disable controller when handheld isn't selected
if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
Disconnect();
ReloadInput();
return;
} }
Disconnect(); Disconnect();
@ -141,33 +128,6 @@ void EmulatedController::ReloadFromSettings() {
ReloadInput(); ReloadInput();
} }
void EmulatedController::ReloadDebugPadFromSettings() {
for (std::size_t index = 0; index < Settings::values.debug_pad_buttons.size(); ++index) {
button_params[index] = Common::ParamPackage(Settings::values.debug_pad_buttons[index]);
}
for (std::size_t index = 0; index < Settings::values.debug_pad_analogs.size(); ++index) {
stick_params[index] = Common::ParamPackage(Settings::values.debug_pad_analogs[index]);
}
for (std::size_t index = 0; index < motion_params.size(); ++index) {
motion_params[index] = {};
}
controller.color_values = {};
controller.colors_state.fullkey = {};
controller.colors_state.left = {};
controller.colors_state.right = {};
ring_params[0] = {};
SetNpadStyleIndex(NpadStyleIndex::ProController);
original_npad_type = npad_type;
Disconnect();
if (Settings::values.debug_pad_enabled) {
Connect();
}
ReloadInput();
}
void EmulatedController::LoadDevices() { void EmulatedController::LoadDevices() {
// TODO(german77): Use more buttons to detect the correct device // TODO(german77): Use more buttons to detect the correct device
const auto left_joycon = button_params[Settings::NativeButton::DRight]; const auto left_joycon = button_params[Settings::NativeButton::DRight];
@ -600,23 +560,9 @@ bool EmulatedController::IsConfiguring() const {
} }
void EmulatedController::SaveCurrentConfig() { void EmulatedController::SaveCurrentConfig() {
// Other can't alter the config from here const auto player_index = NpadIdTypeToIndex(npad_id_type);
if (npad_id_type == NpadIdType::Other) {
return;
}
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
auto& player = Settings::values.players.GetValue()[player_index]; auto& player = Settings::values.players.GetValue()[player_index];
player.connected = is_connected;
// Only save the connected status when handheld is connected
if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
player.connected = is_connected;
}
if (npad_id_type != NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
player.connected = is_connected;
}
player.controller_type = MapNPadToSettingsType(npad_type); player.controller_type = MapNPadToSettingsType(npad_type);
for (std::size_t index = 0; index < player.buttons.size(); ++index) { for (std::size_t index = 0; index < player.buttons.size(); ++index) {
player.buttons[index] = button_params[index].Serialize(); player.buttons[index] = button_params[index].Serialize();
@ -1206,7 +1152,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
if (!output_devices[device_index]) { if (!output_devices[device_index]) {
return false; return false;
} }
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index]; const auto& player = Settings::values.players.GetValue()[player_index];
const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f;
@ -1232,7 +1178,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
} }
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index]; const auto& player = Settings::values.players.GetValue()[player_index];
if (!player.vibration_enabled) { if (!player.vibration_enabled) {

View file

@ -250,14 +250,9 @@ public:
/// Reload all input devices /// Reload all input devices
void ReloadInput(); void ReloadInput();
/// Overrides current mapped devices with the stored configuration and reloads all input /// Overrides current mapped devices with the stored configuration and reloads all input devices
/// callbacks
void ReloadFromSettings(); void ReloadFromSettings();
/// Overrides current mapped debug pad with the stored configuration and reloads all input
/// callbacks
void ReloadDebugPadFromSettings();
/// Saves the current mapped configuration /// Saves the current mapped configuration
void SaveCurrentConfig(); void SaveCurrentConfig();

View file

@ -690,32 +690,6 @@ constexpr size_t NpadIdTypeToIndex(NpadIdType npad_id_type) {
} }
} }
/// Converts a NpadIdType to a config array index.
constexpr size_t NpadIdTypeToConfigIndex(NpadIdType npad_id_type) {
switch (npad_id_type) {
case NpadIdType::Player1:
return 0;
case NpadIdType::Player2:
return 1;
case NpadIdType::Player3:
return 2;
case NpadIdType::Player4:
return 3;
case NpadIdType::Player5:
return 4;
case NpadIdType::Player6:
return 5;
case NpadIdType::Player7:
return 6;
case NpadIdType::Player8:
return 7;
case NpadIdType::Other:
case NpadIdType::Handheld:
default:
return 0;
}
}
/// Converts an array index to a NpadIdType /// Converts an array index to a NpadIdType
constexpr NpadIdType IndexToNpadIdType(size_t index) { constexpr NpadIdType IndexToNpadIdType(size_t index) {
switch (index) { switch (index) {

View file

@ -542,14 +542,19 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index)
const auto player_connected = player_groupboxes[player_index]->isChecked() && const auto player_connected = player_groupboxes[player_index]->isChecked() &&
controller_type != Core::HID::NpadStyleIndex::Handheld; controller_type != Core::HID::NpadStyleIndex::Handheld;
if (controller->GetNpadStyleIndex(true) == controller_type &&
controller->IsConnected(true) == player_connected) {
return;
}
// Disconnect the controller first. // Disconnect the controller first.
UpdateController(controller, controller_type, false); UpdateController(controller, controller_type, false);
// Handheld // Handheld
if (player_index == 0) { if (player_index == 0) {
auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
UpdateController(handheld, controller_type, false);
if (controller_type == Core::HID::NpadStyleIndex::Handheld) { if (controller_type == Core::HID::NpadStyleIndex::Handheld) {
auto* handheld =
system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld, UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld,
player_groupboxes[player_index]->isChecked()); player_groupboxes[player_index]->isChecked());
} }

View file

@ -212,11 +212,16 @@ void Config::ReadPlayerValue(std::size_t player_index) {
} }
if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) { if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) {
player.controller_type = static_cast<Settings::ControllerType>( const auto controller = static_cast<Settings::ControllerType>(
qt_config qt_config
->value(QStringLiteral("%1type").arg(player_prefix), ->value(QStringLiteral("%1type").arg(player_prefix),
static_cast<u8>(Settings::ControllerType::ProController)) static_cast<u8>(Settings::ControllerType::ProController))
.toUInt()); .toUInt());
if (controller == Settings::ControllerType::LeftJoycon ||
controller == Settings::ControllerType::RightJoycon) {
player.controller_type = controller;
}
} else { } else {
player.connected = player.connected =
ReadSetting(QStringLiteral("%1connected").arg(player_prefix), player_index == 0) ReadSetting(QStringLiteral("%1connected").arg(player_prefix), player_index == 0)

View file

@ -57,7 +57,7 @@ void ConfigureInputPerGame::ApplyConfiguration() {
} }
void ConfigureInputPerGame::LoadConfiguration() { void ConfigureInputPerGame::LoadConfiguration() {
static constexpr size_t HANDHELD_INDEX = 0; static constexpr size_t HANDHELD_INDEX = 8;
auto& hid_core = system.HIDCore(); auto& hid_core = system.HIDCore();
for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) { for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) {
@ -69,6 +69,9 @@ void ConfigureInputPerGame::LoadConfiguration() {
const auto selection_index = player_combobox->currentIndex(); const auto selection_index = player_combobox->currentIndex();
if (selection_index == 0) { if (selection_index == 0) {
Settings::values.players.GetValue()[player_index].profile_name = ""; Settings::values.players.GetValue()[player_index].profile_name = "";
if (player_index == 0) {
Settings::values.players.GetValue()[HANDHELD_INDEX] = {};
}
Settings::values.players.SetGlobal(true); Settings::values.players.SetGlobal(true);
emulated_controller->ReloadFromSettings(); emulated_controller->ReloadFromSettings();
continue; continue;

View file

@ -1589,6 +1589,7 @@ void ConfigureInputPlayer::LoadProfile() {
} }
void ConfigureInputPlayer::SaveProfile() { void ConfigureInputPlayer::SaveProfile() {
static constexpr size_t HANDHELD_INDEX = 8;
const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex()); const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex());
if (profile_name.isEmpty()) { if (profile_name.isEmpty()) {
@ -1597,7 +1598,12 @@ void ConfigureInputPlayer::SaveProfile() {
ApplyConfiguration(); ApplyConfiguration();
if (!profiles->SaveProfile(profile_name.toStdString(), player_index)) { // When we're in handheld mode, only the handheld emulated controller bindings are updated
const bool is_handheld = player_index == 0 && emulated_controller->GetNpadIdType() ==
Core::HID::NpadIdType::Handheld;
const auto profile_player_index = is_handheld ? HANDHELD_INDEX : player_index;
if (!profiles->SaveProfile(profile_name.toStdString(), profile_player_index)) {
QMessageBox::critical(this, tr("Save Input Profile"), QMessageBox::critical(this, tr("Save Input Profile"),
tr("Failed to save the input profile \"%1\"").arg(profile_name)); tr("Failed to save the input profile \"%1\"").arg(profile_name));
UpdateInputProfiles(); UpdateInputProfiles();