early-access version 1838

This commit is contained in:
pineappleEA 2021-07-01 14:23:06 +02:00
parent 7482a950d9
commit 755af6b65b
40 changed files with 754 additions and 912 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 1837. This is the source code for early-access 1838.
## Legal Notice ## Legal Notice

View File

@ -30,8 +30,7 @@ StreamPtr AudioOut::OpenStream(Core::Timing::CoreTiming& core_timing, u32 sample
u32 num_channels, std::string&& name, u32 num_channels, std::string&& name,
Stream::ReleaseCallback&& release_callback) { Stream::ReleaseCallback&& release_callback) {
if (!sink) { if (!sink) {
sink = CreateSinkFromID(Settings::values.sink_id.GetValue(), sink = CreateSinkFromID(Settings::values.sink_id, Settings::values.audio_device_id);
Settings::values.audio_device_id.GetValue());
} }
return std::make_shared<Stream>( return std::make_shared<Stream>(

View File

@ -41,7 +41,7 @@ void LogSettings() {
LOG_INFO(Config, "yuzu Configuration:"); LOG_INFO(Config, "yuzu Configuration:");
log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue()); log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue());
log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0)); log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0));
log_setting("System_CurrentUser", values.current_user.GetValue()); log_setting("System_CurrentUser", values.current_user);
log_setting("System_LanguageIndex", values.language_index.GetValue()); log_setting("System_LanguageIndex", values.language_index.GetValue());
log_setting("System_RegionIndex", values.region_index.GetValue()); log_setting("System_RegionIndex", values.region_index.GetValue());
log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue());
@ -61,18 +61,18 @@ void LogSettings() {
log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
log_setting("Renderer_UseGarbageCollection", values.use_caches_gc.GetValue()); log_setting("Renderer_UseGarbageCollection", values.use_caches_gc.GetValue());
log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
log_setting("Audio_OutputEngine", values.sink_id.GetValue()); log_setting("Audio_OutputEngine", values.sink_id);
log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue()); log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue());
log_setting("Audio_OutputDevice", values.audio_device_id.GetValue()); log_setting("Audio_OutputDevice", values.audio_device_id);
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue()); log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir)); log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir));
log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir)); log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir));
log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir)); log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir));
log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir)); log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir));
log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir));
log_setting("Debugging_ProgramArgs", values.program_args.GetValue()); log_setting("Debugging_ProgramArgs", values.program_args);
log_setting("Services_BCATBackend", values.bcat_backend.GetValue()); log_setting("Services_BCATBackend", values.bcat_backend);
log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local.GetValue()); log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local);
} }
bool IsConfiguringGlobal() { bool IsConfiguringGlobal() {
@ -94,7 +94,7 @@ bool IsGPULevelHigh() {
bool IsFastmemEnabled() { bool IsFastmemEnabled() {
if (values.cpu_accuracy.GetValue() == CPUAccuracy::DebugMode) { if (values.cpu_accuracy.GetValue() == CPUAccuracy::DebugMode) {
return static_cast<bool>(values.cpuopt_fastmem); return values.cpuopt_fastmem;
} }
return true; return true;
} }

View File

@ -10,12 +10,10 @@
#include <map> #include <map>
#include <optional> #include <optional>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/settings_input.h" #include "common/settings_input.h"
#include "input_common/udp/client.h"
namespace Settings { namespace Settings {
@ -36,236 +34,68 @@ enum class CPUAccuracy : u32 {
DebugMode = 2, DebugMode = 2,
}; };
/** The BasicSetting class is a simple resource manager. It defines a label and default value
* alongside the actual value of the setting for simpler and less-error prone use with frontend
* configurations. Setting a default value and label is required, though subclasses may deviate from
* this requirement.
*/
template <typename Type> template <typename Type>
class BasicSetting { class Setting final {
protected:
BasicSetting() = default;
/**
* Only sets the setting to the given initializer, leaving the other members to their default
* initializers.
*
* @param global_val Initial value of the setting
*/
explicit BasicSetting(const Type& global_val) : global{global_val} {}
public: public:
/** Setting() = default;
* Sets a default value, label, and setting value. explicit Setting(Type val) : global{val} {}
*
* @param default_val Intial value of the setting, and default value of the setting
* @param name Label for the setting
*/
explicit BasicSetting(const Type& default_val, const std::string& name)
: default_value{default_val}, global{default_val}, label{name} {}
~BasicSetting() = default;
/**
* Returns a reference to the setting's value.
*
* @returns A reference to the setting
*/
[[nodiscard]] const Type& GetValue() const {
return global;
}
/**
* Sets the setting to the given value.
*
* @param value The desired value
*/
void SetValue(const Type& value) {
Type temp{value};
std::swap(global, temp);
}
/**
* Returns the value that this setting was created with.
*
* @returns A reference to the default value
*/
[[nodiscard]] const Type& GetDefault() const {
return default_value;
}
/**
* Returns the label this setting was created with.
*
* @returns A reference to the label
*/
[[nodiscard]] const std::string& GetLabel() const {
return label;
}
/**
* Assigns a value to the setting.
*
* @param value The desired setting value
*
* @returns A reference to the setting
*/
const Type& operator=(const Type& value) {
Type temp{value};
std::swap(global, temp);
return global;
}
/**
* Returns a reference to the setting.
*
* @returns A reference to the setting
*/
explicit operator const Type&() const {
return global;
}
protected:
const Type default_value{}; ///< The default value
Type global{}; ///< The setting
const std::string label{}; ///< The setting's label
};
/**
* The Setting class is a slightly more complex version of the BasicSetting class. This adds a
* custom setting to switch to when a guest application specifically requires it. The effect is that
* other components of the emulator can access the setting's intended value without any need for the
* component to ask whether the custom or global setting is needed at the moment.
*
* By default, the global setting is used.
*
* Like the BasicSetting, this requires setting a default value and label to use.
*/
template <typename Type>
class Setting final : public BasicSetting<Type> {
public:
/**
* Sets a default value, label, and setting value.
*
* @param default_val Intial value of the setting, and default value of the setting
* @param name Label for the setting
*/
explicit Setting(const Type& default_val, const std::string& name)
: BasicSetting<Type>(default_val, name) {}
~Setting() = default; ~Setting() = default;
/**
* Tells this setting to represent either the global or custom setting when other member
* functions are used. Setting to_global to true means using the global setting, to false
* false for the custom setting.
*
* @param to_global Whether to use the global or custom setting.
*/
void SetGlobal(bool to_global) { void SetGlobal(bool to_global) {
use_global = to_global; use_global = to_global;
} }
bool UsingGlobal() const {
/**
* Returns whether this setting is using the global setting or not.
*
* @returns The global state
*/
[[nodiscard]] bool UsingGlobal() const {
return use_global; return use_global;
} }
Type GetValue(bool need_global = false) const {
/**
* Returns either the global or custom setting depending on the values of this setting's global
* state or if the global value was specifically requested.
*
* @param need_global Request global value regardless of setting's state; defaults to false
*
* @returns The required value of the setting
*/
[[nodiscard]] const Type& GetValue(bool need_global = false) const {
if (use_global || need_global) { if (use_global || need_global) {
return this->global; return global;
} }
return custom; return local;
} }
/**
* Sets the current setting value depending on the global state.
*
* @param value The new value
*/
void SetValue(const Type& value) { void SetValue(const Type& value) {
Type temp{value};
if (use_global) { if (use_global) {
std::swap(this->global, temp); global = value;
} else { } else {
std::swap(custom, temp); local = value;
} }
} }
/**
* Assigns the current setting value depending on the global state.
*
* @param value The new value
*
* @returns A reference to the current setting value
*/
const Type& operator=(const Type& value) {
Type temp{value};
if (use_global) {
std::swap(this->global, temp);
return this->global;
}
std::swap(custom, temp);
return custom;
}
/**
* Returns the current setting value depending on the global state.
*
* @returns A reference to the current setting value
*/
explicit operator const Type&() const {
if (use_global) {
return this->global;
}
return custom;
}
private: private:
bool use_global{true}; ///< The setting's global state bool use_global = true;
Type custom{}; ///< The custom value of the setting Type global{};
Type local{};
}; };
/** /**
* The InputSetting class allows for getting a reference to either the global or custom members. * The InputSetting class allows for getting a reference to either the global or local members.
* This is required as we cannot easily modify the values of user-defined types within containers * This is required as we cannot easily modify the values of user-defined types within containers
* using the SetValue() member function found in the Setting class. The primary purpose of this * using the SetValue() member function found in the Setting class. The primary purpose of this
* class is to store an array of 10 PlayerInput structs for both the global and custom setting and * class is to store an array of 10 PlayerInput structs for both the global and local (per-game)
* allows for easily accessing and modifying both settings. * setting and allows for easily accessing and modifying both settings.
*/ */
template <typename Type> template <typename Type>
class InputSetting final { class InputSetting final {
public: public:
InputSetting() = default; InputSetting() = default;
explicit InputSetting(Type val) : BasicSetting<Type>(val) {} explicit InputSetting(Type val) : global{val} {}
~InputSetting() = default; ~InputSetting() = default;
void SetGlobal(bool to_global) { void SetGlobal(bool to_global) {
use_global = to_global; use_global = to_global;
} }
[[nodiscard]] bool UsingGlobal() const { bool UsingGlobal() const {
return use_global; return use_global;
} }
[[nodiscard]] Type& GetValue(bool need_global = false) { Type& GetValue(bool need_global = false) {
if (use_global || need_global) { if (use_global || need_global) {
return global; return global;
} }
return custom; return local;
} }
private: private:
bool use_global{true}; ///< The setting's global state bool use_global = true;
Type global{}; ///< The setting Type global{};
Type custom{}; ///< The custom setting value Type local{};
}; };
struct TouchFromButtonMap { struct TouchFromButtonMap {
@ -275,155 +105,144 @@ struct TouchFromButtonMap {
struct Values { struct Values {
// Audio // Audio
BasicSetting<std::string> audio_device_id{"auto", "output_device"}; std::string audio_device_id;
BasicSetting<std::string> sink_id{"auto", "output_engine"}; std::string sink_id;
BasicSetting<bool> audio_muted{false, "audio_muted"}; bool audio_muted;
Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"}; Setting<bool> enable_audio_stretching;
Setting<float> volume{1.0f, "volume"}; Setting<float> volume;
// Core // Core
Setting<bool> use_multi_core{true, "use_multi_core"}; Setting<bool> use_multi_core;
// Cpu // Cpu
Setting<CPUAccuracy> cpu_accuracy{CPUAccuracy::Accurate, "cpu_accuracy"}; Setting<CPUAccuracy> cpu_accuracy;
BasicSetting<bool> cpuopt_page_tables{true, "cpuopt_page_tables"}; bool cpuopt_page_tables;
BasicSetting<bool> cpuopt_block_linking{true, "cpuopt_block_linking"}; bool cpuopt_block_linking;
BasicSetting<bool> cpuopt_return_stack_buffer{true, "cpuopt_return_stack_buffer"}; bool cpuopt_return_stack_buffer;
BasicSetting<bool> cpuopt_fast_dispatcher{true, "cpuopt_fast_dispatcher"}; bool cpuopt_fast_dispatcher;
BasicSetting<bool> cpuopt_context_elimination{true, "cpuopt_context_elimination"}; bool cpuopt_context_elimination;
BasicSetting<bool> cpuopt_const_prop{true, "cpuopt_const_prop"}; bool cpuopt_const_prop;
BasicSetting<bool> cpuopt_misc_ir{true, "cpuopt_misc_ir"}; bool cpuopt_misc_ir;
BasicSetting<bool> cpuopt_reduce_misalign_checks{true, "cpuopt_reduce_misalign_checks"}; bool cpuopt_reduce_misalign_checks;
BasicSetting<bool> cpuopt_fastmem{true, "cpuopt_fastmem"}; bool cpuopt_fastmem;
Setting<bool> cpuopt_unsafe_unfuse_fma{true, "cpuopt_unsafe_unfuse_fma"}; Setting<bool> cpuopt_unsafe_unfuse_fma;
Setting<bool> cpuopt_unsafe_reduce_fp_error{true, "cpuopt_unsafe_reduce_fp_error"}; Setting<bool> cpuopt_unsafe_reduce_fp_error;
Setting<bool> cpuopt_unsafe_ignore_standard_fpcr{true, "cpuopt_unsafe_ignore_standard_fpcr"}; Setting<bool> cpuopt_unsafe_ignore_standard_fpcr;
Setting<bool> cpuopt_unsafe_inaccurate_nan{true, "cpuopt_unsafe_inaccurate_nan"}; Setting<bool> cpuopt_unsafe_inaccurate_nan;
Setting<bool> cpuopt_unsafe_fastmem_check{true, "cpuopt_unsafe_fastmem_check"}; Setting<bool> cpuopt_unsafe_fastmem_check;
// Renderer // Renderer
Setting<RendererBackend> renderer_backend{RendererBackend::OpenGL, "backend"}; Setting<RendererBackend> renderer_backend;
BasicSetting<bool> renderer_debug{false, "debug"}; bool renderer_debug;
Setting<int> vulkan_device{0, "vulkan_device"}; Setting<int> vulkan_device;
Setting<u16> resolution_factor{0, "resolution_factor"}; Setting<u16> resolution_factor{1};
// *nix platforms may have issues with the borderless windowed fullscreen mode. Setting<int> fullscreen_mode;
// Default to exclusive fullscreen on these platforms for now. Setting<int> aspect_ratio;
Setting<int> fullscreen_mode{ Setting<int> max_anisotropy;
#ifdef _WIN32 Setting<bool> use_frame_limit;
0, Setting<u16> frame_limit;
#else Setting<bool> use_disk_shader_cache;
1, Setting<GPUAccuracy> gpu_accuracy;
#endif Setting<bool> use_asynchronous_gpu_emulation;
"fullscreen_mode"}; Setting<bool> use_nvdec_emulation;
Setting<int> aspect_ratio{0, "aspect_ratio"}; Setting<bool> accelerate_astc;
Setting<int> max_anisotropy{0, "max_anisotropy"}; Setting<bool> use_vsync;
Setting<bool> use_frame_limit{true, "use_frame_limit"}; Setting<bool> disable_fps_limit;
Setting<u16> frame_limit{100, "frame_limit"}; Setting<bool> use_assembly_shaders;
Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; Setting<bool> use_asynchronous_shaders;
Setting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High, "gpu_accuracy"}; Setting<bool> use_fast_gpu_time;
Setting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; Setting<bool> use_caches_gc;
Setting<bool> use_nvdec_emulation{true, "use_nvdec_emulation"};
Setting<bool> accelerate_astc{true, "accelerate_astc"};
Setting<bool> use_vsync{true, "use_vsync"};
Setting<bool> disable_fps_limit{false, "disable_fps_limit"};
Setting<bool> use_assembly_shaders{false, "use_assembly_shaders"};
Setting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"};
Setting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"};
Setting<bool> use_caches_gc{false, "use_caches_gc"};
Setting<float> bg_red{0.0f, "bg_red"}; Setting<float> bg_red;
Setting<float> bg_green{0.0f, "bg_green"}; Setting<float> bg_green;
Setting<float> bg_blue{0.0f, "bg_blue"}; Setting<float> bg_blue;
// System // System
Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; Setting<std::optional<u32>> rng_seed;
// Measured in seconds since epoch // Measured in seconds since epoch
std::optional<std::chrono::seconds> custom_rtc; std::optional<std::chrono::seconds> custom_rtc;
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
std::chrono::seconds custom_rtc_differential; std::chrono::seconds custom_rtc_differential;
BasicSetting<s32> current_user{0, "current_user"}; s32 current_user;
Setting<s32> language_index{1, "language_index"}; Setting<s32> language_index;
Setting<s32> region_index{1, "region_index"}; Setting<s32> region_index;
Setting<s32> time_zone_index{0, "time_zone_index"}; Setting<s32> time_zone_index;
Setting<s32> sound_index{1, "sound_index"}; Setting<s32> sound_index;
// Controls // Controls
InputSetting<std::array<PlayerInput, 10>> players; InputSetting<std::array<PlayerInput, 10>> players;
Setting<bool> use_docked_mode{true, "use_docked_mode"}; Setting<bool> use_docked_mode;
Setting<bool> vibration_enabled{true, "vibration_enabled"}; Setting<bool> vibration_enabled;
Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; Setting<bool> enable_accurate_vibrations;
Setting<bool> motion_enabled{true, "motion_enabled"}; Setting<bool> motion_enabled;
BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01", std::string motion_device;
"motion_device"}; std::string udp_input_servers;
BasicSetting<std::string> udp_input_servers{InputCommon::CemuhookUDP::DEFAULT_SRV,
"udp_input_servers"};
BasicSetting<bool> mouse_panning{false, "mouse_panning"}; bool mouse_panning;
BasicSetting<float> mouse_panning_sensitivity{1.0f, "mouse_panning_sensitivity"}; float mouse_panning_sensitivity;
BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; bool mouse_enabled;
std::string mouse_device; std::string mouse_device;
MouseButtonsRaw mouse_buttons; MouseButtonsRaw mouse_buttons;
BasicSetting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; bool emulate_analog_keyboard;
BasicSetting<bool> keyboard_enabled{false, "keyboard_enabled"}; bool keyboard_enabled;
KeyboardKeysRaw keyboard_keys; KeyboardKeysRaw keyboard_keys;
KeyboardModsRaw keyboard_mods; KeyboardModsRaw keyboard_mods;
BasicSetting<bool> debug_pad_enabled{false, "debug_pad_enabled"}; bool debug_pad_enabled;
ButtonsRaw debug_pad_buttons; ButtonsRaw debug_pad_buttons;
AnalogsRaw debug_pad_analogs; AnalogsRaw debug_pad_analogs;
TouchscreenInput touchscreen; TouchscreenInput touchscreen;
BasicSetting<bool> use_touch_from_button{false, "use_touch_from_button"}; bool use_touch_from_button;
BasicSetting<std::string> touch_device{"min_x:100,min_y:50,max_x:1800,max_y:850", std::string touch_device;
"touch_device"}; int touch_from_button_map_index;
BasicSetting<int> touch_from_button_map_index{0, "touch_from_button_map"};
std::vector<TouchFromButtonMap> touch_from_button_maps; std::vector<TouchFromButtonMap> touch_from_button_maps;
std::atomic_bool is_device_reload_pending{true}; std::atomic_bool is_device_reload_pending{true};
// Data Storage // Data Storage
BasicSetting<bool> use_virtual_sd{true, "use_virtual_sd"}; bool use_virtual_sd;
BasicSetting<bool> gamecard_inserted{false, "gamecard_inserted"}; bool gamecard_inserted;
BasicSetting<bool> gamecard_current_game{false, "gamecard_current_game"}; bool gamecard_current_game;
BasicSetting<std::string> gamecard_path{std::string(), "gamecard_path"}; std::string gamecard_path;
// Debugging // Debugging
bool record_frame_times; bool record_frame_times;
BasicSetting<bool> use_gdbstub{false, "use_gdbstub"}; bool use_gdbstub;
BasicSetting<u16> gdbstub_port{0, "gdbstub_port"}; u16 gdbstub_port;
BasicSetting<std::string> program_args{std::string(), "program_args"}; std::string program_args;
BasicSetting<bool> dump_exefs{false, "dump_exefs"}; bool dump_exefs;
BasicSetting<bool> dump_nso{false, "dump_nso"}; bool dump_nso;
BasicSetting<bool> enable_fs_access_log{false, "enable_fs_access_log"}; bool enable_fs_access_log;
BasicSetting<bool> reporting_services{false, "reporting_services"}; bool reporting_services;
BasicSetting<bool> quest_flag{false, "quest_flag"}; bool quest_flag;
BasicSetting<bool> disable_macro_jit{false, "disable_macro_jit"}; bool disable_macro_jit;
BasicSetting<bool> extended_logging{false, "extended_logging"}; bool extended_logging;
BasicSetting<bool> use_debug_asserts{false, "use_debug_asserts"}; bool use_debug_asserts;
BasicSetting<bool> use_auto_stub{false, "use_auto_stub"}; bool use_auto_stub;
// Miscellaneous // Miscellaneous
BasicSetting<std::string> log_filter{"*:Info", "log_filter"}; std::string log_filter;
BasicSetting<bool> use_dev_keys{false, "use_dev_keys"}; bool use_dev_keys;
// Services // Services
BasicSetting<std::string> bcat_backend{"none", "bcat_backend"}; std::string bcat_backend;
BasicSetting<bool> bcat_boxcat_local{false, "bcat_boxcat_local"}; bool bcat_boxcat_local;
// WebService // WebService
BasicSetting<bool> enable_telemetry{true, "enable_telemetry"}; bool enable_telemetry;
BasicSetting<std::string> web_api_url{"https://api.yuzu-emu.org", "web_api_url"}; std::string web_api_url;
BasicSetting<std::string> yuzu_username{std::string(), "yuzu_username"}; std::string yuzu_username;
BasicSetting<std::string> yuzu_token{std::string(), "yuzu_token"}; std::string yuzu_token;
// Add-Ons // Add-Ons
std::map<u64, std::vector<std::string>> disabled_addons; std::map<u64, std::vector<std::string>> disabled_addons;

View File

@ -263,9 +263,9 @@ struct System::Impl {
if (Settings::values.gamecard_inserted) { if (Settings::values.gamecard_inserted) {
if (Settings::values.gamecard_current_game) { if (Settings::values.gamecard_current_game) {
fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath)); fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath));
} else if (!Settings::values.gamecard_path.GetValue().empty()) { } else if (!Settings::values.gamecard_path.empty()) {
fs_controller.SetGameCard(GetGameFileFromPath( fs_controller.SetGameCard(
virtual_filesystem, static_cast<std::string>(Settings::values.gamecard_path))); GetGameFileFromPath(virtual_filesystem, Settings::values.gamecard_path));
} }
} }

View File

@ -13,7 +13,7 @@ ProfileSelectApplet::~ProfileSelectApplet() = default;
void DefaultProfileSelectApplet::SelectProfile( void DefaultProfileSelectApplet::SelectProfile(
std::function<void(std::optional<Common::UUID>)> callback) const { std::function<void(std::optional<Common::UUID>)> callback) const {
Service::Account::ProfileManager manager; Service::Account::ProfileManager manager;
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); callback(manager.GetUser(Settings::values.current_user).value_or(Common::UUID{}));
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
} }

View File

@ -48,8 +48,7 @@ ProfileManager::ProfileManager() {
CreateNewUser(UUID::Generate(), "yuzu"); CreateNewUser(UUID::Generate(), "yuzu");
} }
auto current = auto current = std::clamp<int>(Settings::values.current_user, 0, MAX_USERS - 1);
std::clamp<int>(static_cast<s32>(Settings::values.current_user), 0, MAX_USERS - 1);
// If user index don't exist. Load the first user and change the active user // If user index don't exist. Load the first user and change the active user
if (!UserExistsIndex(current)) { if (!UserExistsIndex(current)) {

View File

@ -1443,7 +1443,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
params.is_account_selected = 1; params.is_account_selected = 1;
Account::ProfileManager profile_manager{}; Account::ProfileManager profile_manager{};
const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user)); const auto uuid = profile_manager.GetUser(Settings::values.current_user);
ASSERT(uuid); ASSERT(uuid);
params.current_user = uuid->uuid; params.current_user = uuid->uuid;

View File

@ -579,7 +579,7 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system, std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system,
DirectoryGetter getter) { DirectoryGetter getter) {
#ifdef YUZU_ENABLE_BOXCAT #ifdef YUZU_ENABLE_BOXCAT
if (Settings::values.bcat_backend.GetValue() == "boxcat") { if (Settings::values.bcat_backend == "boxcat") {
return std::make_unique<Boxcat>(system.GetAppletManager(), std::move(getter)); return std::make_unique<Boxcat>(system.GetAppletManager(), std::move(getter));
} }
#endif #endif

View File

@ -179,7 +179,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
if (Settings::values.bcat_backend.GetValue() == "none") { if (Settings::values.bcat_backend == "none") {
rb.PushEnum(RequestState::NotSubmitted); rb.PushEnum(RequestState::NotSubmitted);
} else { } else {
rb.PushEnum(RequestState::Connected); rb.PushEnum(RequestState::Connected);
@ -384,7 +384,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
if (Settings::values.bcat_backend.GetValue() == "none") { if (Settings::values.bcat_backend == "none") {
rb.Push<u8>(0); rb.Push<u8>(0);
} else { } else {
rb.Push<u8>(1); rb.Push<u8>(1);
@ -395,7 +395,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
if (Settings::values.bcat_backend.GetValue() == "none") { if (Settings::values.bcat_backend == "none") {
rb.Push<u8>(0); rb.Push<u8>(0);
} else { } else {
rb.Push<u8>(1); rb.Push<u8>(1);

View File

@ -160,7 +160,7 @@ void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(Settings::values.quest_flag.GetValue())); rb.Push(static_cast<u32>(Settings::values.quest_flag));
} }
void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) { void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) {

View File

@ -155,8 +155,8 @@ static bool LoadNroImpl(Kernel::KProcess& process, const std::vector<u8>& data)
codeset.segments[i].size = PageAlignSize(nro_header.segments[i].size); codeset.segments[i].size = PageAlignSize(nro_header.segments[i].size);
} }
if (!Settings::values.program_args.GetValue().empty()) { if (!Settings::values.program_args.empty()) {
const auto arg_data = Settings::values.program_args.GetValue(); const auto arg_data = Settings::values.program_args;
codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
NSOArgumentHeader args_header{ NSOArgumentHeader args_header{
NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}}; NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}};

View File

@ -104,8 +104,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
codeset.segments[i].size = nso_header.segments[i].size; codeset.segments[i].size = nso_header.segments[i].size;
} }
if (should_pass_arguments && !Settings::values.program_args.GetValue().empty()) { if (should_pass_arguments && !Settings::values.program_args.empty()) {
const auto arg_data{Settings::values.program_args.GetValue()}; const auto arg_data{Settings::values.program_args};
codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
NSOArgumentHeader args_header{ NSOArgumentHeader args_header{

View File

@ -397,7 +397,7 @@ void Reporter::ClearFSAccessLog() const {
} }
bool Reporter::IsReportingEnabled() const { bool Reporter::IsReportingEnabled() const {
return Settings::values.reporting_services.GetValue(); return Settings::values.reporting_services;
} }
} // namespace Core } // namespace Core

View File

@ -135,7 +135,7 @@ u64 RegenerateTelemetryId() {
bool VerifyLogin(const std::string& username, const std::string& token) { bool VerifyLogin(const std::string& username, const std::string& token) {
#ifdef ENABLE_WEB_SERVICE #ifdef ENABLE_WEB_SERVICE
return WebService::VerifyLogin(Settings::values.web_api_url.GetValue(), username, token); return WebService::VerifyLogin(Settings::values.web_api_url, username, token);
#else #else
return false; return false;
#endif #endif
@ -152,8 +152,7 @@ TelemetrySession::~TelemetrySession() {
#ifdef ENABLE_WEB_SERVICE #ifdef ENABLE_WEB_SERVICE
auto backend = std::make_unique<WebService::TelemetryJson>( auto backend = std::make_unique<WebService::TelemetryJson>(
Settings::values.web_api_url.GetValue(), Settings::values.yuzu_username.GetValue(), Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token);
Settings::values.yuzu_token.GetValue());
#else #else
auto backend = std::make_unique<Telemetry::NullVisitor>(); auto backend = std::make_unique<Telemetry::NullVisitor>();
#endif #endif
@ -213,7 +212,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
// Log user configuration information // Log user configuration information
constexpr auto field_type = Telemetry::FieldType::UserConfig; constexpr auto field_type = Telemetry::FieldType::UserConfig;
AddField(field_type, "Audio_SinkId", Settings::values.sink_id.GetValue()); AddField(field_type, "Audio_SinkId", Settings::values.sink_id);
AddField(field_type, "Audio_EnableAudioStretching", AddField(field_type, "Audio_EnableAudioStretching",
Settings::values.enable_audio_stretching.GetValue()); Settings::values.enable_audio_stretching.GetValue());
AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core.GetValue()); AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core.GetValue());
@ -243,8 +242,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
bool TelemetrySession::SubmitTestcase() { bool TelemetrySession::SubmitTestcase() {
#ifdef ENABLE_WEB_SERVICE #ifdef ENABLE_WEB_SERVICE
auto backend = std::make_unique<WebService::TelemetryJson>( auto backend = std::make_unique<WebService::TelemetryJson>(
Settings::values.web_api_url.GetValue(), Settings::values.yuzu_username.GetValue(), Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token);
Settings::values.yuzu_token.GetValue());
field_collection.Accept(*backend); field_collection.Accept(*backend);
return backend->SubmitTestcase(); return backend->SubmitTestcase();
#else #else

View File

@ -84,8 +84,7 @@ public:
std::lock_guard lock{mutex}; std::lock_guard lock{mutex};
const auto axis_value = const auto axis_value =
static_cast<float>(mouse_input->GetMouseState(button).axis.at(axis)); static_cast<float>(mouse_input->GetMouseState(button).axis.at(axis));
return axis_value * Settings::values.mouse_panning_sensitivity.GetValue() / return axis_value * Settings::values.mouse_panning_sensitivity / (100.0f * range);
(100.0f * range);
} }
std::pair<float, float> GetAnalog(u32 analog_axis_x, u32 analog_axis_y) const { std::pair<float, float> GetAnalog(u32 analog_axis_x, u32 analog_axis_y) const {

View File

@ -13,7 +13,7 @@ class TouchFromButtonDevice final : public Input::TouchDevice {
public: public:
TouchFromButtonDevice() { TouchFromButtonDevice() {
const auto button_index = const auto button_index =
static_cast<u64>(Settings::values.touch_from_button_map_index.GetValue()); static_cast<std::size_t>(Settings::values.touch_from_button_map_index);
const auto& buttons = Settings::values.touch_from_button_maps[button_index].buttons; const auto& buttons = Settings::values.touch_from_button_maps[button_index].buttons;
for (const auto& config_entry : buttons) { for (const auto& config_entry : buttons) {

View File

@ -201,7 +201,7 @@ bool Client::DeviceConnected(std::size_t pad) const {
void Client::ReloadSockets() { void Client::ReloadSockets() {
Reset(); Reset();
std::stringstream servers_ss(static_cast<std::string>(Settings::values.udp_input_servers)); std::stringstream servers_ss(Settings::values.udp_input_servers);
std::string server_token; std::string server_token;
std::size_t client = 0; std::size_t client = 0;
while (std::getline(servers_ss, server_token, ',')) { while (std::getline(servers_ss, server_token, ',')) {
@ -370,7 +370,7 @@ std::optional<std::size_t> Client::GetUnusedFingerID() const {
void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id) { void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id) {
// TODO: Use custom calibration per device // TODO: Use custom calibration per device
const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); const Common::ParamPackage touch_param(Settings::values.touch_device);
const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100)); const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100));
const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50)); const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50));
const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800)); const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800));

View File

@ -103,7 +103,7 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
gpu(gpu_), gpu(gpu_),
library(OpenLibrary()), library(OpenLibrary()),
instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
true, Settings::values.renderer_debug.GetValue())), true, Settings::values.renderer_debug)),
debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr),
surface(CreateSurface(instance, render_window)), surface(CreateSurface(instance, render_window)),
device(CreateDevice(instance, dld, *surface)), device(CreateDevice(instance, dld, *surface)),

View File

@ -272,87 +272,6 @@ void Config::Initialize(const std::string& config_name) {
} }
} }
/* {Read,Write}BasicSetting and WriteGlobalSetting templates must be defined here before their
* usages later in this file. This allows explicit definition of some types that don't work
* nicely with the general version.
*/
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant, nor
// can it implicitly convert a QVariant back to a {std::,Q}string
template <>
void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
setting.SetValue(setting.GetDefault());
} else {
setting.SetValue(qt_config->value(name, QString::fromStdString(setting.GetDefault()))
.toString()
.toStdString());
}
}
template <typename Type>
void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
setting.SetValue(setting.GetDefault());
} else {
setting.SetValue(
static_cast<QVariant>(qt_config->value(name, setting.GetDefault())).value<Type>());
}
}
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant
template <>
void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue() == setting.GetDefault());
qt_config->setValue(name, QString::fromStdString(setting.GetValue()));
}
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
template <>
void Config::WriteBasicSetting(const Settings::BasicSetting<float>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const double value = setting.GetValue();
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue() == setting.GetDefault());
qt_config->setValue(name, value);
}
template <typename Type>
void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue() == setting.GetDefault());
qt_config->setValue(name, setting.GetValue());
}
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
template <>
void Config::WriteGlobalSetting(const Settings::Setting<float>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const double value = setting.GetValue(global);
if (!global) {
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
}
if (global || !setting.UsingGlobal()) {
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue(global) == setting.GetDefault());
qt_config->setValue(name, value);
}
}
template <typename Type>
void Config::WriteGlobalSetting(const Settings::Setting<Type>& setting) {
QString name = QString::fromStdString(setting.GetLabel());
if (!global) {
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
}
if (global || !setting.UsingGlobal()) {
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue(global) == setting.GetDefault());
qt_config->setValue(name, setting.GetValue(global));
}
}
void Config::ReadPlayerValue(std::size_t player_index) { void Config::ReadPlayerValue(std::size_t player_index) {
const QString player_prefix = [this, player_index] { const QString player_prefix = [this, player_index] {
if (type == ConfigType::InputProfile) { if (type == ConfigType::InputProfile) {
@ -476,7 +395,8 @@ void Config::ReadPlayerValue(std::size_t player_index) {
} }
void Config::ReadDebugValues() { void Config::ReadDebugValues() {
ReadBasicSetting(Settings::values.debug_pad_enabled); Settings::values.debug_pad_enabled =
ReadSetting(QStringLiteral("debug_pad_enabled"), false).toBool();
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
@ -512,7 +432,8 @@ void Config::ReadDebugValues() {
} }
void Config::ReadKeyboardValues() { void Config::ReadKeyboardValues() {
ReadBasicSetting(Settings::values.keyboard_enabled); Settings::values.keyboard_enabled =
ReadSetting(QStringLiteral("keyboard_enabled"), false).toBool();
std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(), std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(),
Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
@ -525,7 +446,7 @@ void Config::ReadKeyboardValues() {
} }
void Config::ReadMouseValues() { void Config::ReadMouseValues() {
ReadBasicSetting(Settings::values.mouse_enabled); Settings::values.mouse_enabled = ReadSetting(QStringLiteral("mouse_enabled"), false).toBool();
for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
const std::string default_param = const std::string default_param =
@ -560,11 +481,18 @@ void Config::ReadAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio")); qt_config->beginGroup(QStringLiteral("Audio"));
if (global) { if (global) {
ReadBasicSetting(Settings::values.audio_device_id); Settings::values.sink_id =
ReadBasicSetting(Settings::values.sink_id); ReadSetting(QStringLiteral("output_engine"), QStringLiteral("auto"))
.toString()
.toStdString();
Settings::values.audio_device_id =
ReadSetting(QStringLiteral("output_device"), QStringLiteral("auto"))
.toString()
.toStdString();
} }
ReadGlobalSetting(Settings::values.enable_audio_stretching); ReadSettingGlobal(Settings::values.enable_audio_stretching,
ReadGlobalSetting(Settings::values.volume); QStringLiteral("enable_audio_stretching"), true);
ReadSettingGlobal(Settings::values.volume, QStringLiteral("volume"), 1);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -581,11 +509,13 @@ void Config::ReadControlValues() {
ReadTouchscreenValues(); ReadTouchscreenValues();
ReadMotionTouchValues(); ReadMotionTouchValues();
ReadBasicSetting(Settings::values.emulate_analog_keyboard); Settings::values.emulate_analog_keyboard =
ReadSetting(QStringLiteral("emulate_analog_keyboard"), false).toBool();
Settings::values.mouse_panning = false; Settings::values.mouse_panning = false;
ReadBasicSetting(Settings::values.mouse_panning_sensitivity); Settings::values.mouse_panning_sensitivity =
ReadSetting(QStringLiteral("mouse_panning_sensitivity"), 1).toFloat();
ReadGlobalSetting(Settings::values.use_docked_mode); ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), true);
// Disable docked mode if handheld is selected // Disable docked mode if handheld is selected
const auto controller_type = Settings::values.players.GetValue()[0].controller_type; const auto controller_type = Settings::values.players.GetValue()[0].controller_type;
@ -593,9 +523,11 @@ void Config::ReadControlValues() {
Settings::values.use_docked_mode.SetValue(false); Settings::values.use_docked_mode.SetValue(false);
} }
ReadGlobalSetting(Settings::values.vibration_enabled); ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"),
ReadGlobalSetting(Settings::values.enable_accurate_vibrations); true);
ReadGlobalSetting(Settings::values.motion_enabled); ReadSettingGlobal(Settings::values.enable_accurate_vibrations,
QStringLiteral("enable_accurate_vibrations"), false);
ReadSettingGlobal(Settings::values.motion_enabled, QStringLiteral("motion_enabled"), true);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -633,19 +565,33 @@ void Config::ReadMotionTouchValues() {
} }
qt_config->endArray(); qt_config->endArray();
ReadBasicSetting(Settings::values.motion_device); Settings::values.motion_device =
ReadBasicSetting(Settings::values.touch_device); ReadSetting(QStringLiteral("motion_device"),
ReadBasicSetting(Settings::values.use_touch_from_button); QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01"))
ReadBasicSetting(Settings::values.touch_from_button_map_index); .toString()
Settings::values.touch_from_button_map_index = std::clamp( .toStdString();
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1); Settings::values.touch_device =
ReadBasicSetting(Settings::values.udp_input_servers); ReadSetting(QStringLiteral("touch_device"),
QStringLiteral("min_x:100,min_y:50,max_x:1800,max_y:850"))
.toString()
.toStdString();
Settings::values.use_touch_from_button =
ReadSetting(QStringLiteral("use_touch_from_button"), false).toBool();
Settings::values.touch_from_button_map_index =
ReadSetting(QStringLiteral("touch_from_button_map"), 0).toInt();
Settings::values.touch_from_button_map_index =
std::clamp(Settings::values.touch_from_button_map_index, 0, num_touch_from_button_maps - 1);
Settings::values.udp_input_servers =
ReadSetting(QStringLiteral("udp_input_servers"),
QString::fromUtf8(InputCommon::CemuhookUDP::DEFAULT_SRV))
.toString()
.toStdString();
} }
void Config::ReadCoreValues() { void Config::ReadCoreValues() {
qt_config->beginGroup(QStringLiteral("Core")); qt_config->beginGroup(QStringLiteral("Core"));
ReadGlobalSetting(Settings::values.use_multi_core); ReadSettingGlobal(Settings::values.use_multi_core, QStringLiteral("use_multi_core"), true);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -653,7 +599,7 @@ void Config::ReadCoreValues() {
void Config::ReadDataStorageValues() { void Config::ReadDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage")); qt_config->beginGroup(QStringLiteral("Data Storage"));
ReadBasicSetting(Settings::values.use_virtual_sd); Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
FS::SetYuzuPath( FS::SetYuzuPath(
FS::YuzuPath::NANDDir, FS::YuzuPath::NANDDir,
qt_config qt_config
@ -682,9 +628,12 @@ void Config::ReadDataStorageValues() {
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)))
.toString() .toString()
.toStdString()); .toStdString());
ReadBasicSetting(Settings::values.gamecard_inserted); Settings::values.gamecard_inserted =
ReadBasicSetting(Settings::values.gamecard_current_game); ReadSetting(QStringLiteral("gamecard_inserted"), false).toBool();
ReadBasicSetting(Settings::values.gamecard_path); Settings::values.gamecard_current_game =
ReadSetting(QStringLiteral("gamecard_current_game"), false).toBool();
Settings::values.gamecard_path =
ReadSetting(QStringLiteral("gamecard_path"), QString{}).toString().toStdString();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -695,24 +644,34 @@ void Config::ReadDebuggingValues() {
// Intentionally not using the QT default setting as this is intended to be changed in the ini // Intentionally not using the QT default setting as this is intended to be changed in the ini
Settings::values.record_frame_times = Settings::values.record_frame_times =
qt_config->value(QStringLiteral("record_frame_times"), false).toBool(); qt_config->value(QStringLiteral("record_frame_times"), false).toBool();
ReadBasicSetting(Settings::values.program_args); Settings::values.program_args =
ReadBasicSetting(Settings::values.dump_exefs); ReadSetting(QStringLiteral("program_args"), QString{}).toString().toStdString();
ReadBasicSetting(Settings::values.dump_nso); Settings::values.dump_exefs = ReadSetting(QStringLiteral("dump_exefs"), false).toBool();
ReadBasicSetting(Settings::values.enable_fs_access_log); Settings::values.dump_nso = ReadSetting(QStringLiteral("dump_nso"), false).toBool();
ReadBasicSetting(Settings::values.reporting_services); Settings::values.enable_fs_access_log =
ReadBasicSetting(Settings::values.quest_flag); ReadSetting(QStringLiteral("enable_fs_access_log"), false).toBool();
ReadBasicSetting(Settings::values.disable_macro_jit); Settings::values.reporting_services =
ReadBasicSetting(Settings::values.extended_logging); ReadSetting(QStringLiteral("reporting_services"), false).toBool();
ReadBasicSetting(Settings::values.use_debug_asserts); Settings::values.quest_flag = ReadSetting(QStringLiteral("quest_flag"), false).toBool();
ReadBasicSetting(Settings::values.use_auto_stub); Settings::values.disable_macro_jit =
ReadSetting(QStringLiteral("disable_macro_jit"), false).toBool();
Settings::values.extended_logging =
ReadSetting(QStringLiteral("extended_logging"), false).toBool();
Settings::values.use_debug_asserts =
ReadSetting(QStringLiteral("use_debug_asserts"), false).toBool();
Settings::values.use_auto_stub = ReadSetting(QStringLiteral("use_auto_stub"), false).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }
void Config::ReadServiceValues() { void Config::ReadServiceValues() {
qt_config->beginGroup(QStringLiteral("Services")); qt_config->beginGroup(QStringLiteral("Services"));
ReadBasicSetting(Settings::values.bcat_backend); Settings::values.bcat_backend =
ReadBasicSetting(Settings::values.bcat_boxcat_local); ReadSetting(QStringLiteral("bcat_backend"), QStringLiteral("none"))
.toString()
.toStdString();
Settings::values.bcat_boxcat_local =
ReadSetting(QStringLiteral("bcat_boxcat_local"), false).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -738,8 +697,11 @@ void Config::ReadDisabledAddOnValues() {
void Config::ReadMiscellaneousValues() { void Config::ReadMiscellaneousValues() {
qt_config->beginGroup(QStringLiteral("Miscellaneous")); qt_config->beginGroup(QStringLiteral("Miscellaneous"));
ReadBasicSetting(Settings::values.log_filter); Settings::values.log_filter =
ReadBasicSetting(Settings::values.use_dev_keys); ReadSetting(QStringLiteral("log_filter"), QStringLiteral("*:Info"))
.toString()
.toStdString();
Settings::values.use_dev_keys = ReadSetting(QStringLiteral("use_dev_keys"), false).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -789,24 +751,38 @@ void Config::ReadPathValues() {
void Config::ReadCpuValues() { void Config::ReadCpuValues() {
qt_config->beginGroup(QStringLiteral("Cpu")); qt_config->beginGroup(QStringLiteral("Cpu"));
ReadGlobalSetting(Settings::values.cpu_accuracy); ReadSettingGlobal(Settings::values.cpu_accuracy, QStringLiteral("cpu_accuracy"), 0);
ReadGlobalSetting(Settings::values.cpuopt_unsafe_unfuse_fma); ReadSettingGlobal(Settings::values.cpuopt_unsafe_unfuse_fma,
ReadGlobalSetting(Settings::values.cpuopt_unsafe_reduce_fp_error); QStringLiteral("cpuopt_unsafe_unfuse_fma"), true);
ReadGlobalSetting(Settings::values.cpuopt_unsafe_ignore_standard_fpcr); ReadSettingGlobal(Settings::values.cpuopt_unsafe_reduce_fp_error,
ReadGlobalSetting(Settings::values.cpuopt_unsafe_inaccurate_nan); QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true);
ReadGlobalSetting(Settings::values.cpuopt_unsafe_fastmem_check); ReadSettingGlobal(Settings::values.cpuopt_unsafe_ignore_standard_fpcr,
QStringLiteral("cpuopt_unsafe_ignore_standard_fpcr"), true);
ReadSettingGlobal(Settings::values.cpuopt_unsafe_inaccurate_nan,
QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true);
ReadSettingGlobal(Settings::values.cpuopt_unsafe_fastmem_check,
QStringLiteral("cpuopt_unsafe_fastmem_check"), true);
if (global) { if (global) {
ReadBasicSetting(Settings::values.cpuopt_page_tables); Settings::values.cpuopt_page_tables =
ReadBasicSetting(Settings::values.cpuopt_block_linking); ReadSetting(QStringLiteral("cpuopt_page_tables"), true).toBool();
ReadBasicSetting(Settings::values.cpuopt_return_stack_buffer); Settings::values.cpuopt_block_linking =
ReadBasicSetting(Settings::values.cpuopt_fast_dispatcher); ReadSetting(QStringLiteral("cpuopt_block_linking"), true).toBool();
ReadBasicSetting(Settings::values.cpuopt_context_elimination); Settings::values.cpuopt_return_stack_buffer =
ReadBasicSetting(Settings::values.cpuopt_const_prop); ReadSetting(QStringLiteral("cpuopt_return_stack_buffer"), true).toBool();
ReadBasicSetting(Settings::values.cpuopt_misc_ir); Settings::values.cpuopt_fast_dispatcher =
ReadBasicSetting(Settings::values.cpuopt_reduce_misalign_checks); ReadSetting(QStringLiteral("cpuopt_fast_dispatcher"), true).toBool();
ReadBasicSetting(Settings::values.cpuopt_fastmem); Settings::values.cpuopt_context_elimination =
ReadSetting(QStringLiteral("cpuopt_context_elimination"), true).toBool();
Settings::values.cpuopt_const_prop =
ReadSetting(QStringLiteral("cpuopt_const_prop"), true).toBool();
Settings::values.cpuopt_misc_ir =
ReadSetting(QStringLiteral("cpuopt_misc_ir"), true).toBool();
Settings::values.cpuopt_reduce_misalign_checks =
ReadSetting(QStringLiteral("cpuopt_reduce_misalign_checks"), true).toBool();
Settings::values.cpuopt_fastmem =
ReadSetting(QStringLiteral("cpuopt_fastmem"), true).toBool();
} }
qt_config->endGroup(); qt_config->endGroup();
@ -815,28 +791,41 @@ void Config::ReadCpuValues() {
void Config::ReadRendererValues() { void Config::ReadRendererValues() {
qt_config->beginGroup(QStringLiteral("Renderer")); qt_config->beginGroup(QStringLiteral("Renderer"));
ReadGlobalSetting(Settings::values.renderer_backend); ReadSettingGlobal(Settings::values.renderer_backend, QStringLiteral("backend"), 0);
ReadBasicSetting(Settings::values.renderer_debug); ReadSettingGlobal(Settings::values.renderer_debug, QStringLiteral("debug"), false);
ReadGlobalSetting(Settings::values.vulkan_device); ReadSettingGlobal(Settings::values.vulkan_device, QStringLiteral("vulkan_device"), 0);
ReadGlobalSetting(Settings::values.fullscreen_mode); #ifdef _WIN32
ReadGlobalSetting(Settings::values.aspect_ratio); ReadSettingGlobal(Settings::values.fullscreen_mode, QStringLiteral("fullscreen_mode"), 0);
ReadGlobalSetting(Settings::values.max_anisotropy); #else
ReadGlobalSetting(Settings::values.use_frame_limit); // *nix platforms may have issues with the borderless windowed fullscreen mode.
ReadGlobalSetting(Settings::values.frame_limit); // Default to exclusive fullscreen on these platforms for now.
ReadGlobalSetting(Settings::values.use_disk_shader_cache); ReadSettingGlobal(Settings::values.fullscreen_mode, QStringLiteral("fullscreen_mode"), 1);
ReadGlobalSetting(Settings::values.gpu_accuracy); #endif
ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation); ReadSettingGlobal(Settings::values.aspect_ratio, QStringLiteral("aspect_ratio"), 0);
ReadGlobalSetting(Settings::values.use_nvdec_emulation); ReadSettingGlobal(Settings::values.max_anisotropy, QStringLiteral("max_anisotropy"), 0);
ReadGlobalSetting(Settings::values.accelerate_astc); ReadSettingGlobal(Settings::values.use_frame_limit, QStringLiteral("use_frame_limit"), true);
ReadGlobalSetting(Settings::values.use_vsync); ReadSettingGlobal(Settings::values.frame_limit, QStringLiteral("frame_limit"), 100);
ReadGlobalSetting(Settings::values.disable_fps_limit); ReadSettingGlobal(Settings::values.use_disk_shader_cache,
ReadGlobalSetting(Settings::values.use_assembly_shaders); QStringLiteral("use_disk_shader_cache"), true);
ReadGlobalSetting(Settings::values.use_asynchronous_shaders); ReadSettingGlobal(Settings::values.gpu_accuracy, QStringLiteral("gpu_accuracy"), 1);
ReadGlobalSetting(Settings::values.use_fast_gpu_time); ReadSettingGlobal(Settings::values.use_asynchronous_gpu_emulation,
ReadGlobalSetting(Settings::values.use_caches_gc); QStringLiteral("use_asynchronous_gpu_emulation"), true);
ReadGlobalSetting(Settings::values.bg_red); ReadSettingGlobal(Settings::values.use_nvdec_emulation, QStringLiteral("use_nvdec_emulation"),
ReadGlobalSetting(Settings::values.bg_green); true);
ReadGlobalSetting(Settings::values.bg_blue); ReadSettingGlobal(Settings::values.accelerate_astc, QStringLiteral("accelerate_astc"), true);
ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true);
ReadSettingGlobal(Settings::values.disable_fps_limit, QStringLiteral("disable_fps_limit"),
false);
ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"),
false);
ReadSettingGlobal(Settings::values.use_asynchronous_shaders,
QStringLiteral("use_asynchronous_shaders"), false);
ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"),
true);
ReadSettingGlobal(Settings::values.use_caches_gc, QStringLiteral("use_caches_gc"), false);
ReadSettingGlobal(Settings::values.bg_red, QStringLiteral("bg_red"), 0.0);
ReadSettingGlobal(Settings::values.bg_green, QStringLiteral("bg_green"), 0.0);
ReadSettingGlobal(Settings::values.bg_blue, QStringLiteral("bg_blue"), 0.0);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -881,15 +870,15 @@ void Config::ReadShortcutValues() {
void Config::ReadSystemValues() { void Config::ReadSystemValues() {
qt_config->beginGroup(QStringLiteral("System")); qt_config->beginGroup(QStringLiteral("System"));
ReadBasicSetting(Settings::values.current_user); ReadSettingGlobal(Settings::values.current_user, QStringLiteral("current_user"), 0);
Settings::values.current_user = std::clamp<int>(Settings::values.current_user.GetValue(), 0, Settings::values.current_user =
Service::Account::MAX_USERS - 1); std::clamp<int>(Settings::values.current_user, 0, Service::Account::MAX_USERS - 1);
ReadGlobalSetting(Settings::values.language_index); ReadSettingGlobal(Settings::values.language_index, QStringLiteral("language_index"), 1);
ReadGlobalSetting(Settings::values.region_index); ReadSettingGlobal(Settings::values.region_index, QStringLiteral("region_index"), 1);
ReadGlobalSetting(Settings::values.time_zone_index); ReadSettingGlobal(Settings::values.time_zone_index, QStringLiteral("time_zone_index"), 0);
bool rng_seed_enabled; bool rng_seed_enabled;
ReadSettingGlobal(rng_seed_enabled, QStringLiteral("rng_seed_enabled"), false); ReadSettingGlobal(rng_seed_enabled, QStringLiteral("rng_seed_enabled"), false);
@ -915,7 +904,7 @@ void Config::ReadSystemValues() {
} }
} }
ReadGlobalSetting(Settings::values.sound_index); ReadSettingGlobal(Settings::values.sound_index, QStringLiteral("sound_index"), 1);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -999,10 +988,16 @@ void Config::ReadUILayoutValues() {
void Config::ReadWebServiceValues() { void Config::ReadWebServiceValues() {
qt_config->beginGroup(QStringLiteral("WebService")); qt_config->beginGroup(QStringLiteral("WebService"));
ReadBasicSetting(Settings::values.enable_telemetry); Settings::values.enable_telemetry =
ReadBasicSetting(Settings::values.web_api_url); ReadSetting(QStringLiteral("enable_telemetry"), true).toBool();
ReadBasicSetting(Settings::values.yuzu_username); Settings::values.web_api_url =
ReadBasicSetting(Settings::values.yuzu_token); ReadSetting(QStringLiteral("web_api_url"), QStringLiteral("https://api.yuzu-emu.org"))
.toString()
.toStdString();
Settings::values.yuzu_username =
ReadSetting(QStringLiteral("yuzu_username")).toString().toStdString();
Settings::values.yuzu_token =
ReadSetting(QStringLiteral("yuzu_token")).toString().toStdString();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1088,7 +1083,7 @@ void Config::SavePlayerValue(std::size_t player_index) {
} }
void Config::SaveDebugValues() { void Config::SaveDebugValues() {
WriteBasicSetting(Settings::values.debug_pad_enabled); WriteSetting(QStringLiteral("debug_pad_enabled"), Settings::values.debug_pad_enabled, false);
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
WriteSetting(QStringLiteral("debug_pad_") + WriteSetting(QStringLiteral("debug_pad_") +
@ -1108,7 +1103,7 @@ void Config::SaveDebugValues() {
} }
void Config::SaveMouseValues() { void Config::SaveMouseValues() {
WriteBasicSetting(Settings::values.mouse_enabled); WriteSetting(QStringLiteral("mouse_enabled"), Settings::values.mouse_enabled, false);
for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
const std::string default_param = const std::string default_param =
@ -1131,11 +1126,19 @@ void Config::SaveTouchscreenValues() {
} }
void Config::SaveMotionTouchValues() { void Config::SaveMotionTouchValues() {
WriteBasicSetting(Settings::values.motion_device); WriteSetting(QStringLiteral("motion_device"),
WriteBasicSetting(Settings::values.touch_device); QString::fromStdString(Settings::values.motion_device),
WriteBasicSetting(Settings::values.use_touch_from_button); QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01"));
WriteBasicSetting(Settings::values.touch_from_button_map_index); WriteSetting(QStringLiteral("touch_device"),
WriteBasicSetting(Settings::values.udp_input_servers); QString::fromStdString(Settings::values.touch_device),
QStringLiteral("engine:emu_window"));
WriteSetting(QStringLiteral("use_touch_from_button"), Settings::values.use_touch_from_button,
false);
WriteSetting(QStringLiteral("touch_from_button_map"),
Settings::values.touch_from_button_map_index, 0);
WriteSetting(QStringLiteral("udp_input_servers"),
QString::fromStdString(Settings::values.udp_input_servers),
QString::fromUtf8(InputCommon::CemuhookUDP::DEFAULT_SRV));
qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps")); qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps"));
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) { for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) {
@ -1178,11 +1181,15 @@ void Config::SaveAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio")); qt_config->beginGroup(QStringLiteral("Audio"));
if (global) { if (global) {
WriteBasicSetting(Settings::values.sink_id); WriteSetting(QStringLiteral("output_engine"),
WriteBasicSetting(Settings::values.audio_device_id); QString::fromStdString(Settings::values.sink_id), QStringLiteral("auto"));
WriteSetting(QStringLiteral("output_device"),
QString::fromStdString(Settings::values.audio_device_id),
QStringLiteral("auto"));
} }
WriteGlobalSetting(Settings::values.enable_audio_stretching); WriteSettingGlobal(QStringLiteral("enable_audio_stretching"),
WriteGlobalSetting(Settings::values.volume); Settings::values.enable_audio_stretching, true);
WriteSettingGlobal(QStringLiteral("volume"), Settings::values.volume, 1.0f);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1198,21 +1205,30 @@ void Config::SaveControlValues() {
SaveTouchscreenValues(); SaveTouchscreenValues();
SaveMotionTouchValues(); SaveMotionTouchValues();
WriteGlobalSetting(Settings::values.use_docked_mode); WriteSettingGlobal(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, true);
WriteGlobalSetting(Settings::values.vibration_enabled); WriteSettingGlobal(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled,
WriteGlobalSetting(Settings::values.enable_accurate_vibrations); true);
WriteGlobalSetting(Settings::values.motion_enabled); WriteSettingGlobal(QStringLiteral("enable_accurate_vibrations"),
WriteBasicSetting(Settings::values.keyboard_enabled); Settings::values.enable_accurate_vibrations, false);
WriteBasicSetting(Settings::values.emulate_analog_keyboard); WriteSettingGlobal(QStringLiteral("motion_enabled"), Settings::values.motion_enabled, true);
WriteBasicSetting(Settings::values.mouse_panning_sensitivity); WriteSetting(QStringLiteral("motion_device"),
QString::fromStdString(Settings::values.motion_device),
QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01"));
WriteSetting(QStringLiteral("touch_device"),
QString::fromStdString(Settings::values.touch_device),
QStringLiteral("engine:emu_window"));
WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false);
WriteSetting(QStringLiteral("emulate_analog_keyboard"),
Settings::values.emulate_analog_keyboard, false);
WriteSetting(QStringLiteral("mouse_panning_sensitivity"),
Settings::values.mouse_panning_sensitivity, 1.0f);
qt_config->endGroup(); qt_config->endGroup();
} }
void Config::SaveCoreValues() { void Config::SaveCoreValues() {
qt_config->beginGroup(QStringLiteral("Core")); qt_config->beginGroup(QStringLiteral("Core"));
WriteGlobalSetting(Settings::values.use_multi_core); WriteSettingGlobal(QStringLiteral("use_multi_core"), Settings::values.use_multi_core, true);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1220,7 +1236,7 @@ void Config::SaveCoreValues() {
void Config::SaveDataStorageValues() { void Config::SaveDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage")); qt_config->beginGroup(QStringLiteral("Data Storage"));
WriteBasicSetting(Settings::values.use_virtual_sd); WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
WriteSetting(QStringLiteral("nand_directory"), WriteSetting(QStringLiteral("nand_directory"),
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)), QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)),
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir))); QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)));
@ -1233,9 +1249,11 @@ void Config::SaveDataStorageValues() {
WriteSetting(QStringLiteral("dump_directory"), WriteSetting(QStringLiteral("dump_directory"),
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)),
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)));
WriteBasicSetting(Settings::values.gamecard_inserted); WriteSetting(QStringLiteral("gamecard_inserted"), Settings::values.gamecard_inserted, false);
WriteBasicSetting(Settings::values.gamecard_current_game); WriteSetting(QStringLiteral("gamecard_current_game"), Settings::values.gamecard_current_game,
WriteBasicSetting(Settings::values.gamecard_path); false);
WriteSetting(QStringLiteral("gamecard_path"),
QString::fromStdString(Settings::values.gamecard_path), QString{});
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1245,23 +1263,24 @@ void Config::SaveDebuggingValues() {
// Intentionally not using the QT default setting as this is intended to be changed in the ini // Intentionally not using the QT default setting as this is intended to be changed in the ini
qt_config->setValue(QStringLiteral("record_frame_times"), Settings::values.record_frame_times); qt_config->setValue(QStringLiteral("record_frame_times"), Settings::values.record_frame_times);
WriteBasicSetting(Settings::values.program_args); WriteSetting(QStringLiteral("program_args"),
WriteBasicSetting(Settings::values.dump_exefs); QString::fromStdString(Settings::values.program_args), QString{});
WriteBasicSetting(Settings::values.dump_nso); WriteSetting(QStringLiteral("dump_exefs"), Settings::values.dump_exefs, false);
WriteBasicSetting(Settings::values.enable_fs_access_log); WriteSetting(QStringLiteral("dump_nso"), Settings::values.dump_nso, false);
WriteBasicSetting(Settings::values.quest_flag); WriteSetting(QStringLiteral("enable_fs_access_log"), Settings::values.enable_fs_access_log,
WriteBasicSetting(Settings::values.use_debug_asserts); false);
WriteBasicSetting(Settings::values.disable_macro_jit); WriteSetting(QStringLiteral("quest_flag"), Settings::values.quest_flag, false);
WriteSetting(QStringLiteral("use_debug_asserts"), Settings::values.use_debug_asserts, false);
WriteSetting(QStringLiteral("disable_macro_jit"), Settings::values.disable_macro_jit, false);
qt_config->endGroup(); qt_config->endGroup();
} }
void Config::SaveServiceValues() { void Config::SaveServiceValues() {
qt_config->beginGroup(QStringLiteral("Services")); qt_config->beginGroup(QStringLiteral("Services"));
WriteSetting(QStringLiteral("bcat_backend"),
WriteBasicSetting(Settings::values.bcat_backend); QString::fromStdString(Settings::values.bcat_backend), QStringLiteral("none"));
WriteBasicSetting(Settings::values.bcat_boxcat_local); WriteSetting(QStringLiteral("bcat_boxcat_local"), Settings::values.bcat_boxcat_local, false);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1287,8 +1306,9 @@ void Config::SaveDisabledAddOnValues() {
void Config::SaveMiscellaneousValues() { void Config::SaveMiscellaneousValues() {
qt_config->beginGroup(QStringLiteral("Miscellaneous")); qt_config->beginGroup(QStringLiteral("Miscellaneous"));
WriteBasicSetting(Settings::values.log_filter); WriteSetting(QStringLiteral("log_filter"), QString::fromStdString(Settings::values.log_filter),
WriteBasicSetting(Settings::values.use_dev_keys); QStringLiteral("*:Info"));
WriteSetting(QStringLiteral("use_dev_keys"), Settings::values.use_dev_keys, false);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1316,27 +1336,38 @@ void Config::SavePathValues() {
void Config::SaveCpuValues() { void Config::SaveCpuValues() {
qt_config->beginGroup(QStringLiteral("Cpu")); qt_config->beginGroup(QStringLiteral("Cpu"));
WriteSetting(QStringLiteral("cpu_accuracy"), WriteSettingGlobal(QStringLiteral("cpu_accuracy"),
static_cast<u32>(Settings::values.cpu_accuracy.GetValue(global)), static_cast<u32>(Settings::values.cpu_accuracy.GetValue(global)),
static_cast<u32>(Settings::values.cpu_accuracy.GetDefault()), Settings::values.cpu_accuracy.UsingGlobal(),
Settings::values.cpu_accuracy.UsingGlobal()); static_cast<u32>(Settings::CPUAccuracy::Accurate));
WriteGlobalSetting(Settings::values.cpuopt_unsafe_unfuse_fma); WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_unfuse_fma"),
WriteGlobalSetting(Settings::values.cpuopt_unsafe_reduce_fp_error); Settings::values.cpuopt_unsafe_unfuse_fma, true);
WriteGlobalSetting(Settings::values.cpuopt_unsafe_ignore_standard_fpcr); WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_reduce_fp_error"),
WriteGlobalSetting(Settings::values.cpuopt_unsafe_inaccurate_nan); Settings::values.cpuopt_unsafe_reduce_fp_error, true);
WriteGlobalSetting(Settings::values.cpuopt_unsafe_fastmem_check); WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_ignore_standard_fpcr"),
Settings::values.cpuopt_unsafe_ignore_standard_fpcr, true);
WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_inaccurate_nan"),
Settings::values.cpuopt_unsafe_inaccurate_nan, true);
WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_fastmem_check"),
Settings::values.cpuopt_unsafe_fastmem_check, true);
if (global) { if (global) {
WriteBasicSetting(Settings::values.cpuopt_page_tables); WriteSetting(QStringLiteral("cpuopt_page_tables"), Settings::values.cpuopt_page_tables,
WriteBasicSetting(Settings::values.cpuopt_block_linking); true);
WriteBasicSetting(Settings::values.cpuopt_return_stack_buffer); WriteSetting(QStringLiteral("cpuopt_block_linking"), Settings::values.cpuopt_block_linking,
WriteBasicSetting(Settings::values.cpuopt_fast_dispatcher); true);
WriteBasicSetting(Settings::values.cpuopt_context_elimination); WriteSetting(QStringLiteral("cpuopt_return_stack_buffer"),
WriteBasicSetting(Settings::values.cpuopt_const_prop); Settings::values.cpuopt_return_stack_buffer, true);
WriteBasicSetting(Settings::values.cpuopt_misc_ir); WriteSetting(QStringLiteral("cpuopt_fast_dispatcher"),
WriteBasicSetting(Settings::values.cpuopt_reduce_misalign_checks); Settings::values.cpuopt_fast_dispatcher, true);
WriteBasicSetting(Settings::values.cpuopt_fastmem); WriteSetting(QStringLiteral("cpuopt_context_elimination"),
Settings::values.cpuopt_context_elimination, true);
WriteSetting(QStringLiteral("cpuopt_const_prop"), Settings::values.cpuopt_const_prop, true);
WriteSetting(QStringLiteral("cpuopt_misc_ir"), Settings::values.cpuopt_misc_ir, true);
WriteSetting(QStringLiteral("cpuopt_reduce_misalign_checks"),
Settings::values.cpuopt_reduce_misalign_checks, true);
WriteSetting(QStringLiteral("cpuopt_fastmem"), Settings::values.cpuopt_fastmem, true);
} }
qt_config->endGroup(); qt_config->endGroup();
@ -1345,34 +1376,46 @@ void Config::SaveCpuValues() {
void Config::SaveRendererValues() { void Config::SaveRendererValues() {
qt_config->beginGroup(QStringLiteral("Renderer")); qt_config->beginGroup(QStringLiteral("Renderer"));
WriteSetting(QString::fromStdString(Settings::values.renderer_backend.GetLabel()), WriteSettingGlobal(QStringLiteral("backend"),
static_cast<u32>(Settings::values.renderer_backend.GetValue(global)), static_cast<int>(Settings::values.renderer_backend.GetValue(global)),
static_cast<u32>(Settings::values.renderer_backend.GetDefault()), Settings::values.renderer_backend.UsingGlobal(), 0);
Settings::values.renderer_backend.UsingGlobal()); WriteSetting(QStringLiteral("debug"), Settings::values.renderer_debug, false);
WriteBasicSetting(Settings::values.renderer_debug); WriteSettingGlobal(QStringLiteral("vulkan_device"), Settings::values.vulkan_device, 0);
WriteGlobalSetting(Settings::values.vulkan_device); #ifdef _WIN32
WriteGlobalSetting(Settings::values.fullscreen_mode); WriteSettingGlobal(QStringLiteral("fullscreen_mode"), Settings::values.fullscreen_mode, 0);
WriteGlobalSetting(Settings::values.aspect_ratio); #else
WriteGlobalSetting(Settings::values.max_anisotropy); // *nix platforms may have issues with the borderless windowed fullscreen mode.
WriteGlobalSetting(Settings::values.use_frame_limit); // Default to exclusive fullscreen on these platforms for now.
WriteGlobalSetting(Settings::values.frame_limit); WriteSettingGlobal(QStringLiteral("fullscreen_mode"), Settings::values.fullscreen_mode, 1);
WriteGlobalSetting(Settings::values.use_disk_shader_cache); #endif
WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()), WriteSettingGlobal(QStringLiteral("aspect_ratio"), Settings::values.aspect_ratio, 0);
static_cast<u32>(Settings::values.gpu_accuracy.GetValue(global)), WriteSettingGlobal(QStringLiteral("max_anisotropy"), Settings::values.max_anisotropy, 0);
static_cast<u32>(Settings::values.gpu_accuracy.GetDefault()), WriteSettingGlobal(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true);
Settings::values.gpu_accuracy.UsingGlobal()); WriteSettingGlobal(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100);
WriteGlobalSetting(Settings::values.use_asynchronous_gpu_emulation); WriteSettingGlobal(QStringLiteral("use_disk_shader_cache"),
WriteGlobalSetting(Settings::values.use_nvdec_emulation); Settings::values.use_disk_shader_cache, true);
WriteGlobalSetting(Settings::values.accelerate_astc); WriteSettingGlobal(QStringLiteral("gpu_accuracy"),
WriteGlobalSetting(Settings::values.use_vsync); static_cast<int>(Settings::values.gpu_accuracy.GetValue(global)),
WriteGlobalSetting(Settings::values.disable_fps_limit); Settings::values.gpu_accuracy.UsingGlobal(), 1);
WriteGlobalSetting(Settings::values.use_assembly_shaders); WriteSettingGlobal(QStringLiteral("use_asynchronous_gpu_emulation"),
WriteGlobalSetting(Settings::values.use_asynchronous_shaders); Settings::values.use_asynchronous_gpu_emulation, true);
WriteGlobalSetting(Settings::values.use_fast_gpu_time); WriteSettingGlobal(QStringLiteral("use_nvdec_emulation"), Settings::values.use_nvdec_emulation,
WriteGlobalSetting(Settings::values.use_caches_gc); true);
WriteGlobalSetting(Settings::values.bg_red); WriteSettingGlobal(QStringLiteral("accelerate_astc"), Settings::values.accelerate_astc, true);
WriteGlobalSetting(Settings::values.bg_green); WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true);
WriteGlobalSetting(Settings::values.bg_blue); WriteSettingGlobal(QStringLiteral("disable_fps_limit"), Settings::values.disable_fps_limit,
false);
WriteSettingGlobal(QStringLiteral("use_assembly_shaders"),
Settings::values.use_assembly_shaders, false);
WriteSettingGlobal(QStringLiteral("use_asynchronous_shaders"),
Settings::values.use_asynchronous_shaders, false);
WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time,
true);
WriteSettingGlobal(QStringLiteral("use_caches_gc"), Settings::values.use_caches_gc, false);
// Cast to double because Qt's written float values are not human-readable
WriteSettingGlobal(QStringLiteral("bg_red"), Settings::values.bg_red, 0.0);
WriteSettingGlobal(QStringLiteral("bg_green"), Settings::values.bg_green, 0.0);
WriteSettingGlobal(QStringLiteral("bg_blue"), Settings::values.bg_blue, 0.0);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1380,7 +1423,8 @@ void Config::SaveRendererValues() {
void Config::SaveScreenshotValues() { void Config::SaveScreenshotValues() {
qt_config->beginGroup(QStringLiteral("Screenshots")); qt_config->beginGroup(QStringLiteral("Screenshots"));
WriteBasicSetting(UISettings::values.enable_screenshot_save_as); WriteSetting(QStringLiteral("enable_screenshot_save_as"),
UISettings::values.enable_screenshot_save_as);
WriteSetting(QStringLiteral("screenshot_path"), WriteSetting(QStringLiteral("screenshot_path"),
QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir))); QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir)));
@ -1410,16 +1454,17 @@ void Config::SaveShortcutValues() {
void Config::SaveSystemValues() { void Config::SaveSystemValues() {
qt_config->beginGroup(QStringLiteral("System")); qt_config->beginGroup(QStringLiteral("System"));
WriteBasicSetting(Settings::values.current_user); WriteSetting(QStringLiteral("current_user"), Settings::values.current_user, 0);
WriteGlobalSetting(Settings::values.language_index); WriteSettingGlobal(QStringLiteral("language_index"), Settings::values.language_index, 1);
WriteGlobalSetting(Settings::values.region_index); WriteSettingGlobal(QStringLiteral("region_index"), Settings::values.region_index, 1);
WriteGlobalSetting(Settings::values.time_zone_index); WriteSettingGlobal(QStringLiteral("time_zone_index"), Settings::values.time_zone_index, 0);
WriteSetting(QStringLiteral("rng_seed_enabled"), WriteSettingGlobal(QStringLiteral("rng_seed_enabled"),
Settings::values.rng_seed.GetValue(global).has_value(), false, Settings::values.rng_seed.GetValue(global).has_value(),
Settings::values.rng_seed.UsingGlobal()); Settings::values.rng_seed.UsingGlobal(), false);
WriteSetting(QStringLiteral("rng_seed"), Settings::values.rng_seed.GetValue(global).value_or(0), WriteSettingGlobal(QStringLiteral("rng_seed"),
0, Settings::values.rng_seed.UsingGlobal()); Settings::values.rng_seed.GetValue(global).value_or(0),
Settings::values.rng_seed.UsingGlobal(), 0);
if (global) { if (global) {
WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(), WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(),
@ -1430,7 +1475,7 @@ void Config::SaveSystemValues() {
0); 0);
} }
WriteGlobalSetting(Settings::values.sound_index); WriteSettingGlobal(QStringLiteral("sound_index"), Settings::values.sound_index, 1);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1440,8 +1485,10 @@ void Config::SaveUIValues() {
WriteSetting(QStringLiteral("theme"), UISettings::values.theme, WriteSetting(QStringLiteral("theme"), UISettings::values.theme,
QString::fromUtf8(UISettings::themes[0].second)); QString::fromUtf8(UISettings::themes[0].second));
WriteBasicSetting(UISettings::values.enable_discord_presence); WriteSetting(QStringLiteral("enable_discord_presence"),
WriteBasicSetting(UISettings::values.select_user_on_boot); UISettings::values.enable_discord_presence, true);
WriteSetting(QStringLiteral("select_user_on_boot"), UISettings::values.select_user_on_boot,
false);
SaveUIGamelistValues(); SaveUIGamelistValues();
SaveUILayoutValues(); SaveUILayoutValues();
@ -1449,17 +1496,18 @@ void Config::SaveUIValues() {
SaveScreenshotValues(); SaveScreenshotValues();
SaveShortcutValues(); SaveShortcutValues();
WriteBasicSetting(UISettings::values.single_window_mode); WriteSetting(QStringLiteral("singleWindowMode"), UISettings::values.single_window_mode, true);
WriteBasicSetting(UISettings::values.fullscreen); WriteSetting(QStringLiteral("fullscreen"), UISettings::values.fullscreen, false);
WriteBasicSetting(UISettings::values.display_titlebar); WriteSetting(QStringLiteral("displayTitleBars"), UISettings::values.display_titlebar, true);
WriteBasicSetting(UISettings::values.show_filter_bar); WriteSetting(QStringLiteral("showFilterBar"), UISettings::values.show_filter_bar, true);
WriteBasicSetting(UISettings::values.show_status_bar); WriteSetting(QStringLiteral("showStatusBar"), UISettings::values.show_status_bar, true);
WriteBasicSetting(UISettings::values.confirm_before_closing); WriteSetting(QStringLiteral("confirmClose"), UISettings::values.confirm_before_closing, true);
WriteBasicSetting(UISettings::values.first_start); WriteSetting(QStringLiteral("firstStart"), UISettings::values.first_start, true);
WriteBasicSetting(UISettings::values.callout_flags); WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0);
WriteBasicSetting(UISettings::values.show_console); WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false);
WriteBasicSetting(UISettings::values.pause_when_in_background); WriteSetting(QStringLiteral("pauseWhenInBackground"),
WriteBasicSetting(UISettings::values.hide_mouse); UISettings::values.pause_when_in_background, false);
WriteSetting(QStringLiteral("hideInactiveMouse"), UISettings::values.hide_mouse, false);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1467,11 +1515,11 @@ void Config::SaveUIValues() {
void Config::SaveUIGamelistValues() { void Config::SaveUIGamelistValues() {
qt_config->beginGroup(QStringLiteral("UIGameList")); qt_config->beginGroup(QStringLiteral("UIGameList"));
WriteBasicSetting(UISettings::values.show_add_ons); WriteSetting(QStringLiteral("show_add_ons"), UISettings::values.show_add_ons, true);
WriteBasicSetting(UISettings::values.icon_size); WriteSetting(QStringLiteral("icon_size"), UISettings::values.icon_size, 64);
WriteBasicSetting(UISettings::values.row_1_text_id); WriteSetting(QStringLiteral("row_1_text_id"), UISettings::values.row_1_text_id, 3);
WriteBasicSetting(UISettings::values.row_2_text_id); WriteSetting(QStringLiteral("row_2_text_id"), UISettings::values.row_2_text_id, 2);
WriteBasicSetting(UISettings::values.cache_game_list); WriteSetting(QStringLiteral("cache_game_list"), UISettings::values.cache_game_list, true);
qt_config->beginWriteArray(QStringLiteral("favorites")); qt_config->beginWriteArray(QStringLiteral("favorites"));
for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) {
qt_config->setArrayIndex(i); qt_config->setArrayIndex(i);
@ -1492,7 +1540,8 @@ void Config::SaveUILayoutValues() {
WriteSetting(QStringLiteral("gameListHeaderState"), UISettings::values.gamelist_header_state); WriteSetting(QStringLiteral("gameListHeaderState"), UISettings::values.gamelist_header_state);
WriteSetting(QStringLiteral("microProfileDialogGeometry"), WriteSetting(QStringLiteral("microProfileDialogGeometry"),
UISettings::values.microprofile_geometry); UISettings::values.microprofile_geometry);
WriteBasicSetting(UISettings::values.microprofile_visible); WriteSetting(QStringLiteral("microProfileDialogVisible"),
UISettings::values.microprofile_visible, false);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1500,10 +1549,13 @@ void Config::SaveUILayoutValues() {
void Config::SaveWebServiceValues() { void Config::SaveWebServiceValues() {
qt_config->beginGroup(QStringLiteral("WebService")); qt_config->beginGroup(QStringLiteral("WebService"));
WriteBasicSetting(Settings::values.enable_telemetry); WriteSetting(QStringLiteral("enable_telemetry"), Settings::values.enable_telemetry, true);
WriteBasicSetting(Settings::values.web_api_url); WriteSetting(QStringLiteral("web_api_url"),
WriteBasicSetting(Settings::values.yuzu_username); QString::fromStdString(Settings::values.web_api_url),
WriteBasicSetting(Settings::values.yuzu_token); QStringLiteral("https://api.yuzu-emu.org"));
WriteSetting(QStringLiteral("yuzu_username"),
QString::fromStdString(Settings::values.yuzu_username));
WriteSetting(QStringLiteral("yuzu_token"), QString::fromStdString(Settings::values.yuzu_token));
qt_config->endGroup(); qt_config->endGroup();
} }
@ -1523,14 +1575,21 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value)
} }
template <typename Type> template <typename Type>
void Config::ReadGlobalSetting(Settings::Setting<Type>& setting) { void Config::ReadSettingGlobal(Settings::Setting<Type>& setting, const QString& name) {
QString name = QString::fromStdString(setting.GetLabel());
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
setting.SetGlobal(use_global); setting.SetGlobal(use_global);
if (global || !use_global) { if (global || !use_global) {
setting.SetValue(static_cast<QVariant>( setting.SetValue(ReadSetting(name).value<Type>());
ReadSetting(name, QVariant::fromValue<Type>(setting.GetDefault()))) }
.value<Type>()); }
template <typename Type>
void Config::ReadSettingGlobal(Settings::Setting<Type>& setting, const QString& name,
const QVariant& default_value) {
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
setting.SetGlobal(use_global);
if (global || !use_global) {
setting.SetValue(ReadSetting(name, default_value).value<Type>());
} }
} }
@ -1553,8 +1612,31 @@ void Config::WriteSetting(const QString& name, const QVariant& value,
qt_config->setValue(name, value); qt_config->setValue(name, value);
} }
void Config::WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value, template <typename Type>
bool use_global) { void Config::WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting) {
if (!global) {
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
}
if (global || !setting.UsingGlobal()) {
qt_config->setValue(name, setting.GetValue(global));
}
}
template <typename Type>
void Config::WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting,
const QVariant& default_value) {
if (!global) {
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
}
if (global || !setting.UsingGlobal()) {
qt_config->setValue(name + QStringLiteral("/default"),
setting.GetValue(global) == default_value.value<Type>());
qt_config->setValue(name, setting.GetValue(global));
}
}
void Config::WriteSettingGlobal(const QString& name, const QVariant& value, bool use_global,
const QVariant& default_value) {
if (!global) { if (!global) {
qt_config->setValue(name + QStringLiteral("/use_global"), use_global); qt_config->setValue(name + QStringLiteral("/use_global"), use_global);
} }

View File

@ -102,75 +102,28 @@ private:
void SaveUILayoutValues(); void SaveUILayoutValues();
void SaveWebServiceValues(); void SaveWebServiceValues();
/**
* Reads a setting from the qt_config.
*
* @param name The setting's identifier
* @param default_value The value to use when the setting is not already present in the config
*/
QVariant ReadSetting(const QString& name) const; QVariant ReadSetting(const QString& name) const;
QVariant ReadSetting(const QString& name, const QVariant& default_value) const; QVariant ReadSetting(const QString& name, const QVariant& default_value) const;
// Templated ReadSettingGlobal functions will also look for the use_global setting and set
/** // both the value and the global state properly
* Only reads a setting from the qt_config if the current config is a global config, or if the template <typename Type>
* current config is a custom config and the setting is overriding the global setting. Otherwise void ReadSettingGlobal(Settings::Setting<Type>& setting, const QString& name);
* it does nothing. template <typename Type>
* void ReadSettingGlobal(Settings::Setting<Type>& setting, const QString& name,
* @param setting The variable to be modified const QVariant& default_value);
* @param name The setting's identifier
* @param default_value The value to use when the setting is not already present in the config
*/
template <typename Type> template <typename Type>
void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const; void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const;
// Templated WriteSettingGlobal functions will also write the global state if needed and will
/** // skip writing the actual setting if it defers to the global value
* Writes a setting to the qt_config.
*
* @param name The setting's idetentifier
* @param value Value of the setting
* @param default_value Default of the setting if not present in qt_config
* @param use_global Specifies if the custom or global config should be in use, for custom
* configs
*/
void WriteSetting(const QString& name, const QVariant& value); void WriteSetting(const QString& name, const QVariant& value);
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value,
bool use_global);
/**
* Reads a value from the qt_config and applies it to the setting, using its label and default
* value. If the config is a custom config, this will also read the global state of the setting
* and apply that information to it.
*
* @param The setting
*/
template <typename Type> template <typename Type>
void ReadGlobalSetting(Settings::Setting<Type>& setting); void WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting);
/**
* Sets a value to the qt_config using the setting's label and default value. If the config is a
* custom config, it will apply the global state, and the custom value if needed.
*
* @param The setting
*/
template <typename Type> template <typename Type>
void WriteGlobalSetting(const Settings::Setting<Type>& setting); void WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting,
const QVariant& default_value);
/** void WriteSettingGlobal(const QString& name, const QVariant& value, bool use_global,
* Reads a value from the qt_config using the setting's label and default value and applies the const QVariant& default_value);
* value to the setting.
*
* @param The setting
*/
template <typename Type>
void ReadBasicSetting(Settings::BasicSetting<Type>& setting);
/** Sets a value from the setting in the qt_config using the setting's label and default value.
*
* @param The setting
*/
template <typename Type>
void WriteBasicSetting(const Settings::BasicSetting<Type>& setting);
ConfigType type; ConfigType type;
std::unique_ptr<QSettings> qt_config; std::unique_ptr<QSettings> qt_config;

View File

@ -69,7 +69,7 @@ void ConfigureAudio::SetOutputSinkFromSinkID() {
[[maybe_unused]] const QSignalBlocker blocker(ui->output_sink_combo_box); [[maybe_unused]] const QSignalBlocker blocker(ui->output_sink_combo_box);
int new_sink_index = 0; int new_sink_index = 0;
const QString sink_id = QString::fromStdString(Settings::values.sink_id.GetValue()); const QString sink_id = QString::fromStdString(Settings::values.sink_id);
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
if (ui->output_sink_combo_box->itemText(index) == sink_id) { if (ui->output_sink_combo_box->itemText(index) == sink_id) {
new_sink_index = index; new_sink_index = index;
@ -83,7 +83,7 @@ void ConfigureAudio::SetOutputSinkFromSinkID() {
void ConfigureAudio::SetAudioDeviceFromDeviceID() { void ConfigureAudio::SetAudioDeviceFromDeviceID() {
int new_device_index = -1; int new_device_index = -1;
const QString device_id = QString::fromStdString(Settings::values.audio_device_id.GetValue()); const QString device_id = QString::fromStdString(Settings::values.audio_device_id);
for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { for (int index = 0; index < ui->audio_device_combo_box->count(); index++) {
if (ui->audio_device_combo_box->itemText(index) == device_id) { if (ui->audio_device_combo_box->itemText(index) == device_id) {
new_device_index = index; new_device_index = index;
@ -106,9 +106,9 @@ void ConfigureAudio::ApplyConfiguration() {
Settings::values.sink_id = Settings::values.sink_id =
ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex())
.toStdString(); .toStdString();
Settings::values.audio_device_id.SetValue( Settings::values.audio_device_id =
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
.toStdString()); .toStdString();
// Guard if during game and set to game-specific value // Guard if during game and set to game-specific value
if (Settings::values.volume.UsingGlobal()) { if (Settings::values.volume.UsingGlobal()) {

View File

@ -24,26 +24,23 @@ void ConfigureCpuDebug::SetConfiguration() {
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
ui->cpuopt_page_tables->setEnabled(runtime_lock); ui->cpuopt_page_tables->setEnabled(runtime_lock);
ui->cpuopt_page_tables->setChecked(Settings::values.cpuopt_page_tables.GetValue()); ui->cpuopt_page_tables->setChecked(Settings::values.cpuopt_page_tables);
ui->cpuopt_block_linking->setEnabled(runtime_lock); ui->cpuopt_block_linking->setEnabled(runtime_lock);
ui->cpuopt_block_linking->setChecked(Settings::values.cpuopt_block_linking.GetValue()); ui->cpuopt_block_linking->setChecked(Settings::values.cpuopt_block_linking);
ui->cpuopt_return_stack_buffer->setEnabled(runtime_lock); ui->cpuopt_return_stack_buffer->setEnabled(runtime_lock);
ui->cpuopt_return_stack_buffer->setChecked( ui->cpuopt_return_stack_buffer->setChecked(Settings::values.cpuopt_return_stack_buffer);
Settings::values.cpuopt_return_stack_buffer.GetValue());
ui->cpuopt_fast_dispatcher->setEnabled(runtime_lock); ui->cpuopt_fast_dispatcher->setEnabled(runtime_lock);
ui->cpuopt_fast_dispatcher->setChecked(Settings::values.cpuopt_fast_dispatcher.GetValue()); ui->cpuopt_fast_dispatcher->setChecked(Settings::values.cpuopt_fast_dispatcher);
ui->cpuopt_context_elimination->setEnabled(runtime_lock); ui->cpuopt_context_elimination->setEnabled(runtime_lock);
ui->cpuopt_context_elimination->setChecked( ui->cpuopt_context_elimination->setChecked(Settings::values.cpuopt_context_elimination);
Settings::values.cpuopt_context_elimination.GetValue());
ui->cpuopt_const_prop->setEnabled(runtime_lock); ui->cpuopt_const_prop->setEnabled(runtime_lock);
ui->cpuopt_const_prop->setChecked(Settings::values.cpuopt_const_prop.GetValue()); ui->cpuopt_const_prop->setChecked(Settings::values.cpuopt_const_prop);
ui->cpuopt_misc_ir->setEnabled(runtime_lock); ui->cpuopt_misc_ir->setEnabled(runtime_lock);
ui->cpuopt_misc_ir->setChecked(Settings::values.cpuopt_misc_ir.GetValue()); ui->cpuopt_misc_ir->setChecked(Settings::values.cpuopt_misc_ir);
ui->cpuopt_reduce_misalign_checks->setEnabled(runtime_lock); ui->cpuopt_reduce_misalign_checks->setEnabled(runtime_lock);
ui->cpuopt_reduce_misalign_checks->setChecked( ui->cpuopt_reduce_misalign_checks->setChecked(Settings::values.cpuopt_reduce_misalign_checks);
Settings::values.cpuopt_reduce_misalign_checks.GetValue());
ui->cpuopt_fastmem->setEnabled(runtime_lock); ui->cpuopt_fastmem->setEnabled(runtime_lock);
ui->cpuopt_fastmem->setChecked(Settings::values.cpuopt_fastmem.GetValue()); ui->cpuopt_fastmem->setChecked(Settings::values.cpuopt_fastmem);
} }
void ConfigureCpuDebug::ApplyConfiguration() { void ConfigureCpuDebug::ApplyConfiguration() {

View File

@ -31,21 +31,20 @@ void ConfigureDebug::SetConfiguration() {
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
ui->toggle_console->setEnabled(runtime_lock); ui->toggle_console->setEnabled(runtime_lock);
ui->toggle_console->setChecked(UISettings::values.show_console.GetValue()); ui->toggle_console->setChecked(UISettings::values.show_console);
ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue())); ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter));
ui->homebrew_args_edit->setText( ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values.program_args));
QString::fromStdString(Settings::values.program_args.GetValue()));
ui->fs_access_log->setEnabled(runtime_lock); ui->fs_access_log->setEnabled(runtime_lock);
ui->fs_access_log->setChecked(Settings::values.enable_fs_access_log.GetValue()); ui->fs_access_log->setChecked(Settings::values.enable_fs_access_log);
ui->reporting_services->setChecked(Settings::values.reporting_services.GetValue()); ui->reporting_services->setChecked(Settings::values.reporting_services);
ui->quest_flag->setChecked(Settings::values.quest_flag.GetValue()); ui->quest_flag->setChecked(Settings::values.quest_flag);
ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts.GetValue()); ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts);
ui->use_auto_stub->setChecked(Settings::values.use_auto_stub.GetValue()); ui->use_auto_stub->setChecked(Settings::values.use_auto_stub);
ui->enable_graphics_debugging->setEnabled(runtime_lock); ui->enable_graphics_debugging->setEnabled(runtime_lock);
ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug.GetValue()); ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug);
ui->disable_macro_jit->setEnabled(runtime_lock); ui->disable_macro_jit->setEnabled(runtime_lock);
ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit.GetValue()); ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit);
ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue()); ui->extended_logging->setChecked(Settings::values.extended_logging);
} }
void ConfigureDebug::ApplyConfiguration() { void ConfigureDebug::ApplyConfiguration() {
@ -62,7 +61,7 @@ void ConfigureDebug::ApplyConfiguration() {
Settings::values.extended_logging = ui->extended_logging->isChecked(); Settings::values.extended_logging = ui->extended_logging->isChecked();
Debugger::ToggleConsole(); Debugger::ToggleConsole();
Common::Log::Filter filter; Common::Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter.GetValue()); filter.ParseFilterString(Settings::values.log_filter);
Common::Log::SetGlobalFilter(filter); Common::Log::SetGlobalFilter(filter);
} }

View File

@ -43,19 +43,18 @@ void ConfigureFilesystem::setConfiguration() {
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir))); QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir)));
ui->sdmc_directory_edit->setText( ui->sdmc_directory_edit->setText(
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::SDMCDir))); QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::SDMCDir)));
ui->gamecard_path_edit->setText( ui->gamecard_path_edit->setText(QString::fromStdString(Settings::values.gamecard_path));
QString::fromStdString(Settings::values.gamecard_path.GetValue()));
ui->dump_path_edit->setText( ui->dump_path_edit->setText(
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir))); QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir)));
ui->load_path_edit->setText( ui->load_path_edit->setText(
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir))); QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir)));
ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted.GetValue()); ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted);
ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game.GetValue()); ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game);
ui->dump_exefs->setChecked(Settings::values.dump_exefs.GetValue()); ui->dump_exefs->setChecked(Settings::values.dump_exefs);
ui->dump_nso->setChecked(Settings::values.dump_nso.GetValue()); ui->dump_nso->setChecked(Settings::values.dump_nso);
ui->cache_game_list->setChecked(UISettings::values.cache_game_list.GetValue()); ui->cache_game_list->setChecked(UISettings::values.cache_game_list);
UpdateEnabledControls(); UpdateEnabledControls();
} }

View File

@ -40,10 +40,10 @@ void ConfigureGeneral::SetConfiguration() {
ui->use_multi_core->setEnabled(runtime_lock); ui->use_multi_core->setEnabled(runtime_lock);
ui->use_multi_core->setChecked(Settings::values.use_multi_core.GetValue()); ui->use_multi_core->setChecked(Settings::values.use_multi_core.GetValue());
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse);
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue()); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue());
ui->frame_limit->setValue(Settings::values.frame_limit.GetValue()); ui->frame_limit->setValue(Settings::values.frame_limit.GetValue());

View File

@ -148,12 +148,12 @@ void ConfigureInputAdvanced::LoadConfiguration() {
} }
} }
ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled.GetValue()); ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled);
ui->mouse_enabled->setChecked(Settings::values.mouse_enabled.GetValue()); ui->mouse_enabled->setChecked(Settings::values.mouse_enabled);
ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled.GetValue()); ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled);
ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard.GetValue()); ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard);
ui->mouse_panning->setChecked(Settings::values.mouse_panning.GetValue()); ui->mouse_panning->setChecked(Settings::values.mouse_panning);
ui->mouse_panning_sensitivity->setValue(Settings::values.mouse_panning_sensitivity.GetValue()); ui->mouse_panning_sensitivity->setValue(Settings::values.mouse_panning_sensitivity);
ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled);
UpdateUIEnabled(); UpdateUIEnabled();

View File

@ -101,16 +101,15 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
ConfigureMotionTouch::~ConfigureMotionTouch() = default; ConfigureMotionTouch::~ConfigureMotionTouch() = default;
void ConfigureMotionTouch::SetConfiguration() { void ConfigureMotionTouch::SetConfiguration() {
const Common::ParamPackage motion_param(Settings::values.motion_device.GetValue()); const Common::ParamPackage motion_param(Settings::values.motion_device);
const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); const Common::ParamPackage touch_param(Settings::values.touch_device);
ui->touch_from_button_checkbox->setChecked(Settings::values.use_touch_from_button.GetValue()); ui->touch_from_button_checkbox->setChecked(Settings::values.use_touch_from_button);
touch_from_button_maps = Settings::values.touch_from_button_maps; touch_from_button_maps = Settings::values.touch_from_button_maps;
for (const auto& touch_map : touch_from_button_maps) { for (const auto& touch_map : touch_from_button_maps) {
ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name)); ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name));
} }
ui->touch_from_button_map->setCurrentIndex( ui->touch_from_button_map->setCurrentIndex(Settings::values.touch_from_button_map_index);
Settings::values.touch_from_button_map_index.GetValue());
ui->motion_sensitivity->setValue(motion_param.Get("sensitivity", 0.01f)); ui->motion_sensitivity->setValue(motion_param.Get("sensitivity", 0.01f));
min_x = touch_param.Get("min_x", 100); min_x = touch_param.Get("min_x", 100);
@ -125,7 +124,7 @@ void ConfigureMotionTouch::SetConfiguration() {
udp_server_list_model->setStringList({}); udp_server_list_model->setStringList({});
ui->udp_server_list->setModel(udp_server_list_model); ui->udp_server_list->setModel(udp_server_list_model);
std::stringstream ss(Settings::values.udp_input_servers.GetValue()); std::stringstream ss(Settings::values.udp_input_servers);
std::string token; std::string token;
while (std::getline(ss, token, ',')) { while (std::getline(ss, token, ',')) {

View File

@ -166,7 +166,7 @@ void ConfigureProfileManager::PopulateUserList() {
void ConfigureProfileManager::UpdateCurrentUser() { void ConfigureProfileManager::UpdateCurrentUser() {
ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS);
const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue()); const auto& current_user = profile_manager->GetUser(Settings::values.current_user);
ASSERT(current_user); ASSERT(current_user);
const auto username = GetAccountUsername(*profile_manager, *current_user); const auto username = GetAccountUsername(*profile_manager, *current_user);
@ -245,18 +245,15 @@ void ConfigureProfileManager::DeleteUser() {
this, tr("Confirm Delete"), this, tr("Confirm Delete"),
tr("You are about to delete user with name \"%1\". Are you sure?").arg(username)); tr("You are about to delete user with name \"%1\". Are you sure?").arg(username));
if (confirm == QMessageBox::No) { if (confirm == QMessageBox::No)
return; return;
}
if (Settings::values.current_user.GetValue() == tree_view->currentIndex().row()) { if (Settings::values.current_user == tree_view->currentIndex().row())
Settings::values.current_user = 0; Settings::values.current_user = 0;
}
UpdateCurrentUser(); UpdateCurrentUser();
if (!profile_manager->RemoveUser(*uuid)) { if (!profile_manager->RemoveUser(*uuid))
return; return;
}
item_model->removeRows(tree_view->currentIndex().row(), 1); item_model->removeRows(tree_view->currentIndex().row(), 1);
tree_view->clearSelection(); tree_view->clearSelection();

View File

@ -65,7 +65,7 @@ void ConfigureService::RetranslateUi() {
void ConfigureService::SetConfiguration() { void ConfigureService::SetConfiguration() {
const int index = const int index =
ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend.GetValue())); ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend));
ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index); ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index);
} }

View File

@ -113,12 +113,11 @@ void ConfigureUi::SetConfiguration() {
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
ui->language_combobox->setCurrentIndex( ui->language_combobox->setCurrentIndex(
ui->language_combobox->findData(UISettings::values.language)); ui->language_combobox->findData(UISettings::values.language));
ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue()); ui->show_add_ons->setChecked(UISettings::values.show_add_ons);
ui->icon_size_combobox->setCurrentIndex( ui->icon_size_combobox->setCurrentIndex(
ui->icon_size_combobox->findData(UISettings::values.icon_size.GetValue())); ui->icon_size_combobox->findData(UISettings::values.icon_size));
ui->enable_screenshot_save_as->setChecked( ui->enable_screenshot_save_as->setChecked(UISettings::values.enable_screenshot_save_as);
UISettings::values.enable_screenshot_save_as.GetValue());
ui->screenshot_path_edit->setText(QString::fromStdString( ui->screenshot_path_edit->setText(QString::fromStdString(
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir))); Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)));
} }
@ -179,7 +178,7 @@ void ConfigureUi::InitializeRowComboBoxes() {
void ConfigureUi::UpdateFirstRowComboBox(bool init) { void ConfigureUi::UpdateFirstRowComboBox(bool init) {
const int currentIndex = const int currentIndex =
init ? UISettings::values.row_1_text_id.GetValue() init ? UISettings::values.row_1_text_id
: ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData()); : ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData());
ui->row_1_text_combobox->clear(); ui->row_1_text_combobox->clear();
@ -198,7 +197,7 @@ void ConfigureUi::UpdateFirstRowComboBox(bool init) {
void ConfigureUi::UpdateSecondRowComboBox(bool init) { void ConfigureUi::UpdateSecondRowComboBox(bool init) {
const int currentIndex = const int currentIndex =
init ? UISettings::values.row_2_text_id.GetValue() init ? UISettings::values.row_2_text_id
: ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData()); : ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData());
ui->row_2_text_combobox->clear(); ui->row_2_text_combobox->clear();

View File

@ -88,22 +88,22 @@ void ConfigureWeb::SetConfiguration() {
ui->web_signup_link->setOpenExternalLinks(true); ui->web_signup_link->setOpenExternalLinks(true);
ui->web_token_info_link->setOpenExternalLinks(true); ui->web_token_info_link->setOpenExternalLinks(true);
if (Settings::values.yuzu_username.GetValue().empty()) { if (Settings::values.yuzu_username.empty()) {
ui->username->setText(tr("Unspecified")); ui->username->setText(tr("Unspecified"));
} else { } else {
ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue())); ui->username->setText(QString::fromStdString(Settings::values.yuzu_username));
} }
ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry.GetValue()); ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry);
ui->edit_token->setText(QString::fromStdString(GenerateDisplayToken( ui->edit_token->setText(QString::fromStdString(
Settings::values.yuzu_username.GetValue(), Settings::values.yuzu_token.GetValue()))); GenerateDisplayToken(Settings::values.yuzu_username, Settings::values.yuzu_token)));
// Connect after setting the values, to avoid calling OnLoginChanged now // Connect after setting the values, to avoid calling OnLoginChanged now
connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
user_verified = true; user_verified = true;
ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence);
} }
void ConfigureWeb::ApplyConfiguration() { void ConfigureWeb::ApplyConfiguration() {

View File

@ -15,10 +15,10 @@
namespace Debugger { namespace Debugger {
void ToggleConsole() { void ToggleConsole() {
static bool console_shown = false; static bool console_shown = false;
if (console_shown == UISettings::values.show_console.GetValue()) { if (console_shown == UISettings::values.show_console) {
return; return;
} else { } else {
console_shown = UISettings::values.show_console.GetValue(); console_shown = UISettings::values.show_console;
} }
#if defined(_WIN32) && !defined(_DEBUG) #if defined(_WIN32) && !defined(_DEBUG)

View File

@ -244,8 +244,7 @@ void GameList::OnUpdateThemedIcons() {
for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) { for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) {
QStandardItem* child = item_model->invisibleRootItem()->child(i); QStandardItem* child = item_model->invisibleRootItem()->child(i);
const int icon_size = const int icon_size = std::min(static_cast<int>(UISettings::values.icon_size), 64);
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) { switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) {
case GameListItemType::SdmcDir: case GameListItemType::SdmcDir:
child->setData( child->setData(

View File

@ -80,7 +80,7 @@ public:
setData(qulonglong(program_id), ProgramIdRole); setData(qulonglong(program_id), ProgramIdRole);
setData(game_type, FileTypeRole); setData(game_type, FileTypeRole);
const u32 size = UISettings::values.icon_size.GetValue(); const u32 size = UISettings::values.icon_size;
QPixmap picture; QPixmap picture;
if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) { if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) {
@ -108,8 +108,8 @@ public:
data(TitleRole).toString(), data(TitleRole).toString(),
}}; }};
const auto& row1 = row_data.at(UISettings::values.row_1_text_id.GetValue()); const auto& row1 = row_data.at(UISettings::values.row_1_text_id);
const int row2_id = UISettings::values.row_2_text_id.GetValue(); const int row2_id = UISettings::values.row_2_text_id;
if (role == SortRole) { if (role == SortRole) {
return row1.toLower(); return row1.toLower();
@ -233,8 +233,7 @@ public:
UISettings::GameDir* game_dir = &directory; UISettings::GameDir* game_dir = &directory;
setData(QVariant(UISettings::values.game_dirs.indexOf(directory)), GameDirRole); setData(QVariant(UISettings::values.game_dirs.indexOf(directory)), GameDirRole);
const int icon_size = const int icon_size = std::min(static_cast<int>(UISettings::values.icon_size), 64);
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
switch (dir_type) { switch (dir_type) {
case GameListItemType::SdmcDir: case GameListItemType::SdmcDir:
setData( setData(
@ -295,8 +294,7 @@ public:
explicit GameListAddDir() { explicit GameListAddDir() {
setData(type(), TypeRole); setData(type(), TypeRole);
const int icon_size = const int icon_size = std::min(static_cast<int>(UISettings::values.icon_size), 64);
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
setData(QIcon::fromTheme(QStringLiteral("plus")) setData(QIcon::fromTheme(QStringLiteral("plus"))
.pixmap(icon_size) .pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
@ -318,8 +316,7 @@ public:
explicit GameListFavorites() { explicit GameListFavorites() {
setData(type(), TypeRole); setData(type(), TypeRole);
const int icon_size = const int icon_size = std::min(static_cast<int>(UISettings::values.icon_size), 64);
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
setData(QIcon::fromTheme(QStringLiteral("star")) setData(QIcon::fromTheme(QStringLiteral("star"))
.pixmap(icon_size) .pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),

View File

@ -156,13 +156,11 @@ enum class CalloutFlag : uint32_t {
}; };
void GMainWindow::ShowTelemetryCallout() { void GMainWindow::ShowTelemetryCallout() {
if (UISettings::values.callout_flags.GetValue() & if (UISettings::values.callout_flags & static_cast<uint32_t>(CalloutFlag::Telemetry)) {
static_cast<uint32_t>(CalloutFlag::Telemetry)) {
return; return;
} }
UISettings::values.callout_flags = UISettings::values.callout_flags |= static_cast<uint32_t>(CalloutFlag::Telemetry);
UISettings::values.callout_flags.GetValue() | static_cast<uint32_t>(CalloutFlag::Telemetry);
const QString telemetry_message = const QString telemetry_message =
tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'>Anonymous " tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'>Anonymous "
"data is collected</a> to help improve yuzu. " "data is collected</a> to help improve yuzu. "
@ -179,7 +177,7 @@ static void InitializeLogging() {
using namespace Common; using namespace Common;
Log::Filter log_filter; Log::Filter log_filter;
log_filter.ParseFilterString(Settings::values.log_filter.GetValue()); log_filter.ParseFilterString(Settings::values.log_filter);
Log::SetGlobalFilter(log_filter); Log::SetGlobalFilter(log_filter);
const auto log_dir = FS::GetYuzuPath(FS::YuzuPath::LogDir); const auto log_dir = FS::GetYuzuPath(FS::YuzuPath::LogDir);
@ -218,7 +216,7 @@ GMainWindow::GMainWindow()
default_theme_paths = QIcon::themeSearchPaths(); default_theme_paths = QIcon::themeSearchPaths();
UpdateUITheme(); UpdateUITheme();
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); SetDiscordEnabled(UISettings::values.enable_discord_presence);
discord_rpc->Update(); discord_rpc->Update();
RegisterMetaTypes(); RegisterMetaTypes();
@ -1062,24 +1060,23 @@ void GMainWindow::RestoreUIState() {
render_window->restoreGeometry(UISettings::values.renderwindow_geometry); render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
#if MICROPROFILE_ENABLED #if MICROPROFILE_ENABLED
microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry); microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry);
microProfileDialog->setVisible(UISettings::values.microprofile_visible.GetValue()); microProfileDialog->setVisible(UISettings::values.microprofile_visible);
#endif #endif
game_list->LoadInterfaceLayout(); game_list->LoadInterfaceLayout();
ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
ToggleWindowMode(); ToggleWindowMode();
ui.action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); ui.action_Fullscreen->setChecked(UISettings::values.fullscreen);
ui.action_Display_Dock_Widget_Headers->setChecked( ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar);
UISettings::values.display_titlebar.GetValue());
OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar);
game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked());
ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar);
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
Debugger::ToggleConsole(); Debugger::ToggleConsole();
} }
@ -1246,14 +1243,13 @@ bool GMainWindow::LoadROM(const QString& filename, std::size_t program_index) {
const Core::System::ResultStatus result{ const Core::System::ResultStatus result{
system.Load(*render_window, filename.toStdString(), program_index)}; system.Load(*render_window, filename.toStdString(), program_index)};
const auto drd_callout = (UISettings::values.callout_flags.GetValue() & const auto drd_callout =
static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0; (UISettings::values.callout_flags & static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0;
if (result == Core::System::ResultStatus::Success && if (result == Core::System::ResultStatus::Success &&
system.GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && system.GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory &&
drd_callout) { drd_callout) {
UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | UISettings::values.callout_flags |= static_cast<u32>(CalloutFlag::DRDDeprecation);
static_cast<u32>(CalloutFlag::DRDDeprecation);
QMessageBox::warning( QMessageBox::warning(
this, tr("Warning Outdated Game Format"), this, tr("Warning Outdated Game Format"),
tr("You are using the deconstructed ROM directory format for this game, which is an " tr("You are using the deconstructed ROM directory format for this game, which is an "
@ -2457,8 +2453,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex
} }
void GMainWindow::OnMenuReportCompatibility() { void GMainWindow::OnMenuReportCompatibility() {
if (!Settings::values.yuzu_token.GetValue().empty() && if (!Settings::values.yuzu_token.empty() && !Settings::values.yuzu_username.empty()) {
!Settings::values.yuzu_username.GetValue().empty()) {
CompatDB compatdb{this}; CompatDB compatdb{this};
compatdb.exec(); compatdb.exec();
} else { } else {
@ -2623,7 +2618,7 @@ void GMainWindow::ResetWindowSize1080() {
void GMainWindow::OnConfigure() { void GMainWindow::OnConfigure() {
const auto old_theme = UISettings::values.theme; const auto old_theme = UISettings::values.theme;
const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); const bool old_discord_presence = UISettings::values.enable_discord_presence;
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get()); ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get());
connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this, connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this,
@ -2680,8 +2675,8 @@ void GMainWindow::OnConfigure() {
if (UISettings::values.theme != old_theme) { if (UISettings::values.theme != old_theme) {
UpdateUITheme(); UpdateUITheme();
} }
if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) { if (UISettings::values.enable_discord_presence != old_discord_presence) {
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); SetDiscordEnabled(UISettings::values.enable_discord_presence);
} }
emit UpdateThemedIcons(); emit UpdateThemedIcons();
@ -2837,8 +2832,7 @@ void GMainWindow::OnCaptureScreenshot() {
} }
} }
#endif #endif
render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor.GetValue(), render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, filename);
filename);
OnStartGame(); OnStartGame();
} }

View File

@ -13,7 +13,6 @@
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/settings.h"
namespace UISettings { namespace UISettings {
@ -49,26 +48,26 @@ struct Values {
QByteArray gamelist_header_state; QByteArray gamelist_header_state;
QByteArray microprofile_geometry; QByteArray microprofile_geometry;
Settings::BasicSetting<bool> microprofile_visible{false, "microProfileDialogVisible"}; bool microprofile_visible;
Settings::BasicSetting<bool> single_window_mode{true, "singleWindowMode"}; bool single_window_mode;
Settings::BasicSetting<bool> fullscreen{false, "fullscreen"}; bool fullscreen;
Settings::BasicSetting<bool> display_titlebar{true, "displayTitleBars"}; bool display_titlebar;
Settings::BasicSetting<bool> show_filter_bar{true, "showFilterBar"}; bool show_filter_bar;
Settings::BasicSetting<bool> show_status_bar{true, "showStatusBar"}; bool show_status_bar;
Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; bool confirm_before_closing;
Settings::BasicSetting<bool> first_start{true, "firstStart"}; bool first_start;
Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; bool pause_when_in_background;
Settings::BasicSetting<bool> hide_mouse{false, "hideInactiveMouse"}; bool hide_mouse;
Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; bool select_user_on_boot;
// Discord RPC // Discord RPC
Settings::BasicSetting<bool> enable_discord_presence{true, "enable_discord_presence"}; bool enable_discord_presence;
Settings::BasicSetting<bool> enable_screenshot_save_as{true, "enable_screenshot_save_as"}; bool enable_screenshot_save_as;
Settings::BasicSetting<u16> screenshot_resolution_factor{0, "screenshot_resolution_factor"}; u16 screenshot_resolution_factor;
QString roms_path; QString roms_path;
QString symbols_path; QString symbols_path;
@ -84,18 +83,18 @@ struct Values {
// Shortcut name <Shortcut, context> // Shortcut name <Shortcut, context>
std::vector<Shortcut> shortcuts; std::vector<Shortcut> shortcuts;
Settings::BasicSetting<uint32_t> callout_flags{0, "calloutFlags"}; uint32_t callout_flags;
// logging // logging
Settings::BasicSetting<bool> show_console{false, "showConsole"}; bool show_console;
// Game List // Game List
Settings::BasicSetting<bool> show_add_ons{true, "show_add_ons"}; bool show_add_ons;
Settings::BasicSetting<uint32_t> icon_size{64, "icon_size"}; uint32_t icon_size;
Settings::BasicSetting<uint8_t> row_1_text_id{3, "row_1_text_id"}; uint8_t row_1_text_id;
Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"}; uint8_t row_2_text_id;
std::atomic_bool is_game_list_reload_pending{false}; std::atomic_bool is_game_list_reload_pending{false};
Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"}; bool cache_game_list;
bool configuration_applied; bool configuration_applied;
bool reset_to_defaults; bool reset_to_defaults;

View File

@ -241,24 +241,6 @@ static const std::array<int, 8> keyboard_mods{
SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI, SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI,
}; };
template <>
void Config::ReadSetting(const std::string& group, Settings::BasicSetting<float>& setting) {
setting = sdl2_config->GetReal(group, setting.GetLabel(), setting.GetDefault());
}
template <>
void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) {
setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault());
}
template <>
void Config::ReadSetting(const std::string& group, Settings::BasicSetting<bool>& setting) {
setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault());
}
template <typename Type>
void Config::ReadSetting(const std::string& group, Settings::BasicSetting<Type>& setting) {
setting = static_cast<Type>(sdl2_config->GetInteger(group, setting.GetLabel(),
static_cast<long>(setting.GetDefault())));
}
void Config::ReadValues() { void Config::ReadValues() {
// Controls // Controls
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
@ -282,7 +264,8 @@ void Config::ReadValues() {
} }
} }
ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); Settings::values.mouse_enabled =
sdl2_config->GetBoolean("ControlsGeneral", "mouse_enabled", false);
for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
Settings::values.mouse_buttons[i] = sdl2_config->Get( Settings::values.mouse_buttons[i] = sdl2_config->Get(
@ -292,11 +275,14 @@ void Config::ReadValues() {
Settings::values.mouse_buttons[i] = default_param; Settings::values.mouse_buttons[i] = default_param;
} }
ReadSetting("ControlsGeneral", Settings::values.motion_device); Settings::values.motion_device = sdl2_config->Get(
"ControlsGeneral", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01");
ReadSetting("ControlsGeneral", Settings::values.keyboard_enabled); Settings::values.keyboard_enabled =
sdl2_config->GetBoolean("ControlsGeneral", "keyboard_enabled", false);
ReadSetting("ControlsGeneral", Settings::values.debug_pad_enabled); Settings::values.debug_pad_enabled =
sdl2_config->GetBoolean("ControlsGeneral", "debug_pad_enabled", false);
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
Settings::values.debug_pad_buttons[i] = sdl2_config->Get( Settings::values.debug_pad_buttons[i] = sdl2_config->Get(
@ -317,9 +303,12 @@ void Config::ReadValues() {
Settings::values.debug_pad_analogs[i] = default_param; Settings::values.debug_pad_analogs[i] = default_param;
} }
ReadSetting("ControlsGeneral", Settings::values.vibration_enabled); Settings::values.vibration_enabled.SetValue(
ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations); sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true));
ReadSetting("ControlsGeneral", Settings::values.motion_enabled); Settings::values.enable_accurate_vibrations.SetValue(
sdl2_config->GetBoolean("ControlsGeneral", "enable_accurate_vibrations", false));
Settings::values.motion_enabled.SetValue(
sdl2_config->GetBoolean("ControlsGeneral", "motion_enabled", true));
Settings::values.touchscreen.enabled = Settings::values.touchscreen.enabled =
sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true);
Settings::values.touchscreen.rotation_angle = Settings::values.touchscreen.rotation_angle =
@ -360,11 +349,13 @@ void Config::ReadValues() {
Settings::TouchFromButtonMap{"default", {}}); Settings::TouchFromButtonMap{"default", {}});
num_touch_from_button_maps = 1; num_touch_from_button_maps = 1;
} }
ReadSetting("ControlsGeneral", Settings::values.use_touch_from_button); Settings::values.use_touch_from_button =
Settings::values.touch_from_button_map_index = std::clamp( sdl2_config->GetBoolean("ControlsGeneral", "use_touch_from_button", false);
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1); Settings::values.touch_from_button_map_index =
std::clamp(Settings::values.touch_from_button_map_index, 0, num_touch_from_button_maps - 1);
ReadSetting("ControlsGeneral", Settings::values.udp_input_servers); Settings::values.udp_input_servers =
sdl2_config->Get("Controls", "udp_input_address", InputCommon::CemuhookUDP::DEFAULT_SRV);
std::transform(keyboard_keys.begin(), keyboard_keys.end(), std::transform(keyboard_keys.begin(), keyboard_keys.end(),
Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
@ -376,7 +367,8 @@ void Config::ReadValues() {
Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
// Data Storage // Data Storage
ReadSetting("Data Storage", Settings::values.use_virtual_sd); Settings::values.use_virtual_sd =
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
FS::SetYuzuPath(FS::YuzuPath::NANDDir, FS::SetYuzuPath(FS::YuzuPath::NANDDir,
sdl2_config->Get("Data Storage", "nand_directory", sdl2_config->Get("Data Storage", "nand_directory",
FS::GetYuzuPathString(FS::YuzuPath::NANDDir))); FS::GetYuzuPathString(FS::YuzuPath::NANDDir)));
@ -389,16 +381,18 @@ void Config::ReadValues() {
FS::SetYuzuPath(FS::YuzuPath::DumpDir, FS::SetYuzuPath(FS::YuzuPath::DumpDir,
sdl2_config->Get("Data Storage", "dump_directory", sdl2_config->Get("Data Storage", "dump_directory",
FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); FS::GetYuzuPathString(FS::YuzuPath::DumpDir)));
ReadSetting("Data Storage", Settings::values.gamecard_inserted); Settings::values.gamecard_inserted =
ReadSetting("Data Storage", Settings::values.gamecard_current_game); sdl2_config->GetBoolean("Data Storage", "gamecard_inserted", false);
ReadSetting("Data Storage", Settings::values.gamecard_path); Settings::values.gamecard_current_game =
sdl2_config->GetBoolean("Data Storage", "gamecard_current_game", false);
Settings::values.gamecard_path = sdl2_config->Get("Data Storage", "gamecard_path", "");
// System // System
ReadSetting("System", Settings::values.use_docked_mode); Settings::values.use_docked_mode.SetValue(
sdl2_config->GetBoolean("System", "use_docked_mode", true));
ReadSetting("System", Settings::values.current_user); Settings::values.current_user = std::clamp<int>(
Settings::values.current_user = std::clamp<int>(Settings::values.current_user.GetValue(), 0, sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1);
Service::Account::MAX_USERS - 1);
const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false);
if (rng_seed_enabled) { if (rng_seed_enabled) {
@ -415,60 +409,89 @@ void Config::ReadValues() {
Settings::values.custom_rtc = std::nullopt; Settings::values.custom_rtc = std::nullopt;
} }
ReadSetting("System", Settings::values.language_index); Settings::values.language_index.SetValue(
ReadSetting("System", Settings::values.time_zone_index); sdl2_config->GetInteger("System", "language_index", 1));
Settings::values.time_zone_index.SetValue(
sdl2_config->GetInteger("System", "time_zone_index", 0));
// Core // Core
ReadSetting("Core", Settings::values.use_multi_core); Settings::values.use_multi_core.SetValue(
sdl2_config->GetBoolean("Core", "use_multi_core", true));
// Renderer // Renderer
ReadSetting("Renderer", Settings::values.renderer_backend); const int renderer_backend = sdl2_config->GetInteger(
ReadSetting("Renderer", Settings::values.renderer_debug); "Renderer", "backend", static_cast<int>(Settings::RendererBackend::OpenGL));
ReadSetting("Renderer", Settings::values.vulkan_device); Settings::values.renderer_backend.SetValue(
static_cast<Settings::RendererBackend>(renderer_backend));
Settings::values.renderer_debug = sdl2_config->GetBoolean("Renderer", "debug", false);
Settings::values.vulkan_device.SetValue(
sdl2_config->GetInteger("Renderer", "vulkan_device", 0));
ReadSetting("Renderer", Settings::values.aspect_ratio); Settings::values.aspect_ratio.SetValue(
ReadSetting("Renderer", Settings::values.max_anisotropy); static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)));
ReadSetting("Renderer", Settings::values.use_frame_limit); Settings::values.max_anisotropy.SetValue(
ReadSetting("Renderer", Settings::values.frame_limit); static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)));
ReadSetting("Renderer", Settings::values.use_disk_shader_cache); Settings::values.use_frame_limit.SetValue(
ReadSetting("Renderer", Settings::values.gpu_accuracy); sdl2_config->GetBoolean("Renderer", "use_frame_limit", true));
ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation); Settings::values.frame_limit.SetValue(
ReadSetting("Renderer", Settings::values.use_vsync); static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)));
ReadSetting("Renderer", Settings::values.disable_fps_limit); Settings::values.use_disk_shader_cache.SetValue(
ReadSetting("Renderer", Settings::values.use_assembly_shaders); sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false));
ReadSetting("Renderer", Settings::values.use_asynchronous_shaders); const int gpu_accuracy_level = sdl2_config->GetInteger("Renderer", "gpu_accuracy", 1);
ReadSetting("Renderer", Settings::values.use_nvdec_emulation); Settings::values.gpu_accuracy.SetValue(static_cast<Settings::GPUAccuracy>(gpu_accuracy_level));
ReadSetting("Renderer", Settings::values.accelerate_astc); Settings::values.use_asynchronous_gpu_emulation.SetValue(
ReadSetting("Renderer", Settings::values.use_fast_gpu_time); sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", true));
Settings::values.use_vsync.SetValue(
static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1)));
Settings::values.disable_fps_limit.SetValue(
sdl2_config->GetBoolean("Renderer", "disable_fps_limit", false));
Settings::values.use_assembly_shaders.SetValue(
sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true));
Settings::values.use_asynchronous_shaders.SetValue(
sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false));
Settings::values.use_nvdec_emulation.SetValue(
sdl2_config->GetBoolean("Renderer", "use_nvdec_emulation", true));
Settings::values.accelerate_astc.SetValue(
sdl2_config->GetBoolean("Renderer", "accelerate_astc", true));
Settings::values.use_fast_gpu_time.SetValue(
sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true));
ReadSetting("Renderer", Settings::values.bg_red); Settings::values.bg_red.SetValue(
ReadSetting("Renderer", Settings::values.bg_green); static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0)));
ReadSetting("Renderer", Settings::values.bg_blue); Settings::values.bg_green.SetValue(
static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0)));
Settings::values.bg_blue.SetValue(
static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0)));
// Audio // Audio
ReadSetting("Audio", Settings::values.sink_id); Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto");
ReadSetting("Audio", Settings::values.enable_audio_stretching); Settings::values.enable_audio_stretching.SetValue(
ReadSetting("Audio", Settings::values.audio_device_id); sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true));
ReadSetting("Audio", Settings::values.volume); Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto");
Settings::values.volume.SetValue(
static_cast<float>(sdl2_config->GetReal("Audio", "volume", 1)));
// Miscellaneous // Miscellaneous
// log_filter has a different default here than from common Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace");
Settings::values.log_filter = Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false);
sdl2_config->Get("Miscellaneous", Settings::values.log_filter.GetLabel(), "*:Trace");
ReadSetting("Miscellaneous", Settings::values.use_dev_keys);
// Debugging // Debugging
Settings::values.record_frame_times = Settings::values.record_frame_times =
sdl2_config->GetBoolean("Debugging", "record_frame_times", false); sdl2_config->GetBoolean("Debugging", "record_frame_times", false);
ReadSetting("Debugging", Settings::values.program_args); Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", "");
ReadSetting("Debugging", Settings::values.dump_exefs); Settings::values.dump_exefs = sdl2_config->GetBoolean("Debugging", "dump_exefs", false);
ReadSetting("Debugging", Settings::values.dump_nso); Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false);
ReadSetting("Debugging", Settings::values.enable_fs_access_log); Settings::values.enable_fs_access_log =
ReadSetting("Debugging", Settings::values.reporting_services); sdl2_config->GetBoolean("Debugging", "enable_fs_access_log", false);
ReadSetting("Debugging", Settings::values.quest_flag); Settings::values.reporting_services =
ReadSetting("Debugging", Settings::values.use_debug_asserts); sdl2_config->GetBoolean("Debugging", "reporting_services", false);
ReadSetting("Debugging", Settings::values.use_auto_stub); Settings::values.quest_flag = sdl2_config->GetBoolean("Debugging", "quest_flag", false);
ReadSetting("Debugging", Settings::values.disable_macro_jit); Settings::values.use_debug_asserts =
sdl2_config->GetBoolean("Debugging", "use_debug_asserts", false);
Settings::values.use_auto_stub = sdl2_config->GetBoolean("Debugging", "use_auto_stub", false);
Settings::values.disable_macro_jit =
sdl2_config->GetBoolean("Debugging", "disable_macro_jit", false);
const auto title_list = sdl2_config->Get("AddOns", "title_ids", ""); const auto title_list = sdl2_config->Get("AddOns", "title_ids", "");
std::stringstream ss(title_list); std::stringstream ss(title_list);
@ -488,14 +511,17 @@ void Config::ReadValues() {
} }
// Web Service // Web Service
ReadSetting("WebService", Settings::values.enable_telemetry); Settings::values.enable_telemetry =
ReadSetting("WebService", Settings::values.web_api_url); sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
ReadSetting("WebService", Settings::values.yuzu_username); Settings::values.web_api_url =
ReadSetting("WebService", Settings::values.yuzu_token); sdl2_config->Get("WebService", "web_api_url", "https://api.yuzu-emu.org");
Settings::values.yuzu_username = sdl2_config->Get("WebService", "yuzu_username", "");
Settings::values.yuzu_token = sdl2_config->Get("WebService", "yuzu_token", "");
// Services // Services
ReadSetting("Services", Settings::values.bcat_backend); Settings::values.bcat_backend = sdl2_config->Get("Services", "bcat_backend", "none");
ReadSetting("Services", Settings::values.bcat_boxcat_local); Settings::values.bcat_boxcat_local =
sdl2_config->GetBoolean("Services", "bcat_boxcat_local", false);
} }
void Config::Reload() { void Config::Reload() {

View File

@ -8,8 +8,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "common/settings.h"
class INIReader; class INIReader;
class Config { class Config {
@ -24,14 +22,4 @@ public:
~Config(); ~Config();
void Reload(); void Reload();
private:
/**
* Applies a value read from the sdl2_config to a BasicSetting.
*
* @param group The name of the INI group
* @param setting The yuzu setting to modify
*/
template <typename Type>
void ReadSetting(const std::string& group, Settings::BasicSetting<Type>& setting);
}; };

View File

@ -78,7 +78,7 @@ static void InitializeLogging() {
using namespace Common; using namespace Common;
Log::Filter log_filter(Log::Level::Debug); Log::Filter log_filter(Log::Level::Debug);
log_filter.ParseFilterString(static_cast<std::string>(Settings::values.log_filter)); log_filter.ParseFilterString(Settings::values.log_filter);
Log::SetGlobalFilter(log_filter); Log::SetGlobalFilter(log_filter);
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>()); Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());