From b2438f1fb7d083ffe8c8afdc30e9c612631d6ace Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 03:23:36 -0400 Subject: settings: Define specializations for settings Suggests to a frontend how to represent each setting. --- src/common/settings.h | 136 ++++++++++++++++++++++++++--------------- src/common/settings_common.cpp | 11 +++- src/common/settings_common.h | 20 +++++- src/common/settings_setting.h | 27 +++++--- 4 files changed, 130 insertions(+), 64 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index 0ae71dd1b..c78dd85c8 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -128,25 +128,31 @@ struct Values { Linkage linkage{}; // Audio - Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio}; - Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; - Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; + Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio, + Specialization::RuntimeList}; + Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio, + Specialization::RuntimeList}; + Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio, + Specialization::RuntimeList}; SwitchableSetting sound_index{linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, "sound_index", Category::SystemAudio}; - SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio, true, true}; - Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; - Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, - false}; + SwitchableSetting volume{ + linkage, 100, 0, 200, "volume", Category::Audio, Specialization::Scalar, true, true}; + Setting audio_muted{ + linkage, false, "audio_muted", Category::Audio, Specialization::Default, false}; + Setting dump_audio_commands{ + linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; SwitchableSetting use_unsafe_extended_memory_layout{ linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", - Category::Core, false, true}; - SwitchableSetting speed_limit{linkage, 100, 0, 9999, "speed_limit", - Category::Core, true, true}; + SwitchableSetting use_speed_limit{ + linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Core, Specialization::Countable, + true, true}; // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, @@ -192,9 +198,10 @@ struct Values { linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend", Category::Renderer}; SwitchableSetting shader_backend{ - linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, - "shader_backend", Category::Renderer}; - SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer}; + linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, + "shader_backend", Category::Renderer, Specialization::RuntimeList}; + SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer, + Specialization::RuntimeList}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; @@ -206,14 +213,10 @@ struct Values { AstcDecodeMode::CpuAsynchronous, "accelerate_astc", Category::Renderer}; - Setting vsync_mode{linkage, - VSyncMode::Fifo, - VSyncMode::Immediate, - VSyncMode::FifoRelaxed, - "use_vsync", - Category::Renderer, - true, - true}; + Setting vsync_mode{ + linkage, VSyncMode::Fifo, VSyncMode::Immediate, VSyncMode::FifoRelaxed, + "use_vsync", Category::Renderer, Specialization::RuntimeList, true, + true}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, "nvdec_emulation", Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. @@ -228,6 +231,7 @@ struct Values { FullscreenMode::Exclusive, "fullscreen_mode", Category::Renderer, + Specialization::Default, true, true}; SwitchableSetting aspect_ratio{linkage, @@ -236,22 +240,37 @@ struct Values { AspectRatio::Stretch, "aspect_ratio", Category::Renderer, + Specialization::Default, true, true}; ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ - linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; - SwitchableSetting anti_aliasing{ - linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; + SwitchableSetting scaling_filter{linkage, + ScalingFilter::Bilinear, + "scaling_filter", + Category::Renderer, + Specialization::Default, + true, + true}; + SwitchableSetting anti_aliasing{linkage, + AntiAliasing::None, + "anti_aliasing", + Category::Renderer, + Specialization::Default, + true, + true}; SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, Specialization::Scalar, + true, true}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; + SwitchableSetting bg_red{ + linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true}; + SwitchableSetting bg_green{ + linkage, 0, "bg_green", Category::Renderer, Specialization::Default, true, true}; + SwitchableSetting bg_blue{ + linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true}; SwitchableSetting gpu_accuracy{linkage, GpuAccuracy::High, @@ -259,6 +278,7 @@ struct Values { GpuAccuracy::Extreme, "gpu_accuracy", Category::RendererAdvanced, + Specialization::Default, true, true}; SwitchableSetting max_anisotropy{ @@ -279,9 +299,15 @@ struct Values { SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; SwitchableSetting use_fast_gpu_time{ - linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ - linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; + linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, Specialization::Default, + true, true}; + SwitchableSetting use_vulkan_driver_pipeline_cache{linkage, + true, + "use_vulkan_driver_pipeline_cache", + Category::RendererAdvanced, + Specialization::Default, + true, + true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; SwitchableSetting use_video_framerate{linkage, false, "use_video_framerate", @@ -310,15 +336,18 @@ struct Values { TimeZone::Auto, TimeZone::Zulu, "time_zone_index", Category::System}; // Measured in seconds since epoch - SwitchableSetting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", - Category::System, true, true}; - SwitchableSetting custom_rtc{linkage, 0, "custom_rtc", Category::System, true, true}; + SwitchableSetting custom_rtc_enabled{ + linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; + SwitchableSetting custom_rtc{ + linkage, 0, "custom_rtc", Category::System, Specialization::Time, true, true}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; - SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", - Category::System, true, true}; - SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; - Setting device_name{linkage, "yuzu", "device_name", Category::System, true, true}; + SwitchableSetting rng_seed_enabled{ + linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; + SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, Specialization::Hex, + true, true}; + Setting device_name{ + linkage, "yuzu", "device_name", Category::System, Specialization::Default, true, true}; Setting current_user{linkage, 0, "current_user", Category::System}; @@ -327,12 +356,13 @@ struct Values { // Controls InputSetting> players; - Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, + Setting enable_raw_input{ + linkage, false, "enable_raw_input", Category::Controls, Specialization::Default, // Only read/write enable_raw_input on Windows platforms #ifdef _WIN32 - true + true #else - false + false #endif }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; @@ -354,7 +384,8 @@ struct Values { Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; - Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; + Setting mouse_panning{ + linkage, false, "mouse_panning", Category::Controls, Specialization::Default, false}; Setting mouse_panning_sensitivity{ linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; @@ -410,19 +441,24 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, false}; - Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, false}; + Setting dump_shaders{ + linkage, false, "dump_shaders", Category::DebuggingGraphics, Specialization::Default, + false}; + Setting dump_macros{ + linkage, false, "dump_macros", Category::DebuggingGraphics, Specialization::Default, false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; - Setting reporting_services{linkage, false, "reporting_services", Category::Debugging, - false}; + Setting reporting_services{ + linkage, false, "reporting_services", Category::Debugging, Specialization::Default, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; - Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, false}; + Setting extended_logging{ + linkage, false, "extended_logging", Category::Debugging, Specialization::Default, false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; + Setting use_auto_stub{ + linkage, false, "use_auto_stub", Category::Debugging, Specialization::Default, false}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index fb42991fa..3e86c7347 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -7,9 +7,10 @@ namespace Settings { BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_) - : label{name}, category{category_}, id{linkage.count}, save{save_}, runtime_modifiable{ - runtime_modifiable_} { + bool save_, bool runtime_modifiable_, + enum Specialization specialization_) + : label{name}, category{category_}, id{linkage.count}, save{save_}, + runtime_modifiable{runtime_modifiable_}, specialization{specialization_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -38,6 +39,10 @@ Category BasicSetting::Category() const { return category; } +Specialization BasicSetting::Specialization() const { + return specialization; +} + const std::string& BasicSetting::GetLabel() const { return label; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 2b5c72f41..664c807f1 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -43,6 +43,17 @@ enum class Category : u32 { MaxEnum, }; +enum class Specialization : u32 { + Default, + Time, + Hex, + List, + RuntimeList, + Scalar, + Countable, + Paired, +}; + bool IsConfiguringGlobal(); void SetConfiguringGlobal(bool is_global); @@ -64,7 +75,7 @@ public: class BasicSetting { protected: explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_); + bool save_, bool runtime_modifiable_, Specialization spec); public: virtual ~BasicSetting(); @@ -180,6 +191,11 @@ public: */ [[nodiscard]] enum Category Category() const; + /** + * @returns Extra metadata for data representation in frontend implementations. + */ + [[nodiscard]] enum Specialization Specialization() const; + /** * Returns the label this setting was created with. * @@ -219,6 +235,8 @@ private: const bool save; ///< Suggests if the setting should be saved and read to a frontend config const bool runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running + const enum Specialization + specialization; ///< Extra data to identify representation of a setting }; } // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index a0a05da54..9805a5b5d 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -35,10 +35,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) + enum Category category_, + enum Specialization specialization = Specialization::Default, + bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, - default_value{default_val} {} + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + value{default_val}, default_value{default_val} {} virtual ~Setting() = default; /** @@ -53,10 +55,11 @@ public: */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, + enum Specialization specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, - default_value{default_val}, maximum{max_val}, minimum{min_val} {} + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} /** * Returns a reference to the setting's value. @@ -230,10 +233,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category_, bool save_ = true, - bool runtime_modifiable_ = false) + Category category_, + enum Specialization specialization = Specialization::Default, + bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : Setting{linkage, default_val, name, category_, save_, runtime_modifiable_} { + : Setting{linkage, default_val, name, category_, specialization, + save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -250,10 +255,12 @@ public: */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, + enum Specialization specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) - : Setting{linkage, default_val, min_val, max_val, - name, category_, save_, runtime_modifiable_} { + : Setting{linkage, default_val, min_val, + max_val, name, category_, + specialization, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } -- cgit v1.2.3