From 20e51402b0c0221d63c923d049e6a4c706c5e2ba Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 26 Jun 2021 02:43:38 -0400 Subject: [PATCH] common: Force defaults for Settings::Setting's Requires a default value when creating each per-game setting. --- src/common/settings.h | 97 ++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index 82ec18e275..dd2d8d4d8c 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -37,8 +37,9 @@ enum class CPUAccuracy : u32 { template class Setting final { public: - Setting() = default; - explicit Setting(Type val) : global{val} {} + explicit Setting(Type val) : global{val} { + default_value = val; + } ~Setting() = default; void SetGlobal(bool to_global) { use_global = to_global; @@ -59,11 +60,15 @@ public: local = value; } } + Type GetDefault() const { + return default_value; + } private: bool use_global = true; Type global{}; Type local{}; + Type default_value{}; }; /** @@ -108,14 +113,14 @@ struct Values { std::string audio_device_id; std::string sink_id; bool audio_muted; - Setting enable_audio_stretching; - Setting volume; + Setting enable_audio_stretching{true}; + Setting volume{1.0f}; // Core - Setting use_multi_core; + Setting use_multi_core{true}; // Cpu - Setting cpu_accuracy; + Setting cpu_accuracy{CPUAccuracy::Accurate}; bool cpuopt_page_tables; bool cpuopt_block_linking; @@ -127,61 +132,69 @@ struct Values { bool cpuopt_reduce_misalign_checks; bool cpuopt_fastmem; - Setting cpuopt_unsafe_unfuse_fma; - Setting cpuopt_unsafe_reduce_fp_error; - Setting cpuopt_unsafe_ignore_standard_fpcr; - Setting cpuopt_unsafe_inaccurate_nan; - Setting cpuopt_unsafe_fastmem_check; + Setting cpuopt_unsafe_unfuse_fma{true}; + Setting cpuopt_unsafe_reduce_fp_error{true}; + Setting cpuopt_unsafe_ignore_standard_fpcr{true}; + Setting cpuopt_unsafe_inaccurate_nan{true}; + Setting cpuopt_unsafe_fastmem_check{true}; // Renderer - Setting renderer_backend; + Setting renderer_backend{RendererBackend::OpenGL}; bool renderer_debug; - Setting vulkan_device; + Setting vulkan_device{0}; - Setting resolution_factor{1}; - Setting fullscreen_mode; - Setting aspect_ratio; - Setting max_anisotropy; - Setting use_frame_limit; - Setting frame_limit; - Setting use_disk_shader_cache; - Setting gpu_accuracy; - Setting use_asynchronous_gpu_emulation; - Setting use_nvdec_emulation; - Setting accelerate_astc; - Setting use_vsync; - Setting disable_fps_limit; - Setting use_assembly_shaders; - Setting use_asynchronous_shaders; - Setting use_fast_gpu_time; - Setting use_caches_gc; + Setting resolution_factor{0}; + // *nix platforms may have issues with the borderless windowed fullscreen mode. + // Default to exclusive fullscreen on these platforms for now. + Setting fullscreen_mode{ +#ifdef _WIN32 + 0 +#else + 1 +#endif + }; + Setting aspect_ratio{0}; + Setting max_anisotropy{0}; + Setting use_frame_limit{true}; + Setting frame_limit{100}; + Setting use_disk_shader_cache{true}; + Setting gpu_accuracy{GPUAccuracy::High}; + Setting use_asynchronous_gpu_emulation{true}; + Setting use_nvdec_emulation{true}; + Setting accelerate_astc{true}; + Setting use_vsync{true}; + Setting disable_fps_limit{false}; + Setting use_assembly_shaders{false}; + Setting use_asynchronous_shaders{false}; + Setting use_fast_gpu_time{true}; + Setting use_caches_gc{false}; - Setting bg_red; - Setting bg_green; - Setting bg_blue; + Setting bg_red{0.0f}; + Setting bg_green{0.0f}; + Setting bg_blue{0.0f}; // System - Setting> rng_seed; + Setting> rng_seed{std::optional()}; // Measured in seconds since epoch std::optional 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; - Setting language_index; - Setting region_index; - Setting time_zone_index; - Setting sound_index; + Setting language_index{1}; + Setting region_index{1}; + Setting time_zone_index{0}; + Setting sound_index{1}; // Controls InputSetting> players; - Setting use_docked_mode; + Setting use_docked_mode{true}; - Setting vibration_enabled; - Setting enable_accurate_vibrations; + Setting vibration_enabled{true}; + Setting enable_accurate_vibrations{false}; - Setting motion_enabled; + Setting motion_enabled{true}; std::string motion_device; std::string udp_input_servers;