summaryrefslogtreecommitdiff
path: root/src/input_common/settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/settings.h')
-rw-r--r--src/input_common/settings.h352
1 files changed, 352 insertions, 0 deletions
diff --git a/src/input_common/settings.h b/src/input_common/settings.h
new file mode 100644
index 000000000..ab0b95cf1
--- /dev/null
+++ b/src/input_common/settings.h
@@ -0,0 +1,352 @@
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#include "common/common_types.h"
10
11namespace Settings {
12namespace NativeButton {
13enum Values : int {
14 A,
15 B,
16 X,
17 Y,
18 LStick,
19 RStick,
20 L,
21 R,
22 ZL,
23 ZR,
24 Plus,
25 Minus,
26
27 DLeft,
28 DUp,
29 DRight,
30 DDown,
31
32 SL,
33 SR,
34
35 Home,
36 Screenshot,
37
38 NumButtons,
39};
40
41constexpr int BUTTON_HID_BEGIN = A;
42constexpr int BUTTON_NS_BEGIN = Home;
43
44constexpr int BUTTON_HID_END = BUTTON_NS_BEGIN;
45constexpr int BUTTON_NS_END = NumButtons;
46
47constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN;
48constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN;
49
50extern const std::array<const char*, NumButtons> mapping;
51
52} // namespace NativeButton
53
54namespace NativeAnalog {
55enum Values : int {
56 LStick,
57 RStick,
58
59 NumAnalogs,
60};
61
62constexpr int STICK_HID_BEGIN = LStick;
63constexpr int STICK_HID_END = NumAnalogs;
64constexpr int NUM_STICKS_HID = NumAnalogs;
65
66extern const std::array<const char*, NumAnalogs> mapping;
67} // namespace NativeAnalog
68
69namespace NativeMotion {
70enum Values : int {
71 MOTIONLEFT,
72 MOTIONRIGHT,
73
74 NumMotions,
75};
76
77constexpr int MOTION_HID_BEGIN = MOTIONLEFT;
78constexpr int MOTION_HID_END = NumMotions;
79constexpr int NUM_MOTION_HID = NumMotions;
80
81extern const std::array<const char*, NumMotions> mapping;
82} // namespace NativeMotion
83
84namespace NativeMouseButton {
85enum Values {
86 Left,
87 Right,
88 Middle,
89 Forward,
90 Back,
91
92 NumMouseButtons,
93};
94
95constexpr int MOUSE_HID_BEGIN = Left;
96constexpr int MOUSE_HID_END = NumMouseButtons;
97constexpr int NUM_MOUSE_HID = NumMouseButtons;
98
99extern const std::array<const char*, NumMouseButtons> mapping;
100} // namespace NativeMouseButton
101
102namespace NativeKeyboard {
103enum Keys {
104 None,
105 Error,
106
107 A = 4,
108 B,
109 C,
110 D,
111 E,
112 F,
113 G,
114 H,
115 I,
116 J,
117 K,
118 L,
119 M,
120 N,
121 O,
122 P,
123 Q,
124 R,
125 S,
126 T,
127 U,
128 V,
129 W,
130 X,
131 Y,
132 Z,
133 N1,
134 N2,
135 N3,
136 N4,
137 N5,
138 N6,
139 N7,
140 N8,
141 N9,
142 N0,
143 Enter,
144 Escape,
145 Backspace,
146 Tab,
147 Space,
148 Minus,
149 Equal,
150 LeftBrace,
151 RightBrace,
152 Backslash,
153 Tilde,
154 Semicolon,
155 Apostrophe,
156 Grave,
157 Comma,
158 Dot,
159 Slash,
160 CapsLockKey,
161
162 F1,
163 F2,
164 F3,
165 F4,
166 F5,
167 F6,
168 F7,
169 F8,
170 F9,
171 F10,
172 F11,
173 F12,
174
175 SystemRequest,
176 ScrollLockKey,
177 Pause,
178 Insert,
179 Home,
180 PageUp,
181 Delete,
182 End,
183 PageDown,
184 Right,
185 Left,
186 Down,
187 Up,
188
189 NumLockKey,
190 KPSlash,
191 KPAsterisk,
192 KPMinus,
193 KPPlus,
194 KPEnter,
195 KP1,
196 KP2,
197 KP3,
198 KP4,
199 KP5,
200 KP6,
201 KP7,
202 KP8,
203 KP9,
204 KP0,
205 KPDot,
206
207 Key102,
208 Compose,
209 Power,
210 KPEqual,
211
212 F13,
213 F14,
214 F15,
215 F16,
216 F17,
217 F18,
218 F19,
219 F20,
220 F21,
221 F22,
222 F23,
223 F24,
224
225 Open,
226 Help,
227 Properties,
228 Front,
229 Stop,
230 Repeat,
231 Undo,
232 Cut,
233 Copy,
234 Paste,
235 Find,
236 Mute,
237 VolumeUp,
238 VolumeDown,
239 CapsLockActive,
240 NumLockActive,
241 ScrollLockActive,
242 KPComma,
243
244 KPLeftParenthesis,
245 KPRightParenthesis,
246
247 LeftControlKey = 0xE0,
248 LeftShiftKey,
249 LeftAltKey,
250 LeftMetaKey,
251 RightControlKey,
252 RightShiftKey,
253 RightAltKey,
254 RightMetaKey,
255
256 MediaPlayPause,
257 MediaStopCD,
258 MediaPrevious,
259 MediaNext,
260 MediaEject,
261 MediaVolumeUp,
262 MediaVolumeDown,
263 MediaMute,
264 MediaWebsite,
265 MediaBack,
266 MediaForward,
267 MediaStop,
268 MediaFind,
269 MediaScrollUp,
270 MediaScrollDown,
271 MediaEdit,
272 MediaSleep,
273 MediaCoffee,
274 MediaRefresh,
275 MediaCalculator,
276
277 NumKeyboardKeys,
278};
279
280static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
281
282enum Modifiers {
283 LeftControl,
284 LeftShift,
285 LeftAlt,
286 LeftMeta,
287 RightControl,
288 RightShift,
289 RightAlt,
290 RightMeta,
291 CapsLock,
292 ScrollLock,
293 NumLock,
294
295 NumKeyboardMods,
296};
297
298constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
299constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
300constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
301
302constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
303constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
304constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
305
306} // namespace NativeKeyboard
307
308using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
309using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
310using MotionRaw = std::array<std::string, NativeMotion::NumMotions>;
311using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>;
312using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>;
313using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>;
314
315constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
316constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
317constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
318constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
319
320enum class ControllerType {
321 ProController,
322 DualJoyconDetached,
323 LeftJoycon,
324 RightJoycon,
325 Handheld,
326};
327
328struct PlayerInput {
329 bool connected;
330 ControllerType controller_type;
331 ButtonsRaw buttons;
332 AnalogsRaw analogs;
333 MotionRaw motions;
334 std::string lstick_mod;
335 std::string rstick_mod;
336
337 u32 body_color_left;
338 u32 body_color_right;
339 u32 button_color_left;
340 u32 button_color_right;
341};
342
343struct TouchscreenInput {
344 bool enabled;
345 std::string device;
346
347 u32 finger;
348 u32 diameter_x;
349 u32 diameter_y;
350 u32 rotation_angle;
351};
352} // namespace Settings