diff options
Diffstat (limited to '')
-rw-r--r-- | src/yuzu/configuration/config.cpp | 177 |
1 files changed, 93 insertions, 84 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index e80a3df77..eb58bfa5b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -5,8 +5,8 @@ #include <array> #include <QKeySequence> #include <QSettings> -#include "common/common_paths.h" -#include "common/file_util.h" +#include "common/fs/fs.h" +#include "common/fs/path_util.h" #include "core/core.h" #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/hid/controllers/npad.h" @@ -243,27 +243,27 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{ // clang-format on void Config::Initialize(const std::string& config_name) { + const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir); + const auto config_file = fmt::format("{}.ini", config_name); + switch (type) { case ConfigType::GlobalConfig: - qt_config_loc = fmt::format("{}" DIR_SEP "{}.ini", FS::GetUserPath(FS::UserPath::ConfigDir), - config_name); - FS::CreateFullPath(qt_config_loc); + qt_config_loc = FS::PathToUTF8String(fs_config_loc / config_file); + void(FS::CreateParentDir(qt_config_loc)); qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat); Reload(); break; case ConfigType::PerGameConfig: - qt_config_loc = fmt::format("{}custom" DIR_SEP "{}.ini", - FS::GetUserPath(FS::UserPath::ConfigDir), config_name); - FS::CreateFullPath(qt_config_loc); + qt_config_loc = FS::PathToUTF8String(fs_config_loc / "custom" / config_file); + void(FS::CreateParentDir(qt_config_loc)); qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat); Reload(); break; case ConfigType::InputProfile: - qt_config_loc = fmt::format("{}input" DIR_SEP "{}.ini", - FS::GetUserPath(FS::UserPath::ConfigDir), config_name); - FS::CreateFullPath(qt_config_loc); + qt_config_loc = FS::PathToUTF8String(fs_config_loc / "input" / config_file); + void(FS::CreateParentDir(qt_config_loc)); qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat); break; @@ -514,6 +514,13 @@ void Config::ReadControlValues() { ReadSetting(QStringLiteral("mouse_panning_sensitivity"), 1).toFloat(); ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), true); + + // Disable docked mode if handheld is selected + const auto controller_type = Settings::values.players.GetValue()[0].controller_type; + if (controller_type == Settings::ControllerType::Handheld) { + Settings::values.use_docked_mode.SetValue(false); + } + ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"), true); ReadSettingGlobal(Settings::values.enable_accurate_vibrations, @@ -591,30 +598,34 @@ void Config::ReadDataStorageValues() { qt_config->beginGroup(QStringLiteral("Data Storage")); Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool(); - FS::GetUserPath(FS::UserPath::NANDDir, - qt_config - ->value(QStringLiteral("nand_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir))) - .toString() - .toStdString()); - FS::GetUserPath(FS::UserPath::SDMCDir, - qt_config - ->value(QStringLiteral("sdmc_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir))) - .toString() - .toStdString()); - FS::GetUserPath(FS::UserPath::LoadDir, - qt_config - ->value(QStringLiteral("load_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir))) - .toString() - .toStdString()); - FS::GetUserPath(FS::UserPath::DumpDir, - qt_config - ->value(QStringLiteral("dump_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir))) - .toString() - .toStdString()); + FS::SetYuzuPath( + FS::YuzuPath::NANDDir, + qt_config + ->value(QStringLiteral("nand_directory"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir))) + .toString() + .toStdString()); + FS::SetYuzuPath( + FS::YuzuPath::SDMCDir, + qt_config + ->value(QStringLiteral("sdmc_directory"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir))) + .toString() + .toStdString()); + FS::SetYuzuPath( + FS::YuzuPath::LoadDir, + qt_config + ->value(QStringLiteral("load_directory"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir))) + .toString() + .toStdString()); + FS::SetYuzuPath( + FS::YuzuPath::DumpDir, + qt_config + ->value(QStringLiteral("dump_directory"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) + .toString() + .toStdString()); Settings::values.gamecard_inserted = ReadSetting(QStringLiteral("gamecard_inserted"), false).toBool(); Settings::values.gamecard_current_game = @@ -736,10 +747,16 @@ void Config::ReadPathValues() { void Config::ReadCpuValues() { qt_config->beginGroup(QStringLiteral("Cpu")); - if (global) { - Settings::values.cpu_accuracy = static_cast<Settings::CPUAccuracy>( - ReadSetting(QStringLiteral("cpu_accuracy"), 0).toInt()); + ReadSettingGlobal(Settings::values.cpu_accuracy, QStringLiteral("cpu_accuracy"), 0); + + ReadSettingGlobal(Settings::values.cpuopt_unsafe_unfuse_fma, + QStringLiteral("cpuopt_unsafe_unfuse_fma"), true); + ReadSettingGlobal(Settings::values.cpuopt_unsafe_reduce_fp_error, + QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true); + ReadSettingGlobal(Settings::values.cpuopt_unsafe_inaccurate_nan, + QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true); + if (global) { Settings::values.cpuopt_page_tables = ReadSetting(QStringLiteral("cpuopt_page_tables"), true).toBool(); Settings::values.cpuopt_block_linking = @@ -756,13 +773,6 @@ void Config::ReadCpuValues() { ReadSetting(QStringLiteral("cpuopt_misc_ir"), true).toBool(); Settings::values.cpuopt_reduce_misalign_checks = ReadSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), true).toBool(); - - Settings::values.cpuopt_unsafe_unfuse_fma = - ReadSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"), true).toBool(); - Settings::values.cpuopt_unsafe_reduce_fp_error = - ReadSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true).toBool(); - Settings::values.cpuopt_unsafe_inaccurate_nan = - ReadSetting(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true).toBool(); } qt_config->endGroup(); @@ -811,11 +821,11 @@ void Config::ReadScreenshotValues() { UISettings::values.enable_screenshot_save_as = ReadSetting(QStringLiteral("enable_screenshot_save_as"), true).toBool(); - FS::GetUserPath( - FS::UserPath::ScreenshotsDir, + FS::SetYuzuPath( + FS::YuzuPath::ScreenshotsDir, qt_config ->value(QStringLiteral("screenshot_path"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir))) + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir))) .toString() .toStdString()); @@ -869,17 +879,14 @@ void Config::ReadSystemValues() { } } - bool custom_rtc_enabled; - ReadSettingGlobal(custom_rtc_enabled, QStringLiteral("custom_rtc_enabled"), false); - bool custom_rtc_global = - global || qt_config->value(QStringLiteral("custom_rtc/use_global"), true).toBool(); - Settings::values.custom_rtc.SetGlobal(custom_rtc_global); - if (global || !custom_rtc_global) { + if (global) { + const auto custom_rtc_enabled = + ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool(); if (custom_rtc_enabled) { - Settings::values.custom_rtc.SetValue( - std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong())); + Settings::values.custom_rtc = + std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong()); } else { - Settings::values.custom_rtc.SetValue(std::nullopt); + Settings::values.custom_rtc = std::nullopt; } } @@ -1217,17 +1224,17 @@ void Config::SaveDataStorageValues() { WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true); WriteSetting(QStringLiteral("nand_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)), - QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir))); + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir))); WriteSetting(QStringLiteral("sdmc_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)), - QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir))); + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir)), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir))); WriteSetting(QStringLiteral("load_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)), - QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir))); + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir)), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir))); WriteSetting(QStringLiteral("dump_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)), - QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir))); + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); WriteSetting(QStringLiteral("gamecard_inserted"), Settings::values.gamecard_inserted, false); WriteSetting(QStringLiteral("gamecard_current_game"), Settings::values.gamecard_current_game, false); @@ -1313,10 +1320,19 @@ void Config::SavePathValues() { void Config::SaveCpuValues() { qt_config->beginGroup(QStringLiteral("Cpu")); - if (global) { - WriteSetting(QStringLiteral("cpu_accuracy"), - static_cast<int>(Settings::values.cpu_accuracy), 0); + WriteSettingGlobal(QStringLiteral("cpu_accuracy"), + static_cast<u32>(Settings::values.cpu_accuracy.GetValue(global)), + Settings::values.cpu_accuracy.UsingGlobal(), + static_cast<u32>(Settings::CPUAccuracy::Accurate)); + + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_unfuse_fma"), + Settings::values.cpuopt_unsafe_unfuse_fma, true); + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), + Settings::values.cpuopt_unsafe_reduce_fp_error, true); + WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), + Settings::values.cpuopt_unsafe_inaccurate_nan, true); + if (global) { WriteSetting(QStringLiteral("cpuopt_page_tables"), Settings::values.cpuopt_page_tables, true); WriteSetting(QStringLiteral("cpuopt_block_linking"), Settings::values.cpuopt_block_linking, @@ -1331,13 +1347,6 @@ void Config::SaveCpuValues() { WriteSetting(QStringLiteral("cpuopt_misc_ir"), Settings::values.cpuopt_misc_ir, true); WriteSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), Settings::values.cpuopt_reduce_misalign_checks, true); - - WriteSetting(QStringLiteral("cpuopt_unsafe_unfuse_fma"), - Settings::values.cpuopt_unsafe_unfuse_fma, true); - WriteSetting(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), - Settings::values.cpuopt_unsafe_reduce_fp_error, true); - WriteSetting(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), - Settings::values.cpuopt_unsafe_inaccurate_nan, true); } qt_config->endGroup(); @@ -1392,7 +1401,7 @@ void Config::SaveScreenshotValues() { WriteSetting(QStringLiteral("enable_screenshot_save_as"), UISettings::values.enable_screenshot_save_as); WriteSetting(QStringLiteral("screenshot_path"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir))); + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir))); qt_config->endGroup(); } @@ -1432,14 +1441,14 @@ void Config::SaveSystemValues() { Settings::values.rng_seed.GetValue(global).value_or(0), Settings::values.rng_seed.UsingGlobal(), 0); - WriteSettingGlobal(QStringLiteral("custom_rtc_enabled"), - Settings::values.custom_rtc.GetValue(global).has_value(), - Settings::values.custom_rtc.UsingGlobal(), false); - WriteSettingGlobal( - QStringLiteral("custom_rtc"), - QVariant::fromValue<long long>( - Settings::values.custom_rtc.GetValue(global).value_or(std::chrono::seconds{}).count()), - Settings::values.custom_rtc.UsingGlobal(), 0); + if (global) { + WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(), + false); + WriteSetting(QStringLiteral("custom_rtc"), + QVariant::fromValue<long long>( + Settings::values.custom_rtc.value_or(std::chrono::seconds{}).count()), + 0); + } WriteSettingGlobal(QStringLiteral("sound_index"), Settings::values.sound_index, 1); |