diff options
Diffstat (limited to 'src/core/settings.cpp')
| -rw-r--r-- | src/core/settings.cpp | 205 |
1 files changed, 127 insertions, 78 deletions
diff --git a/src/core/settings.cpp b/src/core/settings.cpp index c1282cb80..aadbc3932 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <string_view> | ||
| 6 | |||
| 5 | #include "common/file_util.h" | 7 | #include "common/file_util.h" |
| 6 | #include "core/core.h" | 8 | #include "core/core.h" |
| 7 | #include "core/gdbstub/gdbstub.h" | 9 | #include "core/gdbstub/gdbstub.h" |
| @@ -11,58 +13,24 @@ | |||
| 11 | 13 | ||
| 12 | namespace Settings { | 14 | namespace Settings { |
| 13 | 15 | ||
| 14 | namespace NativeButton { | 16 | Values values = {}; |
| 15 | const std::array<const char*, NumButtons> mapping = {{ | 17 | static bool configuring_global = true; |
| 16 | "button_a", | ||
| 17 | "button_b", | ||
| 18 | "button_x", | ||
| 19 | "button_y", | ||
| 20 | "button_lstick", | ||
| 21 | "button_rstick", | ||
| 22 | "button_l", | ||
| 23 | "button_r", | ||
| 24 | "button_zl", | ||
| 25 | "button_zr", | ||
| 26 | "button_plus", | ||
| 27 | "button_minus", | ||
| 28 | "button_dleft", | ||
| 29 | "button_dup", | ||
| 30 | "button_dright", | ||
| 31 | "button_ddown", | ||
| 32 | "button_lstick_left", | ||
| 33 | "button_lstick_up", | ||
| 34 | "button_lstick_right", | ||
| 35 | "button_lstick_down", | ||
| 36 | "button_rstick_left", | ||
| 37 | "button_rstick_up", | ||
| 38 | "button_rstick_right", | ||
| 39 | "button_rstick_down", | ||
| 40 | "button_sl", | ||
| 41 | "button_sr", | ||
| 42 | "button_home", | ||
| 43 | "button_screenshot", | ||
| 44 | }}; | ||
| 45 | } | ||
| 46 | 18 | ||
| 47 | namespace NativeAnalog { | 19 | std::string GetTimeZoneString() { |
| 48 | const std::array<const char*, NumAnalogs> mapping = {{ | 20 | static constexpr std::array timezones{ |
| 49 | "lstick", | 21 | "auto", "default", "CET", "CST6CDT", "Cuba", "EET", "Egypt", "Eire", |
| 50 | "rstick", | 22 | "EST", "EST5EDT", "GB", "GB-Eire", "GMT", "GMT+0", "GMT-0", "GMT0", |
| 51 | }}; | 23 | "Greenwich", "Hongkong", "HST", "Iceland", "Iran", "Israel", "Jamaica", "Japan", |
| 52 | } | 24 | "Kwajalein", "Libya", "MET", "MST", "MST7MDT", "Navajo", "NZ", "NZ-CHAT", |
| 25 | "Poland", "Portugal", "PRC", "PST8PDT", "ROC", "ROK", "Singapore", "Turkey", | ||
| 26 | "UCT", "Universal", "UTC", "W-SU", "WET", "Zulu", | ||
| 27 | }; | ||
| 53 | 28 | ||
| 54 | namespace NativeMouseButton { | 29 | const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue()); |
| 55 | const std::array<const char*, NumMouseButtons> mapping = {{ | 30 | ASSERT(time_zone_index < timezones.size()); |
| 56 | "left", | 31 | return timezones[time_zone_index]; |
| 57 | "right", | ||
| 58 | "middle", | ||
| 59 | "forward", | ||
| 60 | "back", | ||
| 61 | }}; | ||
| 62 | } | 32 | } |
| 63 | 33 | ||
| 64 | Values values = {}; | ||
| 65 | |||
| 66 | void Apply() { | 34 | void Apply() { |
| 67 | GDBStub::SetServerPort(values.gdbstub_port); | 35 | GDBStub::SetServerPort(values.gdbstub_port); |
| 68 | GDBStub::ToggleServer(values.use_gdbstub); | 36 | GDBStub::ToggleServer(values.use_gdbstub); |
| @@ -75,38 +43,119 @@ void Apply() { | |||
| 75 | Service::HID::ReloadInputDevices(); | 43 | Service::HID::ReloadInputDevices(); |
| 76 | } | 44 | } |
| 77 | 45 | ||
| 78 | template <typename T> | ||
| 79 | void LogSetting(const std::string& name, const T& value) { | ||
| 80 | LOG_INFO(Config, "{}: {}", name, value); | ||
| 81 | } | ||
| 82 | |||
| 83 | void LogSettings() { | 46 | void LogSettings() { |
| 47 | const auto log_setting = [](std::string_view name, const auto& value) { | ||
| 48 | LOG_INFO(Config, "{}: {}", name, value); | ||
| 49 | }; | ||
| 50 | |||
| 84 | LOG_INFO(Config, "yuzu Configuration:"); | 51 | LOG_INFO(Config, "yuzu Configuration:"); |
| 85 | LogSetting("System_UseDockedMode", Settings::values.use_docked_mode); | 52 | log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue()); |
| 86 | LogSetting("System_RngSeed", Settings::values.rng_seed.value_or(0)); | 53 | log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0)); |
| 87 | LogSetting("System_CurrentUser", Settings::values.current_user); | 54 | log_setting("System_CurrentUser", values.current_user); |
| 88 | LogSetting("System_LanguageIndex", Settings::values.language_index); | 55 | log_setting("System_LanguageIndex", values.language_index.GetValue()); |
| 89 | LogSetting("System_RegionIndex", Settings::values.region_index); | 56 | log_setting("System_RegionIndex", values.region_index.GetValue()); |
| 90 | LogSetting("Core_UseMultiCore", Settings::values.use_multi_core); | 57 | log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); |
| 91 | LogSetting("Renderer_UseResolutionFactor", Settings::values.resolution_factor); | 58 | log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); |
| 92 | LogSetting("Renderer_UseFrameLimit", Settings::values.use_frame_limit); | 59 | log_setting("CPU_Accuracy", values.cpu_accuracy); |
| 93 | LogSetting("Renderer_FrameLimit", Settings::values.frame_limit); | 60 | log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); |
| 94 | LogSetting("Renderer_UseDiskShaderCache", Settings::values.use_disk_shader_cache); | 61 | log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue()); |
| 95 | LogSetting("Renderer_UseAccurateGpuEmulation", Settings::values.use_accurate_gpu_emulation); | 62 | log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); |
| 96 | LogSetting("Renderer_UseAsynchronousGpuEmulation", | 63 | log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); |
| 97 | Settings::values.use_asynchronous_gpu_emulation); | 64 | log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue()); |
| 98 | LogSetting("Renderer_UseVsync", Settings::values.use_vsync); | 65 | log_setting("Renderer_UseAsynchronousGpuEmulation", |
| 99 | LogSetting("Audio_OutputEngine", Settings::values.sink_id); | 66 | values.use_asynchronous_gpu_emulation.GetValue()); |
| 100 | LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching); | 67 | log_setting("Renderer_UseNvdecEmulation", values.use_nvdec_emulation.GetValue()); |
| 101 | LogSetting("Audio_OutputDevice", Settings::values.audio_device_id); | 68 | log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); |
| 102 | LogSetting("DataStorage_UseVirtualSd", Settings::values.use_virtual_sd); | 69 | log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue()); |
| 103 | LogSetting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)); | 70 | log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); |
| 104 | LogSetting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)); | 71 | log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); |
| 105 | LogSetting("Debugging_UseGdbstub", Settings::values.use_gdbstub); | 72 | log_setting("Audio_OutputEngine", values.sink_id); |
| 106 | LogSetting("Debugging_GdbstubPort", Settings::values.gdbstub_port); | 73 | log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue()); |
| 107 | LogSetting("Debugging_ProgramArgs", Settings::values.program_args); | 74 | log_setting("Audio_OutputDevice", values.audio_device_id); |
| 108 | LogSetting("Services_BCATBackend", Settings::values.bcat_backend); | 75 | log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd); |
| 109 | LogSetting("Services_BCATBoxcatLocal", Settings::values.bcat_boxcat_local); | 76 | log_setting("DataStorage_NandDir", Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)); |
| 77 | log_setting("DataStorage_SdmcDir", Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)); | ||
| 78 | log_setting("Debugging_UseGdbstub", values.use_gdbstub); | ||
| 79 | log_setting("Debugging_GdbstubPort", values.gdbstub_port); | ||
| 80 | log_setting("Debugging_ProgramArgs", values.program_args); | ||
| 81 | log_setting("Services_BCATBackend", values.bcat_backend); | ||
| 82 | log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local); | ||
| 83 | } | ||
| 84 | |||
| 85 | bool IsConfiguringGlobal() { | ||
| 86 | return configuring_global; | ||
| 87 | } | ||
| 88 | |||
| 89 | void SetConfiguringGlobal(bool is_global) { | ||
| 90 | configuring_global = is_global; | ||
| 91 | } | ||
| 92 | |||
| 93 | bool IsGPULevelExtreme() { | ||
| 94 | return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme; | ||
| 95 | } | ||
| 96 | |||
| 97 | bool IsGPULevelHigh() { | ||
| 98 | return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme || | ||
| 99 | values.gpu_accuracy.GetValue() == GPUAccuracy::High; | ||
| 100 | } | ||
| 101 | |||
| 102 | float Volume() { | ||
| 103 | if (values.audio_muted) { | ||
| 104 | return 0.0f; | ||
| 105 | } | ||
| 106 | return values.volume.GetValue(); | ||
| 107 | } | ||
| 108 | |||
| 109 | void RestoreGlobalState() { | ||
| 110 | // If a game is running, DO NOT restore the global settings state | ||
| 111 | if (Core::System::GetInstance().IsPoweredOn()) { | ||
| 112 | return; | ||
| 113 | } | ||
| 114 | |||
| 115 | // Audio | ||
| 116 | values.enable_audio_stretching.SetGlobal(true); | ||
| 117 | values.volume.SetGlobal(true); | ||
| 118 | |||
| 119 | // Core | ||
| 120 | values.use_multi_core.SetGlobal(true); | ||
| 121 | |||
| 122 | // Renderer | ||
| 123 | values.renderer_backend.SetGlobal(true); | ||
| 124 | values.vulkan_device.SetGlobal(true); | ||
| 125 | values.aspect_ratio.SetGlobal(true); | ||
| 126 | values.max_anisotropy.SetGlobal(true); | ||
| 127 | values.use_frame_limit.SetGlobal(true); | ||
| 128 | values.frame_limit.SetGlobal(true); | ||
| 129 | values.use_disk_shader_cache.SetGlobal(true); | ||
| 130 | values.gpu_accuracy.SetGlobal(true); | ||
| 131 | values.use_asynchronous_gpu_emulation.SetGlobal(true); | ||
| 132 | values.use_nvdec_emulation.SetGlobal(true); | ||
| 133 | values.use_vsync.SetGlobal(true); | ||
| 134 | values.use_assembly_shaders.SetGlobal(true); | ||
| 135 | values.use_asynchronous_shaders.SetGlobal(true); | ||
| 136 | values.use_fast_gpu_time.SetGlobal(true); | ||
| 137 | values.bg_red.SetGlobal(true); | ||
| 138 | values.bg_green.SetGlobal(true); | ||
| 139 | values.bg_blue.SetGlobal(true); | ||
| 140 | |||
| 141 | // System | ||
| 142 | values.language_index.SetGlobal(true); | ||
| 143 | values.region_index.SetGlobal(true); | ||
| 144 | values.time_zone_index.SetGlobal(true); | ||
| 145 | values.rng_seed.SetGlobal(true); | ||
| 146 | values.custom_rtc.SetGlobal(true); | ||
| 147 | values.sound_index.SetGlobal(true); | ||
| 148 | |||
| 149 | // Controls | ||
| 150 | values.players.SetGlobal(true); | ||
| 151 | values.use_docked_mode.SetGlobal(true); | ||
| 152 | values.vibration_enabled.SetGlobal(true); | ||
| 153 | values.motion_enabled.SetGlobal(true); | ||
| 154 | } | ||
| 155 | |||
| 156 | void Sanitize() { | ||
| 157 | values.use_asynchronous_gpu_emulation.SetValue( | ||
| 158 | values.use_asynchronous_gpu_emulation.GetValue() || values.use_multi_core.GetValue()); | ||
| 110 | } | 159 | } |
| 111 | 160 | ||
| 112 | } // namespace Settings | 161 | } // namespace Settings |