diff options
Diffstat (limited to 'src/yuzu_cmd/config.cpp')
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 160 |
1 files changed, 89 insertions, 71 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index f4cd905c9..e1adbbf2b 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -16,9 +16,11 @@ | |||
| 16 | #include "yuzu_cmd/config.h" | 16 | #include "yuzu_cmd/config.h" |
| 17 | #include "yuzu_cmd/default_ini.h" | 17 | #include "yuzu_cmd/default_ini.h" |
| 18 | 18 | ||
| 19 | namespace FS = Common::FS; | ||
| 20 | |||
| 19 | Config::Config() { | 21 | Config::Config() { |
| 20 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 22 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| 21 | sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "sdl2-config.ini"; | 23 | sdl2_config_loc = FS::GetUserPath(FS::UserPath::ConfigDir) + "sdl2-config.ini"; |
| 22 | sdl2_config = std::make_unique<INIReader>(sdl2_config_loc); | 24 | sdl2_config = std::make_unique<INIReader>(sdl2_config_loc); |
| 23 | 25 | ||
| 24 | Reload(); | 26 | Reload(); |
| @@ -31,8 +33,8 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { | |||
| 31 | if (sdl2_config->ParseError() < 0) { | 33 | if (sdl2_config->ParseError() < 0) { |
| 32 | if (retry) { | 34 | if (retry) { |
| 33 | LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); | 35 | LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); |
| 34 | FileUtil::CreateFullPath(location); | 36 | FS::CreateFullPath(location); |
| 35 | FileUtil::WriteStringToFile(true, location, default_contents); | 37 | FS::WriteStringToFile(true, location, default_contents); |
| 36 | sdl2_config = std::make_unique<INIReader>(location); // Reopen file | 38 | sdl2_config = std::make_unique<INIReader>(location); // Reopen file |
| 37 | 39 | ||
| 38 | return LoadINI(default_contents, false); | 40 | return LoadINI(default_contents, false); |
| @@ -226,24 +228,24 @@ static const std::array<int, 8> keyboard_mods{ | |||
| 226 | 228 | ||
| 227 | void Config::ReadValues() { | 229 | void Config::ReadValues() { |
| 228 | // Controls | 230 | // Controls |
| 229 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { | 231 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { |
| 230 | const auto group = fmt::format("ControlsP{}", p); | 232 | const auto group = fmt::format("ControlsP{}", p); |
| 231 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 233 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 232 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | 234 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 233 | Settings::values.players[p].buttons[i] = | 235 | Settings::values.players.GetValue()[p].buttons[i] = |
| 234 | sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param); | 236 | sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param); |
| 235 | if (Settings::values.players[p].buttons[i].empty()) | 237 | if (Settings::values.players.GetValue()[p].buttons[i].empty()) |
| 236 | Settings::values.players[p].buttons[i] = default_param; | 238 | Settings::values.players.GetValue()[p].buttons[i] = default_param; |
| 237 | } | 239 | } |
| 238 | 240 | ||
| 239 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | 241 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { |
| 240 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | 242 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( |
| 241 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | 243 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], |
| 242 | default_analogs[i][3], default_analogs[i][4], 0.5f); | 244 | default_analogs[i][3], default_analogs[i][4], 0.5f); |
| 243 | Settings::values.players[p].analogs[i] = | 245 | Settings::values.players.GetValue()[p].analogs[i] = |
| 244 | sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param); | 246 | sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param); |
| 245 | if (Settings::values.players[p].analogs[i].empty()) | 247 | if (Settings::values.players.GetValue()[p].analogs[i].empty()) |
| 246 | Settings::values.players[p].analogs[i] = default_param; | 248 | Settings::values.players.GetValue()[p].analogs[i] = default_param; |
| 247 | } | 249 | } |
| 248 | } | 250 | } |
| 249 | 251 | ||
| @@ -286,6 +288,12 @@ void Config::ReadValues() { | |||
| 286 | Settings::values.debug_pad_analogs[i] = default_param; | 288 | Settings::values.debug_pad_analogs[i] = default_param; |
| 287 | } | 289 | } |
| 288 | 290 | ||
| 291 | Settings::values.vibration_enabled.SetValue( | ||
| 292 | sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true)); | ||
| 293 | Settings::values.enable_accurate_vibrations.SetValue( | ||
| 294 | sdl2_config->GetBoolean("ControlsGeneral", "enable_accurate_vibrations", false)); | ||
| 295 | Settings::values.motion_enabled.SetValue( | ||
| 296 | sdl2_config->GetBoolean("ControlsGeneral", "motion_enabled", true)); | ||
| 289 | Settings::values.touchscreen.enabled = | 297 | Settings::values.touchscreen.enabled = |
| 290 | sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); | 298 | sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); |
| 291 | Settings::values.touchscreen.device = | 299 | Settings::values.touchscreen.device = |
| @@ -315,38 +323,30 @@ void Config::ReadValues() { | |||
| 315 | // Data Storage | 323 | // Data Storage |
| 316 | Settings::values.use_virtual_sd = | 324 | Settings::values.use_virtual_sd = |
| 317 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); | 325 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); |
| 318 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir, | 326 | FS::GetUserPath( |
| 319 | sdl2_config->Get("Data Storage", "nand_directory", | 327 | FS::UserPath::NANDDir, |
| 320 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); | 328 | sdl2_config->Get("Data Storage", "nand_directory", FS::GetUserPath(FS::UserPath::NANDDir))); |
| 321 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir, | 329 | FS::GetUserPath( |
| 322 | sdl2_config->Get("Data Storage", "sdmc_directory", | 330 | FS::UserPath::SDMCDir, |
| 323 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); | 331 | sdl2_config->Get("Data Storage", "sdmc_directory", FS::GetUserPath(FS::UserPath::SDMCDir))); |
| 324 | FileUtil::GetUserPath(FileUtil::UserPath::LoadDir, | 332 | FS::GetUserPath( |
| 325 | sdl2_config->Get("Data Storage", "load_directory", | 333 | FS::UserPath::LoadDir, |
| 326 | FileUtil::GetUserPath(FileUtil::UserPath::LoadDir))); | 334 | sdl2_config->Get("Data Storage", "load_directory", FS::GetUserPath(FS::UserPath::LoadDir))); |
| 327 | FileUtil::GetUserPath(FileUtil::UserPath::DumpDir, | 335 | FS::GetUserPath( |
| 328 | sdl2_config->Get("Data Storage", "dump_directory", | 336 | FS::UserPath::DumpDir, |
| 329 | FileUtil::GetUserPath(FileUtil::UserPath::DumpDir))); | 337 | sdl2_config->Get("Data Storage", "dump_directory", FS::GetUserPath(FS::UserPath::DumpDir))); |
| 330 | FileUtil::GetUserPath(FileUtil::UserPath::CacheDir, | 338 | FS::GetUserPath(FS::UserPath::CacheDir, |
| 331 | sdl2_config->Get("Data Storage", "cache_directory", | 339 | sdl2_config->Get("Data Storage", "cache_directory", |
| 332 | FileUtil::GetUserPath(FileUtil::UserPath::CacheDir))); | 340 | FS::GetUserPath(FS::UserPath::CacheDir))); |
| 333 | Settings::values.gamecard_inserted = | 341 | Settings::values.gamecard_inserted = |
| 334 | sdl2_config->GetBoolean("Data Storage", "gamecard_inserted", false); | 342 | sdl2_config->GetBoolean("Data Storage", "gamecard_inserted", false); |
| 335 | Settings::values.gamecard_current_game = | 343 | Settings::values.gamecard_current_game = |
| 336 | sdl2_config->GetBoolean("Data Storage", "gamecard_current_game", false); | 344 | sdl2_config->GetBoolean("Data Storage", "gamecard_current_game", false); |
| 337 | Settings::values.gamecard_path = sdl2_config->Get("Data Storage", "gamecard_path", ""); | 345 | Settings::values.gamecard_path = sdl2_config->Get("Data Storage", "gamecard_path", ""); |
| 338 | Settings::values.nand_total_size = static_cast<Settings::NANDTotalSize>(sdl2_config->GetInteger( | ||
| 339 | "Data Storage", "nand_total_size", static_cast<long>(Settings::NANDTotalSize::S29_1GB))); | ||
| 340 | Settings::values.nand_user_size = static_cast<Settings::NANDUserSize>(sdl2_config->GetInteger( | ||
| 341 | "Data Storage", "nand_user_size", static_cast<long>(Settings::NANDUserSize::S26GB))); | ||
| 342 | Settings::values.nand_system_size = static_cast<Settings::NANDSystemSize>( | ||
| 343 | sdl2_config->GetInteger("Data Storage", "nand_system_size", | ||
| 344 | static_cast<long>(Settings::NANDSystemSize::S2_5GB))); | ||
| 345 | Settings::values.sdmc_size = static_cast<Settings::SDMCSize>(sdl2_config->GetInteger( | ||
| 346 | "Data Storage", "sdmc_size", static_cast<long>(Settings::SDMCSize::S16GB))); | ||
| 347 | 346 | ||
| 348 | // System | 347 | // System |
| 349 | Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false); | 348 | Settings::values.use_docked_mode.SetValue( |
| 349 | sdl2_config->GetBoolean("System", "use_docked_mode", false)); | ||
| 350 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); | 350 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); |
| 351 | 351 | ||
| 352 | Settings::values.current_user = std::clamp<int>( | 352 | Settings::values.current_user = std::clamp<int>( |
| @@ -354,60 +354,76 @@ void Config::ReadValues() { | |||
| 354 | 354 | ||
| 355 | const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); | 355 | const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); |
| 356 | if (rng_seed_enabled) { | 356 | if (rng_seed_enabled) { |
| 357 | Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0); | 357 | Settings::values.rng_seed.SetValue(sdl2_config->GetInteger("System", "rng_seed", 0)); |
| 358 | } else { | 358 | } else { |
| 359 | Settings::values.rng_seed = std::nullopt; | 359 | Settings::values.rng_seed.SetValue(std::nullopt); |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); | 362 | const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); |
| 363 | if (custom_rtc_enabled) { | 363 | if (custom_rtc_enabled) { |
| 364 | Settings::values.custom_rtc = | 364 | Settings::values.custom_rtc.SetValue( |
| 365 | std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)); | 365 | std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0))); |
| 366 | } else { | 366 | } else { |
| 367 | Settings::values.custom_rtc = std::nullopt; | 367 | Settings::values.custom_rtc.SetValue(std::nullopt); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | Settings::values.language_index.SetValue( | ||
| 371 | sdl2_config->GetInteger("System", "language_index", 1)); | ||
| 372 | Settings::values.time_zone_index.SetValue( | ||
| 373 | sdl2_config->GetInteger("System", "time_zone_index", 0)); | ||
| 374 | |||
| 370 | // Core | 375 | // Core |
| 371 | Settings::values.use_multi_core = sdl2_config->GetBoolean("Core", "use_multi_core", false); | 376 | Settings::values.use_multi_core.SetValue( |
| 377 | sdl2_config->GetBoolean("Core", "use_multi_core", true)); | ||
| 372 | 378 | ||
| 373 | // Renderer | 379 | // Renderer |
| 374 | const int renderer_backend = sdl2_config->GetInteger( | 380 | const int renderer_backend = sdl2_config->GetInteger( |
| 375 | "Renderer", "backend", static_cast<int>(Settings::RendererBackend::OpenGL)); | 381 | "Renderer", "backend", static_cast<int>(Settings::RendererBackend::OpenGL)); |
| 376 | Settings::values.renderer_backend = static_cast<Settings::RendererBackend>(renderer_backend); | 382 | Settings::values.renderer_backend.SetValue( |
| 383 | static_cast<Settings::RendererBackend>(renderer_backend)); | ||
| 377 | Settings::values.renderer_debug = sdl2_config->GetBoolean("Renderer", "debug", false); | 384 | Settings::values.renderer_debug = sdl2_config->GetBoolean("Renderer", "debug", false); |
| 378 | Settings::values.vulkan_device = sdl2_config->GetInteger("Renderer", "vulkan_device", 0); | 385 | Settings::values.vulkan_device.SetValue( |
| 379 | 386 | sdl2_config->GetInteger("Renderer", "vulkan_device", 0)); | |
| 380 | Settings::values.resolution_factor = | 387 | |
| 381 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); | 388 | Settings::values.aspect_ratio.SetValue( |
| 382 | Settings::values.aspect_ratio = | 389 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0))); |
| 383 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); | 390 | Settings::values.max_anisotropy.SetValue( |
| 384 | Settings::values.max_anisotropy = | 391 | static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0))); |
| 385 | static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)); | 392 | Settings::values.use_frame_limit.SetValue( |
| 386 | Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); | 393 | sdl2_config->GetBoolean("Renderer", "use_frame_limit", true)); |
| 387 | Settings::values.frame_limit = | 394 | Settings::values.frame_limit.SetValue( |
| 388 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); | 395 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100))); |
| 389 | Settings::values.use_disk_shader_cache = | 396 | Settings::values.use_disk_shader_cache.SetValue( |
| 390 | sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false); | 397 | sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false)); |
| 391 | Settings::values.use_accurate_gpu_emulation = | 398 | const int gpu_accuracy_level = sdl2_config->GetInteger("Renderer", "gpu_accuracy", 0); |
| 392 | sdl2_config->GetBoolean("Renderer", "use_accurate_gpu_emulation", false); | 399 | Settings::values.gpu_accuracy.SetValue(static_cast<Settings::GPUAccuracy>(gpu_accuracy_level)); |
| 393 | Settings::values.use_asynchronous_gpu_emulation = | 400 | Settings::values.use_asynchronous_gpu_emulation.SetValue( |
| 394 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false); | 401 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", true)); |
| 395 | Settings::values.use_vsync = | 402 | Settings::values.use_vsync.SetValue( |
| 396 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1)); | 403 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1))); |
| 397 | 404 | Settings::values.use_assembly_shaders.SetValue( | |
| 398 | Settings::values.bg_red = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0)); | 405 | sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true)); |
| 399 | Settings::values.bg_green = | 406 | Settings::values.use_asynchronous_shaders.SetValue( |
| 400 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0)); | 407 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false)); |
| 401 | Settings::values.bg_blue = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0)); | 408 | Settings::values.use_asynchronous_shaders.SetValue( |
| 409 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false)); | ||
| 410 | Settings::values.use_fast_gpu_time.SetValue( | ||
| 411 | sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true)); | ||
| 412 | |||
| 413 | Settings::values.bg_red.SetValue( | ||
| 414 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0))); | ||
| 415 | Settings::values.bg_green.SetValue( | ||
| 416 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0))); | ||
| 417 | Settings::values.bg_blue.SetValue( | ||
| 418 | static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0))); | ||
| 402 | 419 | ||
| 403 | // Audio | 420 | // Audio |
| 404 | Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); | 421 | Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); |
| 405 | Settings::values.enable_audio_stretching = | 422 | Settings::values.enable_audio_stretching.SetValue( |
| 406 | sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true); | 423 | sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true)); |
| 407 | Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto"); | 424 | Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto"); |
| 408 | Settings::values.volume = static_cast<float>(sdl2_config->GetReal("Audio", "volume", 1)); | 425 | Settings::values.volume.SetValue( |
| 409 | 426 | static_cast<float>(sdl2_config->GetReal("Audio", "volume", 1))); | |
| 410 | Settings::values.language_index = sdl2_config->GetInteger("System", "language_index", 1); | ||
| 411 | 427 | ||
| 412 | // Miscellaneous | 428 | // Miscellaneous |
| 413 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 429 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |
| @@ -425,6 +441,8 @@ void Config::ReadValues() { | |||
| 425 | Settings::values.reporting_services = | 441 | Settings::values.reporting_services = |
| 426 | sdl2_config->GetBoolean("Debugging", "reporting_services", false); | 442 | sdl2_config->GetBoolean("Debugging", "reporting_services", false); |
| 427 | Settings::values.quest_flag = sdl2_config->GetBoolean("Debugging", "quest_flag", false); | 443 | Settings::values.quest_flag = sdl2_config->GetBoolean("Debugging", "quest_flag", false); |
| 444 | Settings::values.disable_macro_jit = | ||
| 445 | sdl2_config->GetBoolean("Debugging", "disable_macro_jit", false); | ||
| 428 | 446 | ||
| 429 | const auto title_list = sdl2_config->Get("AddOns", "title_ids", ""); | 447 | const auto title_list = sdl2_config->Get("AddOns", "title_ids", ""); |
| 430 | std::stringstream ss(title_list); | 448 | std::stringstream ss(title_list); |