summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt4
-rw-r--r--src/common/assert.cpp2
-rw-r--r--src/common/logging/backend.cpp2
-rw-r--r--src/common/settings.cpp143
-rw-r--r--src/common/settings.h261
-rw-r--r--src/common/settings_input.cpp47
-rw-r--r--src/common/settings_input.h373
7 files changed, 830 insertions, 2 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 9f8dafa3b..88644eeb6 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -152,6 +152,10 @@ add_library(common STATIC
152 scm_rev.cpp 152 scm_rev.cpp
153 scm_rev.h 153 scm_rev.h
154 scope_exit.h 154 scope_exit.h
155 settings.cpp
156 settings.h
157 settings_input.cpp
158 settings_input.h
155 spin_lock.cpp 159 spin_lock.cpp
156 spin_lock.h 160 spin_lock.h
157 stream.cpp 161 stream.cpp
diff --git a/src/common/assert.cpp b/src/common/assert.cpp
index 4f599af55..72f1121aa 100644
--- a/src/common/assert.cpp
+++ b/src/common/assert.cpp
@@ -5,7 +5,7 @@
5#include "common/assert.h" 5#include "common/assert.h"
6#include "common/common_funcs.h" 6#include "common/common_funcs.h"
7 7
8#include "core/settings.h" 8#include "common/settings.h"
9 9
10void assert_handle_failure() { 10void assert_handle_failure() {
11 if (Settings::values.use_debug_asserts) { 11 if (Settings::values.use_debug_asserts) {
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 4575df24d..90ee4f33f 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -21,9 +21,9 @@
21#include "common/logging/backend.h" 21#include "common/logging/backend.h"
22#include "common/logging/log.h" 22#include "common/logging/log.h"
23#include "common/logging/text_formatter.h" 23#include "common/logging/text_formatter.h"
24#include "common/settings.h"
24#include "common/string_util.h" 25#include "common/string_util.h"
25#include "common/threadsafe_queue.h" 26#include "common/threadsafe_queue.h"
26#include "core/settings.h"
27 27
28namespace Log { 28namespace Log {
29 29
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
new file mode 100644
index 000000000..702b6598d
--- /dev/null
+++ b/src/common/settings.cpp
@@ -0,0 +1,143 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <string_view>
6
7#include "common/assert.h"
8#include "common/file_util.h"
9#include "common/logging/log.h"
10#include "common/settings.h"
11
12namespace Settings {
13
14Values values = {};
15static bool configuring_global = true;
16
17std::string GetTimeZoneString() {
18 static constexpr std::array timezones{
19 "auto", "default", "CET", "CST6CDT", "Cuba", "EET", "Egypt", "Eire",
20 "EST", "EST5EDT", "GB", "GB-Eire", "GMT", "GMT+0", "GMT-0", "GMT0",
21 "Greenwich", "Hongkong", "HST", "Iceland", "Iran", "Israel", "Jamaica", "Japan",
22 "Kwajalein", "Libya", "MET", "MST", "MST7MDT", "Navajo", "NZ", "NZ-CHAT",
23 "Poland", "Portugal", "PRC", "PST8PDT", "ROC", "ROK", "Singapore", "Turkey",
24 "UCT", "Universal", "UTC", "W-SU", "WET", "Zulu",
25 };
26
27 const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue());
28 ASSERT(time_zone_index < timezones.size());
29 return timezones[time_zone_index];
30}
31
32void LogSettings() {
33 const auto log_setting = [](std::string_view name, const auto& value) {
34 LOG_INFO(Config, "{}: {}", name, value);
35 };
36
37 LOG_INFO(Config, "yuzu Configuration:");
38 log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue());
39 log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0));
40 log_setting("System_CurrentUser", values.current_user);
41 log_setting("System_LanguageIndex", values.language_index.GetValue());
42 log_setting("System_RegionIndex", values.region_index.GetValue());
43 log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue());
44 log_setting("Core_UseMultiCore", values.use_multi_core.GetValue());
45 log_setting("CPU_Accuracy", values.cpu_accuracy);
46 log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue());
47 log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue());
48 log_setting("Renderer_FrameLimit", values.frame_limit.GetValue());
49 log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue());
50 log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue());
51 log_setting("Renderer_UseAsynchronousGpuEmulation",
52 values.use_asynchronous_gpu_emulation.GetValue());
53 log_setting("Renderer_UseNvdecEmulation", values.use_nvdec_emulation.GetValue());
54 log_setting("Renderer_UseVsync", values.use_vsync.GetValue());
55 log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue());
56 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
57 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
58 log_setting("Audio_OutputEngine", values.sink_id);
59 log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue());
60 log_setting("Audio_OutputDevice", values.audio_device_id);
61 log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
62 log_setting("DataStorage_CacheDir", Common::FS::GetUserPath(Common::FS::UserPath::CacheDir));
63 log_setting("DataStorage_ConfigDir", Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir));
64 log_setting("DataStorage_LoadDir", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir));
65 log_setting("DataStorage_NandDir", Common::FS::GetUserPath(Common::FS::UserPath::NANDDir));
66 log_setting("DataStorage_SdmcDir", Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir));
67 log_setting("Debugging_ProgramArgs", values.program_args);
68 log_setting("Services_BCATBackend", values.bcat_backend);
69 log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local);
70}
71
72bool IsConfiguringGlobal() {
73 return configuring_global;
74}
75
76void SetConfiguringGlobal(bool is_global) {
77 configuring_global = is_global;
78}
79
80bool IsGPULevelExtreme() {
81 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme;
82}
83
84bool IsGPULevelHigh() {
85 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme ||
86 values.gpu_accuracy.GetValue() == GPUAccuracy::High;
87}
88
89float Volume() {
90 if (values.audio_muted) {
91 return 0.0f;
92 }
93 return values.volume.GetValue();
94}
95
96void RestoreGlobalState(bool is_powered_on) {
97 // If a game is running, DO NOT restore the global settings state
98 if (is_powered_on) {
99 return;
100 }
101
102 // Audio
103 values.enable_audio_stretching.SetGlobal(true);
104 values.volume.SetGlobal(true);
105
106 // Core
107 values.use_multi_core.SetGlobal(true);
108
109 // Renderer
110 values.renderer_backend.SetGlobal(true);
111 values.vulkan_device.SetGlobal(true);
112 values.aspect_ratio.SetGlobal(true);
113 values.max_anisotropy.SetGlobal(true);
114 values.use_frame_limit.SetGlobal(true);
115 values.frame_limit.SetGlobal(true);
116 values.use_disk_shader_cache.SetGlobal(true);
117 values.gpu_accuracy.SetGlobal(true);
118 values.use_asynchronous_gpu_emulation.SetGlobal(true);
119 values.use_nvdec_emulation.SetGlobal(true);
120 values.use_vsync.SetGlobal(true);
121 values.use_assembly_shaders.SetGlobal(true);
122 values.use_asynchronous_shaders.SetGlobal(true);
123 values.use_fast_gpu_time.SetGlobal(true);
124 values.bg_red.SetGlobal(true);
125 values.bg_green.SetGlobal(true);
126 values.bg_blue.SetGlobal(true);
127
128 // System
129 values.language_index.SetGlobal(true);
130 values.region_index.SetGlobal(true);
131 values.time_zone_index.SetGlobal(true);
132 values.rng_seed.SetGlobal(true);
133 values.custom_rtc.SetGlobal(true);
134 values.sound_index.SetGlobal(true);
135
136 // Controls
137 values.players.SetGlobal(true);
138 values.use_docked_mode.SetGlobal(true);
139 values.vibration_enabled.SetGlobal(true);
140 values.motion_enabled.SetGlobal(true);
141}
142
143} // namespace Settings
diff --git a/src/common/settings.h b/src/common/settings.h
new file mode 100644
index 000000000..d39b4aa45
--- /dev/null
+++ b/src/common/settings.h
@@ -0,0 +1,261 @@
1// Copyright 2021 yuzu 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
15#include "common/common_types.h"
16#include "common/settings_input.h"
17
18namespace Settings {
19
20enum class RendererBackend : u32 {
21 OpenGL = 0,
22 Vulkan = 1,
23};
24
25enum class GPUAccuracy : u32 {
26 Normal = 0,
27 High = 1,
28 Extreme = 2,
29};
30
31enum class CPUAccuracy : u32 {
32 Accurate = 0,
33 Unsafe = 1,
34 DebugMode = 2,
35};
36
37template <typename Type>
38class Setting final {
39public:
40 Setting() = default;
41 explicit Setting(Type val) : global{val} {}
42 ~Setting() = default;
43 void SetGlobal(bool to_global) {
44 use_global = to_global;
45 }
46 bool UsingGlobal() const {
47 return use_global;
48 }
49 Type GetValue(bool need_global = false) const {
50 if (use_global || need_global) {
51 return global;
52 }
53 return local;
54 }
55 void SetValue(const Type& value) {
56 if (use_global) {
57 global = value;
58 } else {
59 local = value;
60 }
61 }
62
63private:
64 bool use_global = true;
65 Type global{};
66 Type local{};
67};
68
69/**
70 * The InputSetting class allows for getting a reference to either the global or local members.
71 * This is required as we cannot easily modify the values of user-defined types within containers
72 * using the SetValue() member function found in the Setting class. The primary purpose of this
73 * class is to store an array of 10 PlayerInput structs for both the global and local (per-game)
74 * setting and allows for easily accessing and modifying both settings.
75 */
76template <typename Type>
77class InputSetting final {
78public:
79 InputSetting() = default;
80 explicit InputSetting(Type val) : global{val} {}
81 ~InputSetting() = default;
82 void SetGlobal(bool to_global) {
83 use_global = to_global;
84 }
85 bool UsingGlobal() const {
86 return use_global;
87 }
88 Type& GetValue(bool need_global = false) {
89 if (use_global || need_global) {
90 return global;
91 }
92 return local;
93 }
94
95private:
96 bool use_global = true;
97 Type global{};
98 Type local{};
99};
100
101struct TouchFromButtonMap {
102 std::string name;
103 std::vector<std::string> buttons;
104};
105
106struct Values {
107 // Audio
108 std::string audio_device_id;
109 std::string sink_id;
110 bool audio_muted;
111 Setting<bool> enable_audio_stretching;
112 Setting<float> volume;
113
114 // Core
115 Setting<bool> use_multi_core;
116
117 // Cpu
118 CPUAccuracy cpu_accuracy;
119
120 bool cpuopt_page_tables;
121 bool cpuopt_block_linking;
122 bool cpuopt_return_stack_buffer;
123 bool cpuopt_fast_dispatcher;
124 bool cpuopt_context_elimination;
125 bool cpuopt_const_prop;
126 bool cpuopt_misc_ir;
127 bool cpuopt_reduce_misalign_checks;
128
129 bool cpuopt_unsafe_unfuse_fma;
130 bool cpuopt_unsafe_reduce_fp_error;
131 bool cpuopt_unsafe_inaccurate_nan;
132
133 // Renderer
134 Setting<RendererBackend> renderer_backend;
135 bool renderer_debug;
136 Setting<int> vulkan_device;
137
138 Setting<u16> resolution_factor{1};
139 Setting<int> fullscreen_mode;
140 Setting<int> aspect_ratio;
141 Setting<int> max_anisotropy;
142 Setting<bool> use_frame_limit;
143 Setting<u16> frame_limit;
144 Setting<bool> use_disk_shader_cache;
145 Setting<GPUAccuracy> gpu_accuracy;
146 Setting<bool> use_asynchronous_gpu_emulation;
147 Setting<bool> use_nvdec_emulation;
148 Setting<bool> use_vsync;
149 Setting<bool> use_assembly_shaders;
150 Setting<bool> use_asynchronous_shaders;
151 Setting<bool> use_fast_gpu_time;
152
153 Setting<float> bg_red;
154 Setting<float> bg_green;
155 Setting<float> bg_blue;
156
157 // System
158 Setting<std::optional<u32>> rng_seed;
159 // Measured in seconds since epoch
160 Setting<std::optional<std::chrono::seconds>> custom_rtc;
161 // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
162 std::chrono::seconds custom_rtc_differential;
163
164 s32 current_user;
165 Setting<s32> language_index;
166 Setting<s32> region_index;
167 Setting<s32> time_zone_index;
168 Setting<s32> sound_index;
169
170 // Controls
171 InputSetting<std::array<PlayerInput, 10>> players;
172
173 Setting<bool> use_docked_mode;
174
175 Setting<bool> vibration_enabled;
176 Setting<bool> enable_accurate_vibrations;
177
178 Setting<bool> motion_enabled;
179 std::string motion_device;
180 std::string udp_input_servers;
181
182 bool mouse_panning;
183 float mouse_panning_sensitivity;
184 bool mouse_enabled;
185 std::string mouse_device;
186 MouseButtonsRaw mouse_buttons;
187
188 bool emulate_analog_keyboard;
189 bool keyboard_enabled;
190 KeyboardKeysRaw keyboard_keys;
191 KeyboardModsRaw keyboard_mods;
192
193 bool debug_pad_enabled;
194 ButtonsRaw debug_pad_buttons;
195 AnalogsRaw debug_pad_analogs;
196
197 TouchscreenInput touchscreen;
198
199 bool use_touch_from_button;
200 std::string touch_device;
201 int touch_from_button_map_index;
202 std::vector<TouchFromButtonMap> touch_from_button_maps;
203
204 std::atomic_bool is_device_reload_pending{true};
205
206 // Data Storage
207 bool use_virtual_sd;
208 bool gamecard_inserted;
209 bool gamecard_current_game;
210 std::string gamecard_path;
211
212 // Debugging
213 bool record_frame_times;
214 bool use_gdbstub;
215 u16 gdbstub_port;
216 std::string program_args;
217 bool dump_exefs;
218 bool dump_nso;
219 bool reporting_services;
220 bool quest_flag;
221 bool disable_macro_jit;
222 bool extended_logging;
223 bool use_debug_asserts;
224 bool use_auto_stub;
225
226 // Miscellaneous
227 std::string log_filter;
228 bool use_dev_keys;
229
230 // Services
231 std::string bcat_backend;
232 bool bcat_boxcat_local;
233
234 // WebService
235 bool enable_telemetry;
236 std::string web_api_url;
237 std::string yuzu_username;
238 std::string yuzu_token;
239
240 // Add-Ons
241 std::map<u64, std::vector<std::string>> disabled_addons;
242};
243
244extern Values values;
245
246bool IsConfiguringGlobal();
247void SetConfiguringGlobal(bool is_global);
248
249bool IsGPULevelExtreme();
250bool IsGPULevelHigh();
251
252float Volume();
253
254std::string GetTimeZoneString();
255
256void LogSettings();
257
258// Restore the global state of all applicable settings in the Values struct
259void RestoreGlobalState(bool is_powered_on);
260
261} // namespace Settings
diff --git a/src/common/settings_input.cpp b/src/common/settings_input.cpp
new file mode 100644
index 000000000..bea2b837b
--- /dev/null
+++ b/src/common/settings_input.cpp
@@ -0,0 +1,47 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/settings_input.h"
6
7namespace Settings {
8namespace NativeButton {
9const std::array<const char*, NumButtons> mapping = {{
10 "button_a", "button_b", "button_x", "button_y", "button_lstick",
11 "button_rstick", "button_l", "button_r", "button_zl", "button_zr",
12 "button_plus", "button_minus", "button_dleft", "button_dup", "button_dright",
13 "button_ddown", "button_sl", "button_sr", "button_home", "button_screenshot",
14}};
15}
16
17namespace NativeAnalog {
18const std::array<const char*, NumAnalogs> mapping = {{
19 "lstick",
20 "rstick",
21}};
22}
23
24namespace NativeVibration {
25const std::array<const char*, NumVibrations> mapping = {{
26 "left_vibration_device",
27 "right_vibration_device",
28}};
29}
30
31namespace NativeMotion {
32const std::array<const char*, NumMotions> mapping = {{
33 "motionleft",
34 "motionright",
35}};
36}
37
38namespace NativeMouseButton {
39const std::array<const char*, NumMouseButtons> mapping = {{
40 "left",
41 "right",
42 "middle",
43 "forward",
44 "back",
45}};
46}
47} // namespace Settings
diff --git a/src/common/settings_input.h b/src/common/settings_input.h
new file mode 100644
index 000000000..609600582
--- /dev/null
+++ b/src/common/settings_input.h
@@ -0,0 +1,373 @@
1// Copyright 2020 yuzu 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 <string>
9
10#include "common/common_types.h"
11
12namespace Settings {
13namespace NativeButton {
14enum Values : int {
15 A,
16 B,
17 X,
18 Y,
19 LStick,
20 RStick,
21 L,
22 R,
23 ZL,
24 ZR,
25 Plus,
26 Minus,
27
28 DLeft,
29 DUp,
30 DRight,
31 DDown,
32
33 SL,
34 SR,
35
36 Home,
37 Screenshot,
38
39 NumButtons,
40};
41
42constexpr int BUTTON_HID_BEGIN = A;
43constexpr int BUTTON_NS_BEGIN = Home;
44
45constexpr int BUTTON_HID_END = BUTTON_NS_BEGIN;
46constexpr int BUTTON_NS_END = NumButtons;
47
48constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN;
49constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN;
50
51extern const std::array<const char*, NumButtons> mapping;
52
53} // namespace NativeButton
54
55namespace NativeAnalog {
56enum Values : int {
57 LStick,
58 RStick,
59
60 NumAnalogs,
61};
62
63constexpr int STICK_HID_BEGIN = LStick;
64constexpr int STICK_HID_END = NumAnalogs;
65constexpr int NUM_STICKS_HID = NumAnalogs;
66
67extern const std::array<const char*, NumAnalogs> mapping;
68} // namespace NativeAnalog
69
70namespace NativeVibration {
71enum Values : int {
72 LeftVibrationDevice,
73 RightVibrationDevice,
74
75 NumVibrations,
76};
77
78constexpr int VIBRATION_HID_BEGIN = LeftVibrationDevice;
79constexpr int VIBRATION_HID_END = NumVibrations;
80constexpr int NUM_VIBRATIONS_HID = NumVibrations;
81
82extern const std::array<const char*, NumVibrations> mapping;
83}; // namespace NativeVibration
84
85namespace NativeMotion {
86enum Values : int {
87 MotionLeft,
88 MotionRight,
89
90 NumMotions,
91};
92
93constexpr int MOTION_HID_BEGIN = MotionLeft;
94constexpr int MOTION_HID_END = NumMotions;
95constexpr int NUM_MOTIONS_HID = NumMotions;
96
97extern const std::array<const char*, NumMotions> mapping;
98} // namespace NativeMotion
99
100namespace NativeMouseButton {
101enum Values {
102 Left,
103 Right,
104 Middle,
105 Forward,
106 Back,
107
108 NumMouseButtons,
109};
110
111constexpr int MOUSE_HID_BEGIN = Left;
112constexpr int MOUSE_HID_END = NumMouseButtons;
113constexpr int NUM_MOUSE_HID = NumMouseButtons;
114
115extern const std::array<const char*, NumMouseButtons> mapping;
116} // namespace NativeMouseButton
117
118namespace NativeKeyboard {
119enum Keys {
120 None,
121 Error,
122
123 A = 4,
124 B,
125 C,
126 D,
127 E,
128 F,
129 G,
130 H,
131 I,
132 J,
133 K,
134 L,
135 M,
136 N,
137 O,
138 P,
139 Q,
140 R,
141 S,
142 T,
143 U,
144 V,
145 W,
146 X,
147 Y,
148 Z,
149 N1,
150 N2,
151 N3,
152 N4,
153 N5,
154 N6,
155 N7,
156 N8,
157 N9,
158 N0,
159 Enter,
160 Escape,
161 Backspace,
162 Tab,
163 Space,
164 Minus,
165 Equal,
166 LeftBrace,
167 RightBrace,
168 Backslash,
169 Tilde,
170 Semicolon,
171 Apostrophe,
172 Grave,
173 Comma,
174 Dot,
175 Slash,
176 CapsLockKey,
177
178 F1,
179 F2,
180 F3,
181 F4,
182 F5,
183 F6,
184 F7,
185 F8,
186 F9,
187 F10,
188 F11,
189 F12,
190
191 SystemRequest,
192 ScrollLockKey,
193 Pause,
194 Insert,
195 Home,
196 PageUp,
197 Delete,
198 End,
199 PageDown,
200 Right,
201 Left,
202 Down,
203 Up,
204
205 NumLockKey,
206 KPSlash,
207 KPAsterisk,
208 KPMinus,
209 KPPlus,
210 KPEnter,
211 KP1,
212 KP2,
213 KP3,
214 KP4,
215 KP5,
216 KP6,
217 KP7,
218 KP8,
219 KP9,
220 KP0,
221 KPDot,
222
223 Key102,
224 Compose,
225 Power,
226 KPEqual,
227
228 F13,
229 F14,
230 F15,
231 F16,
232 F17,
233 F18,
234 F19,
235 F20,
236 F21,
237 F22,
238 F23,
239 F24,
240
241 Open,
242 Help,
243 Properties,
244 Front,
245 Stop,
246 Repeat,
247 Undo,
248 Cut,
249 Copy,
250 Paste,
251 Find,
252 Mute,
253 VolumeUp,
254 VolumeDown,
255 CapsLockActive,
256 NumLockActive,
257 ScrollLockActive,
258 KPComma,
259
260 KPLeftParenthesis,
261 KPRightParenthesis,
262
263 LeftControlKey = 0xE0,
264 LeftShiftKey,
265 LeftAltKey,
266 LeftMetaKey,
267 RightControlKey,
268 RightShiftKey,
269 RightAltKey,
270 RightMetaKey,
271
272 MediaPlayPause,
273 MediaStopCD,
274 MediaPrevious,
275 MediaNext,
276 MediaEject,
277 MediaVolumeUp,
278 MediaVolumeDown,
279 MediaMute,
280 MediaWebsite,
281 MediaBack,
282 MediaForward,
283 MediaStop,
284 MediaFind,
285 MediaScrollUp,
286 MediaScrollDown,
287 MediaEdit,
288 MediaSleep,
289 MediaCoffee,
290 MediaRefresh,
291 MediaCalculator,
292
293 NumKeyboardKeys,
294};
295
296static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
297
298enum Modifiers {
299 LeftControl,
300 LeftShift,
301 LeftAlt,
302 LeftMeta,
303 RightControl,
304 RightShift,
305 RightAlt,
306 RightMeta,
307 CapsLock,
308 ScrollLock,
309 NumLock,
310
311 NumKeyboardMods,
312};
313
314constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
315constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
316constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
317
318constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
319constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
320constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
321
322} // namespace NativeKeyboard
323
324using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
325using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
326using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
327using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>;
328
329using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>;
330using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>;
331using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>;
332
333constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
334constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
335constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
336constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
337
338enum class ControllerType {
339 ProController,
340 DualJoyconDetached,
341 LeftJoycon,
342 RightJoycon,
343 Handheld,
344 GameCube,
345};
346
347struct PlayerInput {
348 bool connected;
349 ControllerType controller_type;
350 ButtonsRaw buttons;
351 AnalogsRaw analogs;
352 VibrationsRaw vibrations;
353 MotionsRaw motions;
354
355 bool vibration_enabled;
356 int vibration_strength;
357
358 u32 body_color_left;
359 u32 body_color_right;
360 u32 button_color_left;
361 u32 button_color_right;
362};
363
364struct TouchscreenInput {
365 bool enabled;
366 std::string device;
367
368 u32 finger;
369 u32 diameter_x;
370 u32 diameter_y;
371 u32 rotation_angle;
372};
373} // namespace Settings