aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorlat9nq <lat9nq@virginia.edu>2020-07-09 22:42:09 -0400
committerGitHub <noreply@github.com>2020-07-09 22:42:09 -0400
commit63d23835ef4445b3a010cc0e8b1e73ebe012ac08 (patch)
treeb243c1167280dbf2e3f5af4597b6638fb707f091 /src/core
parent0f60ccdde28096bcbb4b73a72cb485784fd501ee (diff)
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer In order to add full per-game settings, we need to be able to tell yuzu to switch to using either the global or game configuration. Using a pointer makes it easier to switch. * configuration: add new UI without changing existing funcitonality The new UI also adds General, System, Graphics, Advanced Graphics, and Audio tabs, but as yet they do nothing. This commit keeps yuzu to the same functionality as originally branched. * configuration: Rename files These weren't included in the last commit. Now they are. * configuration: setup global configuration checkbox Global config checkbox now enables/disables the appropriate tabs in the game properties dialog. The use global configuration setting is now saved to the config, defaulting to true. This also addresses some changes requested in the PR. * configuration: swap to per-game config memory for properties dialog Does not set memory going in-game. Swaps to game values when opening the properties dialog, then swaps back when closing it. Uses a `memcpy` to swap. Also implements saving config files, limited to certain groups of configurations so as to not risk setting unsafe configurations. * configuration: change config interfaces to use config-specific pointers When a game is booted, we need to be able to open the configuration dialogs without changing the settings pointer in the game's emualtion. A new pointer specific to just the configuration dialogs can be used to separate changes to just those config dialogs without affecting the emulation. * configuration: boot a game using per-game settings Swaps values where needed to boot a game. * configuration: user correct config during emulation Creates a new pointer specifically for modifying the configuration while emulation is in progress. Both the regular configuration dialog and the game properties dialog now use the pointer Settings::config_values to focus edits to the correct struct. * settings: split Settings::values into two different structs By splitting the settings into two mutually exclusive structs, it becomes easier, as a developer, to determine how to use the Settings structs after per-game configurations is merged. Other benefits include only duplicating the required settings in memory. * settings: move use_docked_mode to Controls group `use_docked_mode` is set in the input settings and cannot be accessed from the system settings. Grouping it with system settings causes it to be saved with per-game settings, which may make transferring configs more difficult later on, especially since docked mode cannot be set from within the game properties dialog. * configuration: Fix the other yuzu executables and a regression In main.cpp, we have to get the title ID before the ROM is loaded, else the renderer will reflect only the global settings and now the user's game specific settings. * settings: use a template to duplicate memory for each setting Replaces the type of each variable in the Settings::Values struct with a new class that allows basic data reading and writing. The new struct Settings::Setting duplicates the data in memory and can manage global overrides per each setting. * configuration: correct add-ons config and swap settings when apropriate Any add-ons interaction happens directly through the global values struct. Swapping bewteen structs now also includes copying the necessary global configs that cannot be changed nor saved in per-game settings. General and System config menus now update based on whether it is viewing the global or per-game settings. * settings: restore old values struct No longer needed with the Settings::Setting class template. * configuration: implement hierarchical game properties dialog This sets the apropriate global or local data in each setting. * clang format * clang format take 2 can the docker container save this? * address comments and style issues * config: read and write settings with global awareness Adds new functions to read and write settings while keeping the global state in focus. Files now generated per-game are much smaller since often they only need address the global state. * settings: restore global state when necessary Upon closing a game or the game properties dialog, we need to restore all global settings to the original global state so that we can properly open the configuration dialog or boot a different game. * configuration: guard setting values incorrectly This disables setting values while a game is running if the setting is overwritten by a per game setting. * config: don't write local settings in the global config Simple guards to prevent writing the wrong settings in the wrong files. * configuration: add comments, assume less, and clang format No longer assumes that a disabled UI element means the global state is turned off, instead opting to directly answer that question. Still however assumes a game is running if it is in that state. * configuration: fix a logic error Should not be negated * restore settings' global state regardless of accept/cancel Fixes loading a properties dialog and causing the global config dialog to show local settings. * fix more logic errors Fixed the frame limit would set the global setting from the game properties dialog. Also strengthened the Settings::Setting member variables and simplified the logic in config reading (ReadSettingGlobal). * fix another logic error In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered condition. * configure_audio: set toggle_stretched_audio to tristate * fixed custom rtc and rng seed overwriting the global value * clang format * rebased * clang format take 4 * address my own review Basically revert unintended changes * settings: literal instead of casting "No need to cast, use 1U instead" Thanks, Morph! Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> * Revert "settings: literal instead of casting " This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f. * main: fix status buttons reporting wrong settings after stop emulation * settings: Log UseDockedMode in the Controls group This should have happened when use_docked_mode was moved over to the controls group internally. This just reflects this in the log. * main: load settings if the file has a title id In other words, don't exit if the loader has trouble getting a title id. * use a zero * settings: initalize resolution factor with constructor instead of casting * Revert "settings: initalize resolution factor with constructor instead of casting" This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8. * configure_graphics: guard device selector when Vulkan is global Prevents the user from editing the device selector if Vulkan is the global renderer backend. Also resets the vulkan_device variable when the users switches back-and-forth between global and Vulkan. * address reviewer concerns Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static. Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com> * main: load per-game settings after LoadROM This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug. * Revert "main: load per-game settings after LoadROM" This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804. * main: only restore global settings when necessary Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug. * configuration_shared: address reviewer concerns except operator overrides Dropping operator override usage in next commit. Co-Authored-By: LC <lioncash@users.noreply.github.com> * settings: Drop operator overrides from Setting template Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog. * complete rebase * configuration_shared: translate "Use global configuration" Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared. * configure_per_game: address reviewer concern As far as I understand, it prevents the program from unnecessarily copying strings. Co-Authored-By: LC <lioncash@users.noreply.github.com> Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> Co-authored-by: VolcaEM <volcaem@users.noreply.github.com> Co-authored-by: LC <lioncash@users.noreply.github.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp6
-rw-r--r--src/core/frontend/framebuffer_layout.cpp2
-rw-r--r--src/core/hle/kernel/process.cpp2
-rw-r--r--src/core/hle/service/am/am.cpp8
-rw-r--r--src/core/hle/service/ns/ns.cpp3
-rw-r--r--src/core/hle/service/set/set.cpp10
-rw-r--r--src/core/hle/service/spl/module.cpp2
-rw-r--r--src/core/hle/service/vi/vi.cpp20
-rw-r--r--src/core/perf_stats.cpp5
-rw-r--r--src/core/settings.cpp84
-rw-r--r--src/core/settings.h124
-rw-r--r--src/core/telemetry_session.cpp27
12 files changed, 190 insertions, 103 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 1a243c515a..69a1aa0a5e 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -147,8 +147,8 @@ struct System::Impl {
device_memory = std::make_unique<Core::DeviceMemory>(system);
- is_multicore = Settings::values.use_multi_core;
- is_async_gpu = is_multicore || Settings::values.use_asynchronous_gpu_emulation;
+ is_multicore = Settings::values.use_multi_core.GetValue();
+ is_async_gpu = is_multicore || Settings::values.use_asynchronous_gpu_emulation.GetValue();
kernel.SetMulticore(is_multicore);
cpu_manager.SetMulticore(is_multicore);
@@ -162,7 +162,7 @@ struct System::Impl {
const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch());
Settings::values.custom_rtc_differential =
- Settings::values.custom_rtc.value_or(current_time) - current_time;
+ Settings::values.custom_rtc.GetValue().value_or(current_time) - current_time;
// Create a default fs if one doesn't already exist.
if (virtual_filesystem == nullptr)
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index d0c43447c0..c1fbc235ba 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -29,7 +29,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
const float window_aspect_ratio = static_cast<float>(height) / width;
const float emulation_aspect_ratio = EmulationAspectRatio(
- static_cast<AspectRatio>(Settings::values.aspect_ratio), window_aspect_ratio);
+ static_cast<AspectRatio>(Settings::values.aspect_ratio.GetValue()), window_aspect_ratio);
const Common::Rectangle<u32> screen_window_area{0, 0, width, height};
Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index f9d7c024d0..c6fcb56ade 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -123,7 +123,7 @@ std::shared_ptr<Process> Process::Create(Core::System& system, std::string name,
: kernel.CreateNewUserProcessID();
process->capabilities.InitializeForMetadatalessProcess();
- std::mt19937 rng(Settings::values.rng_seed.value_or(0));
+ std::mt19937 rng(Settings::values.rng_seed.GetValue().value_or(0));
std::uniform_int_distribution<u64> distribution;
std::generate(process->random_entropy.begin(), process->random_entropy.end(),
[&] { return distribution(rng); });
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index c688d6d981..256449aa70 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -749,14 +749,14 @@ void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext&
if (Settings::values.use_docked_mode) {
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
} else {
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
}
}
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 7e5ceccdb4..6cfa9666d2 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -366,7 +366,8 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
LOG_DEBUG(Service_NS, "called with supported_languages={:08X}", supported_languages);
// Get language code from settings
- const auto language_code = Set::GetLanguageCodeFromIndex(Settings::values.language_index);
+ const auto language_code =
+ Set::GetLanguageCodeFromIndex(Settings::values.language_index.GetValue());
// Convert to application language, get priority list
const auto application_language = ConvertToApplicationLanguage(language_code);
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index e5cfd21018..34fe2fd82b 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -91,7 +91,7 @@ void GetAvailableLanguageCodesImpl(Kernel::HLERequestContext& ctx, std::size_t m
}
void GetKeyCodeMapImpl(Kernel::HLERequestContext& ctx) {
- const auto language_code = available_language_codes[Settings::values.language_index];
+ const auto language_code = available_language_codes[Settings::values.language_index.GetValue()];
const auto key_code =
std::find_if(language_to_layout.cbegin(), language_to_layout.cend(),
[=](const auto& element) { return element.first == language_code; });
@@ -99,7 +99,7 @@ void GetKeyCodeMapImpl(Kernel::HLERequestContext& ctx) {
if (key_code == language_to_layout.cend()) {
LOG_ERROR(Service_SET,
"Could not find keyboard layout for language index {}, defaulting to English us",
- Settings::values.language_index);
+ Settings::values.language_index.GetValue());
} else {
layout = key_code->second;
}
@@ -163,11 +163,11 @@ void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) {
}
void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index);
+ LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index.GetValue());
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
- rb.PushEnum(available_language_codes[Settings::values.language_index]);
+ rb.PushEnum(available_language_codes[Settings::values.language_index.GetValue()]);
}
void SET::GetRegionCode(Kernel::HLERequestContext& ctx) {
@@ -175,7 +175,7 @@ void SET::GetRegionCode(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS);
- rb.Push(Settings::values.region_index);
+ rb.Push(Settings::values.region_index.GetValue());
}
void SET::GetKeyCodeMap(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp
index e724d4ab80..865ed3b917 100644
--- a/src/core/hle/service/spl/module.cpp
+++ b/src/core/hle/service/spl/module.cpp
@@ -19,7 +19,7 @@ namespace Service::SPL {
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
: ServiceFramework(name), module(std::move(module)),
- rng(Settings::values.rng_seed.value_or(std::time(nullptr))) {}
+ rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {}
Module::Interface::~Interface() = default;
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 1570920746..552a5e4ef1 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -519,9 +519,9 @@ private:
IGBPConnectRequestParcel request{ctx.ReadBuffer()};
IGBPConnectResponseParcel response{
static_cast<u32>(static_cast<u32>(DisplayResolution::UndockedWidth) *
- Settings::values.resolution_factor),
+ Settings::values.resolution_factor.GetValue()),
static_cast<u32>(static_cast<u32>(DisplayResolution::UndockedHeight) *
- Settings::values.resolution_factor)};
+ Settings::values.resolution_factor.GetValue())};
ctx.WriteBuffer(response.Serialize());
break;
}
@@ -748,14 +748,14 @@ private:
if (Settings::values.use_docked_mode) {
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
} else {
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
}
rb.PushRaw<float>(60.0f); // This wouldn't seem to be correct for 30 fps games.
@@ -1029,9 +1029,9 @@ private:
// between docked and undocked dimensions. We take the liberty of applying
// the resolution scaling factor here.
rb.Push(static_cast<u64>(DisplayResolution::UndockedWidth) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
rb.Push(static_cast<u64>(DisplayResolution::UndockedHeight) *
- static_cast<u32>(Settings::values.resolution_factor));
+ static_cast<u32>(Settings::values.resolution_factor.GetValue()));
}
void SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
@@ -1064,8 +1064,8 @@ private:
LOG_WARNING(Service_VI, "(STUBBED) called");
DisplayInfo display_info;
- display_info.width *= static_cast<u64>(Settings::values.resolution_factor);
- display_info.height *= static_cast<u64>(Settings::values.resolution_factor);
+ display_info.width *= static_cast<u64>(Settings::values.resolution_factor.GetValue());
+ display_info.height *= static_cast<u64>(Settings::values.resolution_factor.GetValue());
ctx.WriteBuffer(&display_info, sizeof(DisplayInfo));
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 9f3a6b8113..29339ead7e 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -119,13 +119,14 @@ double PerfStats::GetLastFrameTimeScale() {
}
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
- if (!Settings::values.use_frame_limit || Settings::values.use_multi_core) {
+ if (!Settings::values.use_frame_limit.GetValue() ||
+ Settings::values.use_multi_core.GetValue()) {
return;
}
auto now = Clock::now();
- const double sleep_scale = Settings::values.frame_limit / 100.0;
+ const double sleep_scale = Settings::values.frame_limit.GetValue() / 100.0;
// Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current
// speed percent or it will clamp too much and prevent this from properly limiting to that
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index 56df5e925d..d3886c4ec7 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -62,6 +62,7 @@ const std::array<const char*, NumMouseButtons> mapping = {{
}
Values values = {};
+bool configuring_global = true;
std::string GetTimeZoneString() {
static constexpr std::array<const char*, 46> timezones{{
@@ -73,9 +74,9 @@ std::string GetTimeZoneString() {
"UCT", "Universal", "UTC", "W-SU", "WET", "Zulu",
}};
- ASSERT(Settings::values.time_zone_index < timezones.size());
+ ASSERT(Settings::values.time_zone_index.GetValue() < timezones.size());
- return timezones[Settings::values.time_zone_index];
+ return timezones[Settings::values.time_zone_index.GetValue()];
}
void Apply() {
@@ -97,25 +98,25 @@ void LogSetting(const std::string& name, const T& value) {
void LogSettings() {
LOG_INFO(Config, "yuzu Configuration:");
- LogSetting("System_UseDockedMode", Settings::values.use_docked_mode);
- LogSetting("System_RngSeed", Settings::values.rng_seed.value_or(0));
+ LogSetting("Controls_UseDockedMode", Settings::values.use_docked_mode);
+ LogSetting("System_RngSeed", Settings::values.rng_seed.GetValue().value_or(0));
LogSetting("System_CurrentUser", Settings::values.current_user);
- LogSetting("System_LanguageIndex", Settings::values.language_index);
- LogSetting("System_RegionIndex", Settings::values.region_index);
- LogSetting("System_TimeZoneIndex", Settings::values.time_zone_index);
- LogSetting("Core_UseMultiCore", Settings::values.use_multi_core);
- LogSetting("Renderer_UseResolutionFactor", Settings::values.resolution_factor);
- LogSetting("Renderer_UseFrameLimit", Settings::values.use_frame_limit);
- LogSetting("Renderer_FrameLimit", Settings::values.frame_limit);
- LogSetting("Renderer_UseDiskShaderCache", Settings::values.use_disk_shader_cache);
- LogSetting("Renderer_GPUAccuracyLevel", Settings::values.gpu_accuracy);
+ LogSetting("System_LanguageIndex", Settings::values.language_index.GetValue());
+ LogSetting("System_RegionIndex", Settings::values.region_index.GetValue());
+ LogSetting("System_TimeZoneIndex", Settings::values.time_zone_index.GetValue());
+ LogSetting("Core_UseMultiCore", Settings::values.use_multi_core.GetValue());
+ LogSetting("Renderer_UseResolutionFactor", Settings::values.resolution_factor.GetValue());
+ LogSetting("Renderer_UseFrameLimit", Settings::values.use_frame_limit.GetValue());
+ LogSetting("Renderer_FrameLimit", Settings::values.frame_limit.GetValue());
+ LogSetting("Renderer_UseDiskShaderCache", Settings::values.use_disk_shader_cache.GetValue());
+ LogSetting("Renderer_GPUAccuracyLevel", Settings::values.gpu_accuracy.GetValue());
LogSetting("Renderer_UseAsynchronousGpuEmulation",
- Settings::values.use_asynchronous_gpu_emulation);
- LogSetting("Renderer_UseVsync", Settings::values.use_vsync);
- LogSetting("Renderer_UseAssemblyShaders", Settings::values.use_assembly_shaders);
- LogSetting("Renderer_AnisotropicFilteringLevel", Settings::values.max_anisotropy);
+ Settings::values.use_asynchronous_gpu_emulation.GetValue());
+ LogSetting("Renderer_UseVsync", Settings::values.use_vsync.GetValue());
+ LogSetting("Renderer_UseAssemblyShaders", Settings::values.use_assembly_shaders.GetValue());
+ LogSetting("Renderer_AnisotropicFilteringLevel", Settings::values.max_anisotropy.GetValue());
LogSetting("Audio_OutputEngine", Settings::values.sink_id);
- LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching);
+ LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching.GetValue());
LogSetting("Audio_OutputDevice", Settings::values.audio_device_id);
LogSetting("DataStorage_UseVirtualSd", Settings::values.use_virtual_sd);
LogSetting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
@@ -131,15 +132,56 @@ float Volume() {
if (values.audio_muted) {
return 0.0f;
}
- return values.volume;
+ return values.volume.GetValue();
}
bool IsGPULevelExtreme() {
- return values.gpu_accuracy == GPUAccuracy::Extreme;
+ return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme;
}
bool IsGPULevelHigh() {
- return values.gpu_accuracy == GPUAccuracy::Extreme || values.gpu_accuracy == GPUAccuracy::High;
+ return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme ||
+ values.gpu_accuracy.GetValue() == GPUAccuracy::High;
+}
+
+void RestoreGlobalState() {
+ // If a game is running, DO NOT restore the global settings state
+ if (Core::System::GetInstance().IsPoweredOn()) {
+ return;
+ }
+
+ // Audio
+ values.enable_audio_stretching.SetGlobal(true);
+ values.volume.SetGlobal(true);
+
+ // Core
+ values.use_multi_core.SetGlobal(true);
+
+ // Renderer
+ values.renderer_backend.SetGlobal(true);
+ values.vulkan_device.SetGlobal(true);
+ values.aspect_ratio.SetGlobal(true);
+ values.max_anisotropy.SetGlobal(true);
+ values.use_frame_limit.SetGlobal(true);
+ values.frame_limit.SetGlobal(true);
+ values.use_disk_shader_cache.SetGlobal(true);
+ values.gpu_accuracy.SetGlobal(true);
+ values.use_asynchronous_gpu_emulation.SetGlobal(true);
+ values.use_vsync.SetGlobal(true);
+ values.use_assembly_shaders.SetGlobal(true);
+ values.use_fast_gpu_time.SetGlobal(true);
+ values.force_30fps_mode.SetGlobal(true);
+ values.bg_red.SetGlobal(true);
+ values.bg_green.SetGlobal(true);
+ values.bg_blue.SetGlobal(true);
+
+ // System
+ values.language_index.SetGlobal(true);
+ values.region_index.SetGlobal(true);
+ values.time_zone_index.SetGlobal(true);
+ values.rng_seed.SetGlobal(true);
+ values.custom_rtc.SetGlobal(true);
+ values.sound_index.SetGlobal(true);
}
} // namespace Settings
diff --git a/src/core/settings.h b/src/core/settings.h
index a598ccbc17..850ca4072c 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -382,20 +382,85 @@ enum class GPUAccuracy : u32 {
Extreme = 2,
};
+extern bool configuring_global;
+
+template <typename Type>
+class Setting final {
+public:
+ Setting() = default;
+ explicit Setting(Type val) : global{val} {}
+ ~Setting() = default;
+ void SetGlobal(bool to_global) {
+ use_global = to_global;
+ }
+ bool UsingGlobal() const {
+ return use_global;
+ }
+ Type GetValue(bool need_global = false) const {
+ if (use_global || need_global) {
+ return global;
+ }
+ return local;
+ }
+ void SetValue(const Type& value) {
+ if (use_global) {
+ global = value;
+ } else {
+ local = value;
+ }
+ }
+
+private:
+ bool use_global = true;
+ Type global{};
+ Type local{};
+};
+
struct Values {
+ // Audio
+ std::string audio_device_id;
+ std::string sink_id;
+ bool audio_muted;
+ Setting<bool> enable_audio_stretching;
+ Setting<float> volume;
+
+ // Core
+ Setting<bool> use_multi_core;
+
+ // Renderer
+ Setting<RendererBackend> renderer_backend;
+ bool renderer_debug;
+ Setting<int> vulkan_device;
+
+ Setting<u16> resolution_factor = Setting(static_cast<u16>(1));
+ Setting<int> aspect_ratio;
+ Setting<int> max_anisotropy;
+ Setting<bool> use_frame_limit;
+ Setting<u16> frame_limit;
+ Setting<bool> use_disk_shader_cache;
+ Setting<GPUAccuracy> gpu_accuracy;
+ Setting<bool> use_asynchronous_gpu_emulation;
+ Setting<bool> use_vsync;
+ Setting<bool> use_assembly_shaders;
+ Setting<bool> force_30fps_mode;
+ Setting<bool> use_fast_gpu_time;
+
+ Setting<float> bg_red;
+ Setting<float> bg_green;
+ Setting<float> bg_blue;
+
// System
- bool use_docked_mode;
- std::optional<u32> rng_seed;
+ Setting<std::optional<u32>> rng_seed;
// Measured in seconds since epoch
- std::optional<std::chrono::seconds> custom_rtc;
+ Setting<std::optional<std::chrono::seconds>> custom_rtc;
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
std::chrono::seconds custom_rtc_differential;
s32 current_user;
- s32 language_index;
- s32 region_index;
- s32 time_zone_index;
- s32 sound_index;
+ Setting<s32> language_index;
+ Setting<s32> region_index;
+ Setting<s32> time_zone_index;
+ Setting<s32> sound_index;
// Controls
std::array<PlayerInput, 10> players;
@@ -419,8 +484,7 @@ struct Values {
u16 udp_input_port;
u8 udp_pad_index;
- // Core
- bool use_multi_core;
+ bool use_docked_mode;
// Data Storage
bool use_virtual_sd;
@@ -432,39 +496,6 @@ struct Values {
NANDUserSize nand_user_size;
SDMCSize sdmc_size;
- // Renderer
- RendererBackend renderer_backend;
- bool renderer_debug;
- int vulkan_device;
-
- u16 resolution_factor{1};
- int aspect_ratio;
- int max_anisotropy;
- bool use_frame_limit;
- u16 frame_limit;
- bool use_disk_shader_cache;
- GPUAccuracy gpu_accuracy;
- bool use_asynchronous_gpu_emulation;
- bool use_vsync;
- bool use_assembly_shaders;
- bool force_30fps_mode;
- bool use_fast_gpu_time;
-
- float bg_red;
- float bg_green;
- float bg_blue;
-
- std::string log_filter;
-
- bool use_dev_keys;
-
- // Audio
- bool audio_muted;
- std::string sink_id;
- bool enable_audio_stretching;
- std::string audio_device_id;
- float volume;
-
// Debugging
bool record_frame_times;
bool use_gdbstub;
@@ -477,7 +508,11 @@ struct Values {
bool disable_cpu_opt;
bool disable_macro_jit;
- // BCAT
+ // Misceallaneous
+ std::string log_filter;
+ bool use_dev_keys;
+
+ // Services
std::string bcat_backend;
bool bcat_boxcat_local;
@@ -501,4 +536,7 @@ std::string GetTimeZoneString();
void Apply();
void LogSettings();
+// Restore the global state of all applicable settings in the Values struct
+void RestoreGlobalState();
+
} // namespace Settings
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index c781b3cfcf..78915e6dbe 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -189,19 +189,24 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) {
// Log user configuration information
constexpr auto field_type = Telemetry::FieldType::UserConfig;
AddField(field_type, "Audio_SinkId", Settings::values.sink_id);
- AddField(field_type, "Audio_EnableAudioStretching", Settings::values.enable_audio_stretching);
- AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core);
- AddField(field_type, "Renderer_Backend", TranslateRenderer(Settings::values.renderer_backend));
- AddField(field_type, "Renderer_ResolutionFactor", Settings::values.resolution_factor);
- AddField(field_type, "Renderer_UseFrameLimit", Settings::values.use_frame_limit);
- AddField(field_type, "Renderer_FrameLimit", Settings::values.frame_limit);
- AddField(field_type, "Renderer_UseDiskShaderCache", Settings::values.use_disk_shader_cache);
+ AddField(field_type, "Audio_EnableAudioStretching",
+ Settings::values.enable_audio_stretching.GetValue());
+ AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core.GetValue());
+ AddField(field_type, "Renderer_Backend",
+ TranslateRenderer(Settings::values.renderer_backend.GetValue()));
+ AddField(field_type, "Renderer_ResolutionFactor",
+ Settings::values.resolution_factor.GetValue());
+ AddField(field_type, "Renderer_UseFrameLimit", Settings::values.use_frame_limit.GetValue());
+ AddField(field_type, "Renderer_FrameLimit", Settings::values.frame_limit.GetValue());
+ AddField(field_type, "Renderer_UseDiskShaderCache",
+ Settings::values.use_disk_shader_cache.GetValue());
AddField(field_type, "Renderer_GPUAccuracyLevel",
- TranslateGPUAccuracyLevel(Settings::values.gpu_accuracy));
+ TranslateGPUAccuracyLevel(Settings::values.gpu_accuracy.GetValue()));
AddField(field_type, "Renderer_UseAsynchronousGpuEmulation",
- Settings::values.use_asynchronous_gpu_emulation);
- AddField(field_type, "Renderer_UseVsync", Settings::values.use_vsync);
- AddField(field_type, "Renderer_UseAssemblyShaders", Settings::values.use_assembly_shaders);
+ Settings::values.use_asynchronous_gpu_emulation.GetValue());
+ AddField(field_type, "Renderer_UseVsync", Settings::values.use_vsync.GetValue());
+ AddField(field_type, "Renderer_UseAssemblyShaders",
+ Settings::values.use_assembly_shaders.GetValue());
AddField(field_type, "System_UseDockedMode", Settings::values.use_docked_mode);
}