summaryrefslogtreecommitdiff
path: root/src/common/settings_input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/settings_input.h')
-rw-r--r--src/common/settings_input.h373
1 files changed, 373 insertions, 0 deletions
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