2021-04-14 16:07:40 -07:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
2014-12-16 21:38:14 -08:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-09-12 17:06:13 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2015-06-20 04:34:45 +01:00
|
|
|
#include <array>
|
2018-09-09 00:57:41 +02:00
|
|
|
#include <atomic>
|
2018-12-28 20:24:24 -05:00
|
|
|
#include <chrono>
|
2018-11-28 13:59:40 -05:00
|
|
|
#include <map>
|
2018-11-11 22:34:23 -05:00
|
|
|
#include <optional>
|
2016-09-18 09:38:01 +09:00
|
|
|
#include <string>
|
2018-11-28 13:59:40 -05:00
|
|
|
#include <vector>
|
2014-12-06 20:00:08 -02:00
|
|
|
|
2021-04-14 16:07:40 -07:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
#include "common/settings_input.h"
|
2020-11-27 10:50:48 -05:00
|
|
|
|
2014-09-12 17:06:13 -07:00
|
|
|
namespace Settings {
|
|
|
|
|
|
2021-04-14 16:07:40 -07:00
|
|
|
enum class RendererBackend : u32 {
|
2020-01-21 16:37:41 -03:00
|
|
|
OpenGL = 0,
|
|
|
|
|
Vulkan = 1,
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-18 16:51:42 -04:00
|
|
|
enum class GPUAccuracy : u32 {
|
|
|
|
|
Normal = 0,
|
|
|
|
|
High = 1,
|
|
|
|
|
Extreme = 2,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-14 16:07:40 -07:00
|
|
|
enum class CPUAccuracy : u32 {
|
2020-07-11 16:25:49 +01:00
|
|
|
Accurate = 0,
|
2020-08-16 13:19:55 +01:00
|
|
|
Unsafe = 1,
|
|
|
|
|
DebugMode = 2,
|
2020-07-11 16:25:49 +01:00
|
|
|
};
|
|
|
|
|
|
2020-07-09 22:42:09 -04:00
|
|
|
template <typename Type>
|
|
|
|
|
class Setting final {
|
|
|
|
|
public:
|
2021-06-26 02:43:38 -04:00
|
|
|
explicit Setting(Type val) : global{val} {
|
|
|
|
|
default_value = val;
|
|
|
|
|
}
|
2020-07-09 22:42:09 -04:00
|
|
|
~Setting() = default;
|
|
|
|
|
void SetGlobal(bool to_global) {
|
|
|
|
|
use_global = to_global;
|
|
|
|
|
}
|
|
|
|
|
bool UsingGlobal() const {
|
|
|
|
|
return use_global;
|
|
|
|
|
}
|
|
|
|
|
Type GetValue(bool need_global = false) const {
|
|
|
|
|
if (use_global || need_global) {
|
|
|
|
|
return global;
|
|
|
|
|
}
|
|
|
|
|
return local;
|
|
|
|
|
}
|
|
|
|
|
void SetValue(const Type& value) {
|
|
|
|
|
if (use_global) {
|
|
|
|
|
global = value;
|
|
|
|
|
} else {
|
|
|
|
|
local = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 02:43:38 -04:00
|
|
|
Type GetDefault() const {
|
|
|
|
|
return default_value;
|
|
|
|
|
}
|
2020-07-09 22:42:09 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool use_global = true;
|
|
|
|
|
Type global{};
|
|
|
|
|
Type local{};
|
2021-06-26 02:43:38 -04:00
|
|
|
Type default_value{};
|
2020-07-09 22:42:09 -04:00
|
|
|
};
|
|
|
|
|
|
2020-09-28 10:00:15 -04:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* 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 local (per-game)
|
|
|
|
|
* setting and allows for easily accessing and modifying both settings.
|
|
|
|
|
*/
|
|
|
|
|
template <typename Type>
|
|
|
|
|
class InputSetting final {
|
|
|
|
|
public:
|
|
|
|
|
InputSetting() = default;
|
|
|
|
|
explicit InputSetting(Type val) : global{val} {}
|
|
|
|
|
~InputSetting() = default;
|
|
|
|
|
void SetGlobal(bool to_global) {
|
|
|
|
|
use_global = to_global;
|
|
|
|
|
}
|
|
|
|
|
bool UsingGlobal() const {
|
|
|
|
|
return use_global;
|
|
|
|
|
}
|
|
|
|
|
Type& GetValue(bool need_global = false) {
|
|
|
|
|
if (use_global || need_global) {
|
|
|
|
|
return global;
|
|
|
|
|
}
|
|
|
|
|
return local;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool use_global = true;
|
|
|
|
|
Type global{};
|
|
|
|
|
Type local{};
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-14 19:01:36 +02:00
|
|
|
struct TouchFromButtonMap {
|
|
|
|
|
std::string name;
|
|
|
|
|
std::vector<std::string> buttons;
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-12 17:06:13 -07:00
|
|
|
struct Values {
|
2020-07-09 22:42:09 -04:00
|
|
|
// Audio
|
|
|
|
|
std::string audio_device_id;
|
|
|
|
|
std::string sink_id;
|
|
|
|
|
bool audio_muted;
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> enable_audio_stretching{true};
|
|
|
|
|
Setting<float> volume{1.0f};
|
2020-07-09 22:42:09 -04:00
|
|
|
|
|
|
|
|
// Core
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> use_multi_core{true};
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2020-07-11 14:26:36 +01:00
|
|
|
// Cpu
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<CPUAccuracy> cpu_accuracy{CPUAccuracy::Accurate};
|
2020-07-11 16:25:49 +01:00
|
|
|
|
2020-07-11 14:26:36 +01:00
|
|
|
bool cpuopt_page_tables;
|
|
|
|
|
bool cpuopt_block_linking;
|
|
|
|
|
bool cpuopt_return_stack_buffer;
|
|
|
|
|
bool cpuopt_fast_dispatcher;
|
|
|
|
|
bool cpuopt_context_elimination;
|
|
|
|
|
bool cpuopt_const_prop;
|
|
|
|
|
bool cpuopt_misc_ir;
|
|
|
|
|
bool cpuopt_reduce_misalign_checks;
|
2021-06-06 09:57:24 +02:00
|
|
|
bool cpuopt_fastmem;
|
2020-07-11 14:26:36 +01:00
|
|
|
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> cpuopt_unsafe_unfuse_fma{true};
|
|
|
|
|
Setting<bool> cpuopt_unsafe_reduce_fp_error{true};
|
|
|
|
|
Setting<bool> cpuopt_unsafe_ignore_standard_fpcr{true};
|
|
|
|
|
Setting<bool> cpuopt_unsafe_inaccurate_nan{true};
|
|
|
|
|
Setting<bool> cpuopt_unsafe_fastmem_check{true};
|
2020-08-16 13:19:55 +01:00
|
|
|
|
2020-07-09 22:42:09 -04:00
|
|
|
// Renderer
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<RendererBackend> renderer_backend{RendererBackend::OpenGL};
|
2020-07-09 22:42:09 -04:00
|
|
|
bool renderer_debug;
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<int> vulkan_device{0};
|
|
|
|
|
|
|
|
|
|
Setting<u16> resolution_factor{0};
|
|
|
|
|
// *nix platforms may have issues with the borderless windowed fullscreen mode.
|
|
|
|
|
// Default to exclusive fullscreen on these platforms for now.
|
|
|
|
|
Setting<int> fullscreen_mode{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
0
|
|
|
|
|
#else
|
|
|
|
|
1
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
Setting<int> aspect_ratio{0};
|
|
|
|
|
Setting<int> max_anisotropy{0};
|
|
|
|
|
Setting<bool> use_frame_limit{true};
|
|
|
|
|
Setting<u16> frame_limit{100};
|
|
|
|
|
Setting<bool> use_disk_shader_cache{true};
|
|
|
|
|
Setting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High};
|
|
|
|
|
Setting<bool> use_asynchronous_gpu_emulation{true};
|
|
|
|
|
Setting<bool> use_nvdec_emulation{true};
|
|
|
|
|
Setting<bool> accelerate_astc{true};
|
|
|
|
|
Setting<bool> use_vsync{true};
|
|
|
|
|
Setting<bool> disable_fps_limit{false};
|
|
|
|
|
Setting<bool> use_assembly_shaders{false};
|
|
|
|
|
Setting<bool> use_asynchronous_shaders{false};
|
|
|
|
|
Setting<bool> use_fast_gpu_time{true};
|
|
|
|
|
Setting<bool> use_caches_gc{false};
|
|
|
|
|
|
|
|
|
|
Setting<float> bg_red{0.0f};
|
|
|
|
|
Setting<float> bg_green{0.0f};
|
|
|
|
|
Setting<float> bg_blue{0.0f};
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2018-03-26 22:24:31 -04:00
|
|
|
// System
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<std::optional<u32>> rng_seed{std::optional<u32>()};
|
2019-01-07 19:40:23 -05:00
|
|
|
// Measured in seconds since epoch
|
2021-05-16 01:17:18 -04:00
|
|
|
std::optional<std::chrono::seconds> custom_rtc;
|
2019-01-07 19:40:23 -05:00
|
|
|
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
|
|
|
|
|
std::chrono::seconds custom_rtc_differential;
|
|
|
|
|
|
2018-11-06 16:38:10 +01:00
|
|
|
s32 current_user;
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<s32> language_index{1};
|
|
|
|
|
Setting<s32> region_index{1};
|
|
|
|
|
Setting<s32> time_zone_index{0};
|
|
|
|
|
Setting<s32> sound_index{1};
|
2018-03-26 22:24:31 -04:00
|
|
|
|
2014-10-25 12:54:44 -07:00
|
|
|
// Controls
|
2020-09-28 10:00:15 -04:00
|
|
|
InputSetting<std::array<PlayerInput, 10>> players;
|
|
|
|
|
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> use_docked_mode{true};
|
2018-11-01 21:54:16 -04:00
|
|
|
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> vibration_enabled{true};
|
|
|
|
|
Setting<bool> enable_accurate_vibrations{false};
|
2020-09-28 10:00:15 -04:00
|
|
|
|
2021-06-26 02:43:38 -04:00
|
|
|
Setting<bool> motion_enabled{true};
|
2020-09-28 10:00:15 -04:00
|
|
|
std::string motion_device;
|
2020-11-17 22:16:29 -06:00
|
|
|
std::string udp_input_servers;
|
2020-07-22 10:39:53 -04:00
|
|
|
|
2021-02-03 12:34:25 -06:00
|
|
|
bool mouse_panning;
|
|
|
|
|
float mouse_panning_sensitivity;
|
2018-11-01 21:52:51 -04:00
|
|
|
bool mouse_enabled;
|
|
|
|
|
std::string mouse_device;
|
|
|
|
|
MouseButtonsRaw mouse_buttons;
|
2018-11-01 21:53:31 -04:00
|
|
|
|
2021-02-03 12:34:25 -06:00
|
|
|
bool emulate_analog_keyboard;
|
2018-11-01 21:53:31 -04:00
|
|
|
bool keyboard_enabled;
|
|
|
|
|
KeyboardKeysRaw keyboard_keys;
|
|
|
|
|
KeyboardModsRaw keyboard_mods;
|
2018-11-01 21:54:16 -04:00
|
|
|
|
|
|
|
|
bool debug_pad_enabled;
|
|
|
|
|
ButtonsRaw debug_pad_buttons;
|
|
|
|
|
AnalogsRaw debug_pad_analogs;
|
|
|
|
|
|
|
|
|
|
TouchscreenInput touchscreen;
|
2020-09-28 10:00:15 -04:00
|
|
|
|
2020-07-14 19:01:36 +02:00
|
|
|
bool use_touch_from_button;
|
2020-09-28 10:00:15 -04:00
|
|
|
std::string touch_device;
|
2020-07-14 19:01:36 +02:00
|
|
|
int touch_from_button_map_index;
|
|
|
|
|
std::vector<TouchFromButtonMap> touch_from_button_maps;
|
2017-01-20 22:46:39 +02:00
|
|
|
|
2020-09-28 10:00:15 -04:00
|
|
|
std::atomic_bool is_device_reload_pending{true};
|
|
|
|
|
|
2014-10-25 12:54:44 -07:00
|
|
|
// Data Storage
|
2014-10-09 19:43:40 -07:00
|
|
|
bool use_virtual_sd;
|
2019-04-23 08:35:12 -04:00
|
|
|
bool gamecard_inserted;
|
|
|
|
|
bool gamecard_current_game;
|
|
|
|
|
std::string gamecard_path;
|
2014-10-27 17:18:28 -04:00
|
|
|
|
2015-09-02 08:56:38 -04:00
|
|
|
// Debugging
|
2019-08-26 17:29:08 +02:00
|
|
|
bool record_frame_times;
|
2015-09-02 08:56:38 -04:00
|
|
|
bool use_gdbstub;
|
|
|
|
|
u16 gdbstub_port;
|
2018-09-30 14:05:12 -04:00
|
|
|
std::string program_args;
|
2018-11-20 17:49:09 -05:00
|
|
|
bool dump_exefs;
|
2018-10-29 16:09:08 -04:00
|
|
|
bool dump_nso;
|
2021-06-13 04:30:54 -04:00
|
|
|
bool enable_fs_access_log;
|
2019-05-17 21:44:28 -04:00
|
|
|
bool reporting_services;
|
2019-06-28 18:37:33 -04:00
|
|
|
bool quest_flag;
|
2020-05-29 14:53:27 +10:00
|
|
|
bool disable_macro_jit;
|
2020-07-29 10:25:37 -07:00
|
|
|
bool extended_logging;
|
2021-04-13 18:38:10 -07:00
|
|
|
bool use_debug_asserts;
|
2021-03-12 17:56:02 -05:00
|
|
|
bool use_auto_stub;
|
2018-09-16 20:05:51 +02:00
|
|
|
|
2021-01-01 21:29:53 +01:00
|
|
|
// Miscellaneous
|
2020-07-09 22:42:09 -04:00
|
|
|
std::string log_filter;
|
|
|
|
|
bool use_dev_keys;
|
|
|
|
|
|
|
|
|
|
// Services
|
2019-04-28 18:44:46 -04:00
|
|
|
std::string bcat_backend;
|
|
|
|
|
bool bcat_boxcat_local;
|
|
|
|
|
|
2018-09-16 20:05:51 +02:00
|
|
|
// WebService
|
|
|
|
|
bool enable_telemetry;
|
|
|
|
|
std::string web_api_url;
|
|
|
|
|
std::string yuzu_username;
|
|
|
|
|
std::string yuzu_token;
|
2018-11-28 13:59:40 -05:00
|
|
|
|
|
|
|
|
// Add-Ons
|
|
|
|
|
std::map<u64, std::vector<std::string>> disabled_addons;
|
2020-11-04 04:16:34 -05:00
|
|
|
};
|
2014-09-12 17:06:13 -07:00
|
|
|
|
2020-11-04 04:16:34 -05:00
|
|
|
extern Values values;
|
|
|
|
|
|
|
|
|
|
bool IsConfiguringGlobal();
|
|
|
|
|
void SetConfiguringGlobal(bool is_global);
|
2020-06-25 21:05:03 +02:00
|
|
|
|
2020-04-15 21:42:05 -04:00
|
|
|
bool IsGPULevelExtreme();
|
|
|
|
|
bool IsGPULevelHigh();
|
2020-02-18 16:51:42 -04:00
|
|
|
|
2021-06-06 09:57:24 +02:00
|
|
|
bool IsFastmemEnabled();
|
|
|
|
|
|
2020-11-04 04:16:34 -05:00
|
|
|
float Volume();
|
|
|
|
|
|
2020-05-11 17:50:07 -04:00
|
|
|
std::string GetTimeZoneString();
|
|
|
|
|
|
2018-07-10 18:02:14 +08:00
|
|
|
void LogSettings();
|
2020-05-11 17:50:07 -04:00
|
|
|
|
2020-07-09 22:42:09 -04:00
|
|
|
// Restore the global state of all applicable settings in the Values struct
|
2020-11-27 10:50:48 -05:00
|
|
|
void RestoreGlobalState(bool is_powered_on);
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2017-08-25 23:53:07 +02:00
|
|
|
} // namespace Settings
|