mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-11-25 15:59:06 +00:00
Merge pull request #12380 from flodavid/save-profile
Save configuration profile name used by players
This commit is contained in:
commit
46c2435235
7 changed files with 55 additions and 12 deletions
|
@ -21,7 +21,7 @@ void AndroidConfig::ReloadAllValues() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidConfig::SaveAllValues() {
|
void AndroidConfig::SaveAllValues() {
|
||||||
Save();
|
SaveValues();
|
||||||
SaveAndroidValues();
|
SaveAndroidValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/fs/fs.h"
|
#include "common/fs/fs.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/settings_common.h"
|
#include "common/settings_common.h"
|
||||||
#include "common/settings_enums.h"
|
#include "common/settings_enums.h"
|
||||||
|
@ -58,6 +59,19 @@ void Config::Initialize(const std::optional<std::string> config_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::WriteToIni() const {
|
void Config::WriteToIni() const {
|
||||||
|
std::string config_type;
|
||||||
|
switch (type) {
|
||||||
|
case ConfigType::GlobalConfig:
|
||||||
|
config_type = "Global";
|
||||||
|
break;
|
||||||
|
case ConfigType::PerGameConfig:
|
||||||
|
config_type = "Game Specific";
|
||||||
|
break;
|
||||||
|
case ConfigType::InputProfile:
|
||||||
|
config_type = "Input Profile";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
LOG_INFO(Config, "Writing {} configuration to: {}", config_type, config_loc);
|
||||||
FILE* fp = nullptr;
|
FILE* fp = nullptr;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb");
|
fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb");
|
||||||
|
@ -117,10 +131,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) {
|
||||||
player_prefix.append("player_").append(ToString(player_index)).append("_");
|
player_prefix.append("player_").append(ToString(player_index)).append("_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto profile_name = ReadStringSetting(std::string(player_prefix).append("profile_name"));
|
||||||
|
|
||||||
auto& player = Settings::values.players.GetValue()[player_index];
|
auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
if (IsCustomConfig()) {
|
if (IsCustomConfig()) {
|
||||||
const auto profile_name =
|
|
||||||
ReadStringSetting(std::string(player_prefix).append("profile_name"));
|
|
||||||
if (profile_name.empty()) {
|
if (profile_name.empty()) {
|
||||||
// Use the global input config
|
// Use the global input config
|
||||||
player = Settings::values.players.GetValue(true)[player_index];
|
player = Settings::values.players.GetValue(true)[player_index];
|
||||||
|
@ -139,6 +153,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) {
|
||||||
player.controller_type = controller;
|
player.controller_type = controller;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (global) {
|
||||||
|
auto& player_global = Settings::values.players.GetValue(true)[player_index];
|
||||||
|
player_global.profile_name = profile_name;
|
||||||
|
}
|
||||||
std::string connected_key = player_prefix;
|
std::string connected_key = player_prefix;
|
||||||
player.connected = ReadBooleanSetting(connected_key.append("connected"),
|
player.connected = ReadBooleanSetting(connected_key.append("connected"),
|
||||||
std::make_optional(player_index == 0));
|
std::make_optional(player_index == 0));
|
||||||
|
@ -412,6 +430,11 @@ void Config::SavePlayerValues(const std::size_t player_index) {
|
||||||
std::make_optional(static_cast<u8>(Settings::ControllerType::ProController)));
|
std::make_optional(static_cast<u8>(Settings::ControllerType::ProController)));
|
||||||
|
|
||||||
if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) {
|
if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) {
|
||||||
|
if (global) {
|
||||||
|
const auto& player_global = Settings::values.players.GetValue(true)[player_index];
|
||||||
|
WriteStringSetting(std::string(player_prefix).append("profile_name"),
|
||||||
|
player_global.profile_name, std::make_optional(std::string("")));
|
||||||
|
}
|
||||||
WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected,
|
WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected,
|
||||||
std::make_optional(player_index == 0));
|
std::make_optional(player_index == 0));
|
||||||
WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"),
|
WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"),
|
||||||
|
@ -468,12 +491,15 @@ void Config::SaveMotionTouchValues() {
|
||||||
|
|
||||||
void Config::SaveValues() {
|
void Config::SaveValues() {
|
||||||
if (global) {
|
if (global) {
|
||||||
|
LOG_DEBUG(Config, "Saving global generic configuration values");
|
||||||
SaveDataStorageValues();
|
SaveDataStorageValues();
|
||||||
SaveDebuggingValues();
|
SaveDebuggingValues();
|
||||||
SaveDisabledAddOnValues();
|
SaveDisabledAddOnValues();
|
||||||
SaveNetworkValues();
|
SaveNetworkValues();
|
||||||
SaveWebServiceValues();
|
SaveWebServiceValues();
|
||||||
SaveMiscellaneousValues();
|
SaveMiscellaneousValues();
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(Config, "Saving only generic configuration values");
|
||||||
}
|
}
|
||||||
SaveControlValues();
|
SaveControlValues();
|
||||||
SaveCoreValues();
|
SaveCoreValues();
|
||||||
|
@ -814,10 +840,6 @@ void Config::Reload() {
|
||||||
SaveValues();
|
SaveValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::Save() {
|
|
||||||
SaveValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Config::ClearControlPlayerValues() const {
|
void Config::ClearControlPlayerValues() const {
|
||||||
// If key is an empty string, all keys in the current group() are removed.
|
// If key is an empty string, all keys in the current group() are removed.
|
||||||
const char* section = Settings::TranslateCategory(Settings::Category::Controls);
|
const char* section = Settings::TranslateCategory(Settings::Category::Controls);
|
||||||
|
|
|
@ -51,7 +51,6 @@ protected:
|
||||||
[[nodiscard]] bool IsCustomConfig() const;
|
[[nodiscard]] bool IsCustomConfig() const;
|
||||||
|
|
||||||
void Reload();
|
void Reload();
|
||||||
void Save();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derived config classes must implement this so they can reload all platform-specific
|
* Derived config classes must implement this so they can reload all platform-specific
|
||||||
|
|
|
@ -1650,9 +1650,21 @@ void ConfigureInputPlayer::SaveProfile() {
|
||||||
void ConfigureInputPlayer::UpdateInputProfiles() {
|
void ConfigureInputPlayer::UpdateInputProfiles() {
|
||||||
ui->comboProfiles->clear();
|
ui->comboProfiles->clear();
|
||||||
|
|
||||||
for (const auto& profile_name : profiles->GetInputProfileNames()) {
|
// Set current profile as empty by default
|
||||||
|
int profile_index = -1;
|
||||||
|
|
||||||
|
// Add every available profile and search the player profile to set it as current one
|
||||||
|
auto& current_profile = Settings::values.players.GetValue()[player_index].profile_name;
|
||||||
|
std::vector<std::string> profile_names = profiles->GetInputProfileNames();
|
||||||
|
std::string profile_name;
|
||||||
|
for (size_t i = 0; i < profile_names.size(); i++) {
|
||||||
|
profile_name = profile_names[i];
|
||||||
ui->comboProfiles->addItem(QString::fromStdString(profile_name));
|
ui->comboProfiles->addItem(QString::fromStdString(profile_name));
|
||||||
|
if (current_profile == profile_name) {
|
||||||
|
profile_index = (int)i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->comboProfiles->setCurrentIndex(-1);
|
LOG_DEBUG(Frontend, "Setting the current input profile to index {}", profile_index);
|
||||||
|
ui->comboProfiles->setCurrentIndex(profile_index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "common/fs/fs.h"
|
#include "common/fs/fs.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "frontend_common/config.h"
|
#include "frontend_common/config.h"
|
||||||
#include "yuzu/configuration/input_profiles.h"
|
#include "yuzu/configuration/input_profiles.h"
|
||||||
|
|
||||||
|
@ -113,6 +114,8 @@ bool InputProfiles::LoadProfile(const std::string& profile_name, std::size_t pla
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO(Config, "Loading input profile `{}`", profile_name);
|
||||||
|
|
||||||
map_profiles[profile_name]->ReadQtControlPlayerValues(player_index);
|
map_profiles[profile_name]->ReadQtControlPlayerValues(player_index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "qt_config.h"
|
#include "qt_config.h"
|
||||||
#include "uisettings.h"
|
#include "uisettings.h"
|
||||||
|
@ -65,7 +66,7 @@ void QtConfig::ReloadAllValues() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtConfig::SaveAllValues() {
|
void QtConfig::SaveAllValues() {
|
||||||
Save();
|
SaveValues();
|
||||||
SaveQtValues();
|
SaveQtValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +328,10 @@ void QtConfig::ReadMultiplayerValues() {
|
||||||
|
|
||||||
void QtConfig::SaveQtValues() {
|
void QtConfig::SaveQtValues() {
|
||||||
if (global) {
|
if (global) {
|
||||||
|
LOG_DEBUG(Config, "Saving global Qt configuration values");
|
||||||
SaveUIValues();
|
SaveUIValues();
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(Config, "Saving Qt configuration values");
|
||||||
}
|
}
|
||||||
SaveQtControlValues();
|
SaveQtControlValues();
|
||||||
|
|
||||||
|
@ -545,6 +549,7 @@ void QtConfig::ReadQtControlPlayerValues(std::size_t player_index) {
|
||||||
void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) {
|
void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) {
|
||||||
BeginGroup(Settings::TranslateCategory(Settings::Category::Controls));
|
BeginGroup(Settings::TranslateCategory(Settings::Category::Controls));
|
||||||
|
|
||||||
|
LOG_DEBUG(Config, "Saving players control configuration values");
|
||||||
SavePlayerValues(player_index);
|
SavePlayerValues(player_index);
|
||||||
SaveQtPlayerValues(player_index);
|
SaveQtPlayerValues(player_index);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "sdl_config.h"
|
#include "sdl_config.h"
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ void SdlConfig::ReloadAllValues() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdlConfig::SaveAllValues() {
|
void SdlConfig::SaveAllValues() {
|
||||||
Save();
|
SaveValues();
|
||||||
SaveSdlValues();
|
SaveSdlValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +178,7 @@ void SdlConfig::ReadHidbusValues() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdlConfig::SaveSdlValues() {
|
void SdlConfig::SaveSdlValues() {
|
||||||
|
LOG_DEBUG(Config, "Saving SDL configuration values");
|
||||||
SaveSdlControlValues();
|
SaveSdlControlValues();
|
||||||
|
|
||||||
WriteToIni();
|
WriteToIni();
|
||||||
|
|
Loading…
Reference in a new issue