summaryrefslogtreecommitdiff
path: root/src/common/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/settings.cpp')
-rw-r--r--src/common/settings.cpp248
1 files changed, 132 insertions, 116 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index d4e55f988..15fd2e222 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -7,9 +7,16 @@
7#include <exception> 7#include <exception>
8#include <stdexcept> 8#include <stdexcept>
9#endif 9#endif
10#include <compare>
11#include <cstddef>
12#include <filesystem>
13#include <functional>
10#include <string_view> 14#include <string_view>
15#include <type_traits>
16#include <fmt/core.h>
11 17
12#include "common/assert.h" 18#include "common/assert.h"
19#include "common/fs/fs_util.h"
13#include "common/fs/path_util.h" 20#include "common/fs/path_util.h"
14#include "common/logging/log.h" 21#include "common/logging/log.h"
15#include "common/settings.h" 22#include "common/settings.h"
@@ -17,11 +24,50 @@
17 24
18namespace Settings { 25namespace Settings {
19 26
27// Clang 14 and earlier have errors when explicitly instantiating these classes
28#ifndef CANNOT_EXPLICITLY_INSTANTIATE
29#define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
30#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
31
32SETTING(AudioEngine, false);
33SETTING(bool, false);
34SETTING(int, false);
35SETTING(std::string, false);
36SETTING(u16, false);
37SWITCHABLE(AnisotropyMode, true);
38SWITCHABLE(AntiAliasing, false);
39SWITCHABLE(AspectRatio, true);
40SWITCHABLE(AstcDecodeMode, true);
41SWITCHABLE(AstcRecompression, true);
42SWITCHABLE(AudioMode, true);
43SWITCHABLE(CpuAccuracy, true);
44SWITCHABLE(FullscreenMode, true);
45SWITCHABLE(GpuAccuracy, true);
46SWITCHABLE(Language, true);
47SWITCHABLE(NvdecEmulation, false);
48SWITCHABLE(Region, true);
49SWITCHABLE(RendererBackend, true);
50SWITCHABLE(ScalingFilter, false);
51SWITCHABLE(ShaderBackend, true);
52SWITCHABLE(TimeZone, true);
53SETTING(VSyncMode, true);
54SWITCHABLE(bool, false);
55SWITCHABLE(int, false);
56SWITCHABLE(int, true);
57SWITCHABLE(s64, false);
58SWITCHABLE(u16, true);
59SWITCHABLE(u32, false);
60SWITCHABLE(u8, false);
61SWITCHABLE(u8, true);
62
63#undef SETTING
64#undef SWITCHABLE
65#endif
66
20Values values; 67Values values;
21static bool configuring_global = true;
22 68
23std::string GetTimeZoneString() { 69std::string GetTimeZoneString(TimeZone time_zone) {
24 const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue()); 70 const auto time_zone_index = static_cast<std::size_t>(time_zone);
25 ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size()); 71 ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size());
26 72
27 std::string location_name; 73 std::string location_name;
@@ -61,73 +107,35 @@ void LogSettings() {
61 }; 107 };
62 108
63 LOG_INFO(Config, "yuzu Configuration:"); 109 LOG_INFO(Config, "yuzu Configuration:");
64 log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue()); 110 for (auto& [category, settings] : values.linkage.by_category) {
65 log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0)); 111 for (const auto& setting : settings) {
66 log_setting("System_DeviceName", values.device_name.GetValue()); 112 if (setting->Id() == values.yuzu_token.Id()) {
67 log_setting("System_CurrentUser", values.current_user.GetValue()); 113 // Hide the token secret, for security reasons.
68 log_setting("System_LanguageIndex", values.language_index.GetValue()); 114 continue;
69 log_setting("System_RegionIndex", values.region_index.GetValue()); 115 }
70 log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); 116
71 log_setting("System_UnsafeMemoryLayout", values.use_unsafe_extended_memory_layout.GetValue()); 117 const auto name = fmt::format(
72 log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); 118 "{:c}{:c} {}.{}", setting->ToString() == setting->DefaultToString() ? '-' : 'M',
73 log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); 119 setting->UsingGlobal() ? '-' : 'C', TranslateCategory(category),
74 log_setting("Renderer_UseResolutionScaling", values.resolution_setup.GetValue()); 120 setting->GetLabel());
75 log_setting("Renderer_ScalingFilter", values.scaling_filter.GetValue()); 121
76 log_setting("Renderer_FSRSlider", values.fsr_sharpening_slider.GetValue()); 122 log_setting(name, setting->Canonicalize());
77 log_setting("Renderer_AntiAliasing", values.anti_aliasing.GetValue()); 123 }
78 log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue()); 124 }
79 log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue());
80 log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue());
81 log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue());
82 log_setting("Renderer_UseAsynchronousGpuEmulation",
83 values.use_asynchronous_gpu_emulation.GetValue());
84 log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue());
85 log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue());
86 log_setting("Renderer_AsyncASTC", values.async_astc.GetValue());
87 log_setting("Renderer_AstcRecompression", values.astc_recompression.GetValue());
88 log_setting("Renderer_UseVsync", values.vsync_mode.GetValue());
89 log_setting("Renderer_UseReactiveFlushing", values.use_reactive_flushing.GetValue());
90 log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue());
91 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
92 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
93 log_setting("Audio_OutputEngine", values.sink_id.GetValue());
94 log_setting("Audio_OutputDevice", values.audio_output_device_id.GetValue());
95 log_setting("Audio_InputDevice", values.audio_input_device_id.GetValue());
96 log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue());
97 log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir)); 125 log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir));
98 log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir)); 126 log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir));
99 log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir)); 127 log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir));
100 log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir)); 128 log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir));
101 log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); 129 log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir));
102 log_setting("Debugging_ProgramArgs", values.program_args.GetValue());
103 log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue());
104 log_setting("Input_EnableMotion", values.motion_enabled.GetValue());
105 log_setting("Input_EnableVibration", values.vibration_enabled.GetValue());
106 log_setting("Input_EnableTouch", values.touchscreen.enabled);
107 log_setting("Input_EnableMouse", values.mouse_enabled.GetValue());
108 log_setting("Input_EnableKeyboard", values.keyboard_enabled.GetValue());
109 log_setting("Input_EnableRingController", values.enable_ring_controller.GetValue());
110 log_setting("Input_EnableIrSensor", values.enable_ir_sensor.GetValue());
111 log_setting("Input_EnableCustomJoycon", values.enable_joycon_driver.GetValue());
112 log_setting("Input_EnableCustomProController", values.enable_procon_driver.GetValue());
113 log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue());
114}
115
116bool IsConfiguringGlobal() {
117 return configuring_global;
118}
119
120void SetConfiguringGlobal(bool is_global) {
121 configuring_global = is_global;
122} 130}
123 131
124bool IsGPULevelExtreme() { 132bool IsGPULevelExtreme() {
125 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme; 133 return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme;
126} 134}
127 135
128bool IsGPULevelHigh() { 136bool IsGPULevelHigh() {
129 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme || 137 return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme ||
130 values.gpu_accuracy.GetValue() == GPUAccuracy::High; 138 values.gpu_accuracy.GetValue() == GpuAccuracy::High;
131} 139}
132 140
133bool IsFastmemEnabled() { 141bool IsFastmemEnabled() {
@@ -144,6 +152,61 @@ float Volume() {
144 return values.volume.GetValue() / static_cast<f32>(values.volume.GetDefault()); 152 return values.volume.GetValue() / static_cast<f32>(values.volume.GetDefault());
145} 153}
146 154
155const char* TranslateCategory(Category category) {
156 switch (category) {
157 case Category::Audio:
158 return "Audio";
159 case Category::Core:
160 return "Core";
161 case Category::Cpu:
162 case Category::CpuDebug:
163 case Category::CpuUnsafe:
164 return "Cpu";
165 case Category::Renderer:
166 case Category::RendererAdvanced:
167 case Category::RendererDebug:
168 return "Renderer";
169 case Category::System:
170 case Category::SystemAudio:
171 return "System";
172 case Category::DataStorage:
173 return "Data Storage";
174 case Category::Debugging:
175 case Category::DebuggingGraphics:
176 return "Debugging";
177 case Category::Miscellaneous:
178 return "Miscellaneous";
179 case Category::Network:
180 return "Network";
181 case Category::WebService:
182 return "WebService";
183 case Category::AddOns:
184 return "DisabledAddOns";
185 case Category::Controls:
186 return "Controls";
187 case Category::Ui:
188 case Category::UiGeneral:
189 return "UI";
190 case Category::UiLayout:
191 return "UiLayout";
192 case Category::UiGameList:
193 return "UiGameList";
194 case Category::Screenshots:
195 return "Screenshots";
196 case Category::Shortcuts:
197 return "Shortcuts";
198 case Category::Multiplayer:
199 return "Multiplayer";
200 case Category::Services:
201 return "Services";
202 case Category::Paths:
203 return "Paths";
204 case Category::MaxEnum:
205 break;
206 }
207 return "Miscellaneous";
208}
209
147void UpdateRescalingInfo() { 210void UpdateRescalingInfo() {
148 const auto setup = values.resolution_setup.GetValue(); 211 const auto setup = values.resolution_setup.GetValue();
149 auto& info = values.resolution_info; 212 auto& info = values.resolution_info;
@@ -212,66 +275,19 @@ void RestoreGlobalState(bool is_powered_on) {
212 return; 275 return;
213 } 276 }
214 277
215 // Audio 278 for (const auto& reset : values.linkage.restore_functions) {
216 values.volume.SetGlobal(true); 279 reset();
217 280 }
218 // Core 281}
219 values.use_multi_core.SetGlobal(true);
220 values.use_unsafe_extended_memory_layout.SetGlobal(true);
221
222 // CPU
223 values.cpu_accuracy.SetGlobal(true);
224 values.cpuopt_unsafe_unfuse_fma.SetGlobal(true);
225 values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true);
226 values.cpuopt_unsafe_ignore_standard_fpcr.SetGlobal(true);
227 values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true);
228 values.cpuopt_unsafe_fastmem_check.SetGlobal(true);
229 values.cpuopt_unsafe_ignore_global_monitor.SetGlobal(true);
230 282
231 // Renderer 283static bool configuring_global = true;
232 values.fsr_sharpening_slider.SetGlobal(true);
233 values.renderer_backend.SetGlobal(true);
234 values.async_presentation.SetGlobal(true);
235 values.renderer_force_max_clock.SetGlobal(true);
236 values.vulkan_device.SetGlobal(true);
237 values.fullscreen_mode.SetGlobal(true);
238 values.aspect_ratio.SetGlobal(true);
239 values.resolution_setup.SetGlobal(true);
240 values.scaling_filter.SetGlobal(true);
241 values.anti_aliasing.SetGlobal(true);
242 values.max_anisotropy.SetGlobal(true);
243 values.use_speed_limit.SetGlobal(true);
244 values.speed_limit.SetGlobal(true);
245 values.use_disk_shader_cache.SetGlobal(true);
246 values.gpu_accuracy.SetGlobal(true);
247 values.use_asynchronous_gpu_emulation.SetGlobal(true);
248 values.nvdec_emulation.SetGlobal(true);
249 values.accelerate_astc.SetGlobal(true);
250 values.async_astc.SetGlobal(true);
251 values.astc_recompression.SetGlobal(true);
252 values.use_reactive_flushing.SetGlobal(true);
253 values.shader_backend.SetGlobal(true);
254 values.use_asynchronous_shaders.SetGlobal(true);
255 values.use_fast_gpu_time.SetGlobal(true);
256 values.use_vulkan_driver_pipeline_cache.SetGlobal(true);
257 values.bg_red.SetGlobal(true);
258 values.bg_green.SetGlobal(true);
259 values.bg_blue.SetGlobal(true);
260 values.enable_compute_pipelines.SetGlobal(true);
261 values.use_video_framerate.SetGlobal(true);
262 284
263 // System 285bool IsConfiguringGlobal() {
264 values.language_index.SetGlobal(true); 286 return configuring_global;
265 values.region_index.SetGlobal(true); 287}
266 values.time_zone_index.SetGlobal(true);
267 values.rng_seed.SetGlobal(true);
268 values.sound_index.SetGlobal(true);
269 288
270 // Controls 289void SetConfiguringGlobal(bool is_global) {
271 values.players.SetGlobal(true); 290 configuring_global = is_global;
272 values.use_docked_mode.SetGlobal(true);
273 values.vibration_enabled.SetGlobal(true);
274 values.motion_enabled.SetGlobal(true);
275} 291}
276 292
277} // namespace Settings 293} // namespace Settings