diff options
Diffstat (limited to 'src/yuzu_tester/config.cpp')
| -rw-r--r-- | src/yuzu_tester/config.cpp | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp index ee2591c8f..b6cdc7c1c 100644 --- a/src/yuzu_tester/config.cpp +++ b/src/yuzu_tester/config.cpp | |||
| @@ -15,10 +15,11 @@ | |||
| 15 | #include "yuzu_tester/config.h" | 15 | #include "yuzu_tester/config.h" |
| 16 | #include "yuzu_tester/default_ini.h" | 16 | #include "yuzu_tester/default_ini.h" |
| 17 | 17 | ||
| 18 | namespace FS = Common::FS; | ||
| 19 | |||
| 18 | Config::Config() { | 20 | Config::Config() { |
| 19 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 21 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| 20 | sdl2_config_loc = | 22 | sdl2_config_loc = FS::GetUserPath(FS::UserPath::ConfigDir) + "sdl2-tester-config.ini"; |
| 21 | FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "sdl2-tester-config.ini"; | ||
| 22 | sdl2_config = std::make_unique<INIReader>(sdl2_config_loc); | 23 | sdl2_config = std::make_unique<INIReader>(sdl2_config_loc); |
| 23 | 24 | ||
| 24 | Reload(); | 25 | Reload(); |
| @@ -31,8 +32,8 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { | |||
| 31 | if (sdl2_config->ParseError() < 0) { | 32 | if (sdl2_config->ParseError() < 0) { |
| 32 | if (retry) { | 33 | if (retry) { |
| 33 | LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); | 34 | LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); |
| 34 | FileUtil::CreateFullPath(location); | 35 | FS::CreateFullPath(location); |
| 35 | FileUtil::WriteStringToFile(true, default_contents, location); | 36 | FS::WriteStringToFile(true, default_contents, location); |
| 36 | sdl2_config = std::make_unique<INIReader>(location); // Reopen file | 37 | sdl2_config = std::make_unique<INIReader>(location); // Reopen file |
| 37 | 38 | ||
| 38 | return LoadINI(default_contents, false); | 39 | return LoadINI(default_contents, false); |
| @@ -46,13 +47,13 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { | |||
| 46 | 47 | ||
| 47 | void Config::ReadValues() { | 48 | void Config::ReadValues() { |
| 48 | // Controls | 49 | // Controls |
| 49 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { | 50 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { |
| 50 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 51 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 51 | Settings::values.players[p].buttons[i] = ""; | 52 | Settings::values.players.GetValue()[p].buttons[i] = ""; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | 55 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { |
| 55 | Settings::values.players[p].analogs[i] = ""; | 56 | Settings::values.players.GetValue()[p].analogs[i] = ""; |
| 56 | } | 57 | } |
| 57 | } | 58 | } |
| 58 | 59 | ||
| @@ -74,6 +75,9 @@ void Config::ReadValues() { | |||
| 74 | Settings::values.debug_pad_analogs[i] = ""; | 75 | Settings::values.debug_pad_analogs[i] = ""; |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 78 | Settings::values.vibration_enabled.SetValue(true); | ||
| 79 | Settings::values.enable_accurate_vibrations.SetValue(false); | ||
| 80 | Settings::values.motion_enabled.SetValue(true); | ||
| 77 | Settings::values.touchscreen.enabled = ""; | 81 | Settings::values.touchscreen.enabled = ""; |
| 78 | Settings::values.touchscreen.device = ""; | 82 | Settings::values.touchscreen.device = ""; |
| 79 | Settings::values.touchscreen.finger = 0; | 83 | Settings::values.touchscreen.finger = 0; |
| @@ -81,68 +85,73 @@ void Config::ReadValues() { | |||
| 81 | Settings::values.touchscreen.diameter_x = 15; | 85 | Settings::values.touchscreen.diameter_x = 15; |
| 82 | Settings::values.touchscreen.diameter_y = 15; | 86 | Settings::values.touchscreen.diameter_y = 15; |
| 83 | 87 | ||
| 88 | Settings::values.use_docked_mode.SetValue( | ||
| 89 | sdl2_config->GetBoolean("Controls", "use_docked_mode", false)); | ||
| 90 | |||
| 84 | // Data Storage | 91 | // Data Storage |
| 85 | Settings::values.use_virtual_sd = | 92 | Settings::values.use_virtual_sd = |
| 86 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); | 93 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); |
| 87 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir, | 94 | FS::GetUserPath(Common::FS::UserPath::NANDDir, |
| 88 | sdl2_config->Get("Data Storage", "nand_directory", | 95 | sdl2_config->Get("Data Storage", "nand_directory", |
| 89 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); | 96 | Common::FS::GetUserPath(Common::FS::UserPath::NANDDir))); |
| 90 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir, | 97 | FS::GetUserPath(Common::FS::UserPath::SDMCDir, |
| 91 | sdl2_config->Get("Data Storage", "sdmc_directory", | 98 | sdl2_config->Get("Data Storage", "sdmc_directory", |
| 92 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); | 99 | Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir))); |
| 93 | 100 | ||
| 94 | // System | 101 | // System |
| 95 | Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false); | ||
| 96 | |||
| 97 | Settings::values.current_user = std::clamp<int>( | 102 | Settings::values.current_user = std::clamp<int>( |
| 98 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); | 103 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); |
| 99 | 104 | ||
| 100 | const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); | 105 | const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); |
| 101 | if (rng_seed_enabled) { | 106 | if (rng_seed_enabled) { |
| 102 | Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0); | 107 | Settings::values.rng_seed.SetValue(sdl2_config->GetInteger("System", "rng_seed", 0)); |
| 103 | } else { | 108 | } else { |
| 104 | Settings::values.rng_seed = std::nullopt; | 109 | Settings::values.rng_seed.SetValue(std::nullopt); |
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); | 112 | const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); |
| 108 | if (custom_rtc_enabled) { | 113 | if (custom_rtc_enabled) { |
| 109 | Settings::values.custom_rtc = | 114 | Settings::values.custom_rtc.SetValue( |
| 110 | std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)); | 115 | std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0))); |
| 111 | } else { | 116 | } else { |
| 112 | Settings::values.custom_rtc = std::nullopt; | 117 | Settings::values.custom_rtc.SetValue(std::nullopt); |
| 113 | } | 118 | } |
| 114 | 119 | ||
| 115 | // Core | 120 | // Core |
| 116 | Settings::values.use_multi_core = sdl2_config->GetBoolean("Core", "use_multi_core", false); | 121 | Settings::values.use_multi_core.SetValue( |
| 122 | sdl2_config->GetBoolean("Core", "use_multi_core", false)); | ||
| 117 | 123 | ||
| 118 | // Renderer | 124 | // Renderer |
| 119 | Settings::values.resolution_factor = | 125 | Settings::values.aspect_ratio.SetValue( |
| 120 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); | 126 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0))); |
| 121 | Settings::values.aspect_ratio = | 127 | Settings::values.max_anisotropy.SetValue( |
| 122 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); | 128 | static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0))); |
| 123 | Settings::values.max_anisotropy = | 129 | Settings::values.use_frame_limit.SetValue(false); |
| 124 | static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)); | 130 | Settings::values.frame_limit.SetValue(100); |
| 125 | Settings::values.use_frame_limit = false; | 131 | Settings::values.use_disk_shader_cache.SetValue( |
| 126 | Settings::values.frame_limit = 100; | 132 | sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false)); |
| 127 | Settings::values.use_disk_shader_cache = | 133 | const int gpu_accuracy_level = sdl2_config->GetInteger("Renderer", "gpu_accuracy", 0); |
| 128 | sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false); | 134 | Settings::values.gpu_accuracy.SetValue(static_cast<Settings::GPUAccuracy>(gpu_accuracy_level)); |
| 129 | Settings::values.use_accurate_gpu_emulation = | 135 | Settings::values.use_asynchronous_gpu_emulation.SetValue( |
| 130 | sdl2_config->GetBoolean("Renderer", "use_accurate_gpu_emulation", false); | 136 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false)); |
| 131 | Settings::values.use_asynchronous_gpu_emulation = | 137 | Settings::values.use_fast_gpu_time.SetValue( |
| 132 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false); | 138 | sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true)); |
| 133 | 139 | ||
| 134 | Settings::values.bg_red = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0)); | 140 | Settings::values.bg_red.SetValue( |
| 135 | Settings::values.bg_green = | 141 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0))); |
| 136 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0)); | 142 | Settings::values.bg_green.SetValue( |
| 137 | Settings::values.bg_blue = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0)); | 143 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0))); |
| 144 | Settings::values.bg_blue.SetValue( | ||
| 145 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0))); | ||
| 138 | 146 | ||
| 139 | // Audio | 147 | // Audio |
| 140 | Settings::values.sink_id = "null"; | 148 | Settings::values.sink_id = "null"; |
| 141 | Settings::values.enable_audio_stretching = false; | 149 | Settings::values.enable_audio_stretching.SetValue(false); |
| 142 | Settings::values.audio_device_id = "auto"; | 150 | Settings::values.audio_device_id = "auto"; |
| 143 | Settings::values.volume = 0; | 151 | Settings::values.volume.SetValue(0); |
| 144 | 152 | ||
| 145 | Settings::values.language_index = sdl2_config->GetInteger("System", "language_index", 1); | 153 | Settings::values.language_index.SetValue( |
| 154 | sdl2_config->GetInteger("System", "language_index", 1)); | ||
| 146 | 155 | ||
| 147 | // Miscellaneous | 156 | // Miscellaneous |
| 148 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 157 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |