summaryrefslogtreecommitdiff
path: root/src/core/settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/settings.h')
-rw-r--r--src/core/settings.h265
1 files changed, 0 insertions, 265 deletions
diff --git a/src/core/settings.h b/src/core/settings.h
deleted file mode 100644
index 0b7d28421..000000000
--- a/src/core/settings.h
+++ /dev/null
@@ -1,265 +0,0 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <array>
8#include <atomic>
9#include <chrono>
10#include <map>
11#include <optional>
12#include <string>
13#include <vector>
14#include "common/common_types.h"
15#include "input_common/settings.h"
16
17namespace Core {
18class System;
19}
20
21namespace Settings {
22
23enum class RendererBackend {
24 OpenGL = 0,
25 Vulkan = 1,
26};
27
28enum class GPUAccuracy : u32 {
29 Normal = 0,
30 High = 1,
31 Extreme = 2,
32};
33
34enum class CPUAccuracy {
35 Accurate = 0,
36 Unsafe = 1,
37 DebugMode = 2,
38};
39
40template <typename Type>
41class Setting final {
42public:
43 Setting() = default;
44 explicit Setting(Type val) : global{val} {}
45 ~Setting() = default;
46 void SetGlobal(bool to_global) {
47 use_global = to_global;
48 }
49 bool UsingGlobal() const {
50 return use_global;
51 }
52 Type GetValue(bool need_global = false) const {
53 if (use_global || need_global) {
54 return global;
55 }
56 return local;
57 }
58 void SetValue(const Type& value) {
59 if (use_global) {
60 global = value;
61 } else {
62 local = value;
63 }
64 }
65
66private:
67 bool use_global = true;
68 Type global{};
69 Type local{};
70};
71
72/**
73 * The InputSetting class allows for getting a reference to either the global or local members.
74 * This is required as we cannot easily modify the values of user-defined types within containers
75 * using the SetValue() member function found in the Setting class. The primary purpose of this
76 * class is to store an array of 10 PlayerInput structs for both the global and local (per-game)
77 * setting and allows for easily accessing and modifying both settings.
78 */
79template <typename Type>
80class InputSetting final {
81public:
82 InputSetting() = default;
83 explicit InputSetting(Type val) : global{val} {}
84 ~InputSetting() = default;
85 void SetGlobal(bool to_global) {
86 use_global = to_global;
87 }
88 bool UsingGlobal() const {
89 return use_global;
90 }
91 Type& GetValue(bool need_global = false) {
92 if (use_global || need_global) {
93 return global;
94 }
95 return local;
96 }
97
98private:
99 bool use_global = true;
100 Type global{};
101 Type local{};
102};
103
104struct TouchFromButtonMap {
105 std::string name;
106 std::vector<std::string> buttons;
107};
108
109struct Values {
110 // Audio
111 std::string audio_device_id;
112 std::string sink_id;
113 bool audio_muted;
114 Setting<bool> enable_audio_stretching;
115 Setting<float> volume;
116
117 // Core
118 Setting<bool> use_multi_core;
119
120 // Cpu
121 CPUAccuracy cpu_accuracy;
122
123 bool cpuopt_page_tables;
124 bool cpuopt_block_linking;
125 bool cpuopt_return_stack_buffer;
126 bool cpuopt_fast_dispatcher;
127 bool cpuopt_context_elimination;
128 bool cpuopt_const_prop;
129 bool cpuopt_misc_ir;
130 bool cpuopt_reduce_misalign_checks;
131
132 bool cpuopt_unsafe_unfuse_fma;
133 bool cpuopt_unsafe_reduce_fp_error;
134 bool cpuopt_unsafe_inaccurate_nan;
135
136 // Renderer
137 Setting<RendererBackend> renderer_backend;
138 bool renderer_debug;
139 Setting<int> vulkan_device;
140
141 Setting<u16> resolution_factor{1};
142 Setting<int> fullscreen_mode;
143 Setting<int> aspect_ratio;
144 Setting<int> max_anisotropy;
145 Setting<bool> use_frame_limit;
146 Setting<u16> frame_limit;
147 Setting<bool> use_disk_shader_cache;
148 Setting<GPUAccuracy> gpu_accuracy;
149 Setting<bool> use_asynchronous_gpu_emulation;
150 Setting<bool> use_nvdec_emulation;
151 Setting<bool> use_vsync;
152 Setting<bool> use_assembly_shaders;
153 Setting<bool> use_asynchronous_shaders;
154 Setting<bool> use_fast_gpu_time;
155
156 Setting<float> bg_red;
157 Setting<float> bg_green;
158 Setting<float> bg_blue;
159
160 // System
161 Setting<std::optional<u32>> rng_seed;
162 // Measured in seconds since epoch
163 Setting<std::optional<std::chrono::seconds>> custom_rtc;
164 // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
165 std::chrono::seconds custom_rtc_differential;
166
167 s32 current_user;
168 Setting<s32> language_index;
169 Setting<s32> region_index;
170 Setting<s32> time_zone_index;
171 Setting<s32> sound_index;
172
173 // Controls
174 InputSetting<std::array<PlayerInput, 10>> players;
175
176 Setting<bool> use_docked_mode;
177
178 Setting<bool> vibration_enabled;
179 Setting<bool> enable_accurate_vibrations;
180
181 Setting<bool> motion_enabled;
182 std::string motion_device;
183 std::string udp_input_servers;
184
185 bool mouse_panning;
186 float mouse_panning_sensitivity;
187 bool mouse_enabled;
188 std::string mouse_device;
189 MouseButtonsRaw mouse_buttons;
190
191 bool emulate_analog_keyboard;
192 bool keyboard_enabled;
193 KeyboardKeysRaw keyboard_keys;
194 KeyboardModsRaw keyboard_mods;
195
196 bool debug_pad_enabled;
197 ButtonsRaw debug_pad_buttons;
198 AnalogsRaw debug_pad_analogs;
199
200 TouchscreenInput touchscreen;
201
202 bool use_touch_from_button;
203 std::string touch_device;
204 int touch_from_button_map_index;
205 std::vector<TouchFromButtonMap> touch_from_button_maps;
206
207 std::atomic_bool is_device_reload_pending{true};
208
209 // Data Storage
210 bool use_virtual_sd;
211 bool gamecard_inserted;
212 bool gamecard_current_game;
213 std::string gamecard_path;
214
215 // Debugging
216 bool record_frame_times;
217 bool use_gdbstub;
218 u16 gdbstub_port;
219 std::string program_args;
220 bool dump_exefs;
221 bool dump_nso;
222 bool reporting_services;
223 bool quest_flag;
224 bool disable_macro_jit;
225 bool extended_logging;
226 bool use_debug_asserts;
227 bool use_auto_stub;
228
229 // Miscellaneous
230 std::string log_filter;
231 bool use_dev_keys;
232
233 // Services
234 std::string bcat_backend;
235 bool bcat_boxcat_local;
236
237 // WebService
238 bool enable_telemetry;
239 std::string web_api_url;
240 std::string yuzu_username;
241 std::string yuzu_token;
242
243 // Add-Ons
244 std::map<u64, std::vector<std::string>> disabled_addons;
245};
246
247extern Values values;
248
249bool IsConfiguringGlobal();
250void SetConfiguringGlobal(bool is_global);
251
252bool IsGPULevelExtreme();
253bool IsGPULevelHigh();
254
255float Volume();
256
257std::string GetTimeZoneString();
258
259void Apply(Core::System& system);
260void LogSettings();
261
262// Restore the global state of all applicable settings in the Values struct
263void RestoreGlobalState(bool is_powered_on);
264
265} // namespace Settings