libnx
hid.h
Go to the documentation of this file.
1 /**
2  * @file hid.h
3  * @brief Human input device (hid) service IPC wrapper.
4  * @author shinyquagsire23
5  * @author yellows8
6  * @copyright libnx Authors
7  */
8 #pragma once
9 #include <assert.h>
10 #include "../types.h"
11 #include "../services/sm.h"
12 
13 // Begin enums and output structs
14 
15 typedef enum
16 {
17  MOUSE_LEFT = BIT(0),
18  MOUSE_RIGHT = BIT(1),
19  MOUSE_MIDDLE = BIT(2),
20  MOUSE_FORWARD = BIT(3),
21  MOUSE_BACK = BIT(4),
22 } HidMouseButton;
23 
24 typedef enum
25 {
26  KBD_MOD_LCTRL = BIT(0),
27  KBD_MOD_LSHIFT = BIT(1),
28  KBD_MOD_LALT = BIT(2),
29  KBD_MOD_LMETA = BIT(3),
30  KBD_MOD_RCTRL = BIT(4),
31  KBD_MOD_RSHIFT = BIT(5),
32  KBD_MOD_RALT = BIT(6),
33  KBD_MOD_RMETA = BIT(7),
34  KBD_MOD_CAPSLOCK = BIT(8),
35  KBD_MOD_SCROLLLOCK = BIT(9),
36  KBD_MOD_NUMLOCK = BIT(10),
37 } HidKeyboardModifier;
38 
39 typedef enum
40 {
41  KBD_NONE = 0x00,
42  KBD_ERR_OVF = 0x01,
43 
44  KBD_A = 0x04,
45  KBD_B = 0x05,
46  KBD_C = 0x06,
47  KBD_D = 0x07,
48  KBD_E = 0x08,
49  KBD_F = 0x09,
50  KBD_G = 0x0a,
51  KBD_H = 0x0b,
52  KBD_I = 0x0c,
53  KBD_J = 0x0d,
54  KBD_K = 0x0e,
55  KBD_L = 0x0f,
56  KBD_M = 0x10,
57  KBD_N = 0x11,
58  KBD_O = 0x12,
59  KBD_P = 0x13,
60  KBD_Q = 0x14,
61  KBD_R = 0x15,
62  KBD_S = 0x16,
63  KBD_T = 0x17,
64  KBD_U = 0x18,
65  KBD_V = 0x19,
66  KBD_W = 0x1a,
67  KBD_X = 0x1b,
68  KBD_Y = 0x1c,
69  KBD_Z = 0x1d,
70 
71  KBD_1 = 0x1e,
72  KBD_2 = 0x1f,
73  KBD_3 = 0x20,
74  KBD_4 = 0x21,
75  KBD_5 = 0x22,
76  KBD_6 = 0x23,
77  KBD_7 = 0x24,
78  KBD_8 = 0x25,
79  KBD_9 = 0x26,
80  KBD_0 = 0x27,
81 
82  KBD_ENTER = 0x28,
83  KBD_ESC = 0x29,
84  KBD_BACKSPACE = 0x2a,
85  KBD_TAB = 0x2b,
86  KBD_SPACE = 0x2c,
87  KBD_MINUS = 0x2d,
88  KBD_EQUAL = 0x2e,
89  KBD_LEFTBRACE = 0x2f,
90  KBD_RIGHTBRACE = 0x30,
91  KBD_BACKSLASH = 0x31,
92  KBD_HASHTILDE = 0x32,
93  KBD_SEMICOLON = 0x33,
94  KBD_APOSTROPHE = 0x34,
95  KBD_GRAVE = 0x35,
96  KBD_COMMA = 0x36,
97  KBD_DOT = 0x37,
98  KBD_SLASH = 0x38,
99  KBD_CAPSLOCK = 0x39,
100 
101  KBD_F1 = 0x3a,
102  KBD_F2 = 0x3b,
103  KBD_F3 = 0x3c,
104  KBD_F4 = 0x3d,
105  KBD_F5 = 0x3e,
106  KBD_F6 = 0x3f,
107  KBD_F7 = 0x40,
108  KBD_F8 = 0x41,
109  KBD_F9 = 0x42,
110  KBD_F10 = 0x43,
111  KBD_F11 = 0x44,
112  KBD_F12 = 0x45,
113 
114  KBD_SYSRQ = 0x46,
115  KBD_SCROLLLOCK = 0x47,
116  KBD_PAUSE = 0x48,
117  KBD_INSERT = 0x49,
118  KBD_HOME = 0x4a,
119  KBD_PAGEUP = 0x4b,
120  KBD_DELETE = 0x4c,
121  KBD_END = 0x4d,
122  KBD_PAGEDOWN = 0x4e,
123  KBD_RIGHT = 0x4f,
124  KBD_LEFT = 0x50,
125  KBD_DOWN = 0x51,
126  KBD_UP = 0x52,
127 
128  KBD_NUMLOCK = 0x53,
129  KBD_KPSLASH = 0x54,
130  KBD_KPASTERISK = 0x55,
131  KBD_KPMINUS = 0x56,
132  KBD_KPPLUS = 0x57,
133  KBD_KPENTER = 0x58,
134  KBD_KP1 = 0x59,
135  KBD_KP2 = 0x5a,
136  KBD_KP3 = 0x5b,
137  KBD_KP4 = 0x5c,
138  KBD_KP5 = 0x5d,
139  KBD_KP6 = 0x5e,
140  KBD_KP7 = 0x5f,
141  KBD_KP8 = 0x60,
142  KBD_KP9 = 0x61,
143  KBD_KP0 = 0x62,
144  KBD_KPDOT = 0x63,
145 
146  KBD_102ND = 0x64,
147  KBD_COMPOSE = 0x65,
148  KBD_POWER = 0x66,
149  KBD_KPEQUAL = 0x67,
150 
151  KBD_F13 = 0x68,
152  KBD_F14 = 0x69,
153  KBD_F15 = 0x6a,
154  KBD_F16 = 0x6b,
155  KBD_F17 = 0x6c,
156  KBD_F18 = 0x6d,
157  KBD_F19 = 0x6e,
158  KBD_F20 = 0x6f,
159  KBD_F21 = 0x70,
160  KBD_F22 = 0x71,
161  KBD_F23 = 0x72,
162  KBD_F24 = 0x73,
163 
164  KBD_OPEN = 0x74,
165  KBD_HELP = 0x75,
166  KBD_PROPS = 0x76,
167  KBD_FRONT = 0x77,
168  KBD_STOP = 0x78,
169  KBD_AGAIN = 0x79,
170  KBD_UNDO = 0x7a,
171  KBD_CUT = 0x7b,
172  KBD_COPY = 0x7c,
173  KBD_PASTE = 0x7d,
174  KBD_FIND = 0x7e,
175  KBD_MUTE = 0x7f,
176  KBD_VOLUMEUP = 0x80,
177  KBD_VOLUMEDOWN = 0x81,
178  KBD_CAPSLOCK_ACTIVE = 0x82 ,
179  KBD_NUMLOCK_ACTIVE = 0x83 ,
180  KBD_SCROLLLOCK_ACTIVE = 0x84 ,
181  KBD_KPCOMMA = 0x85,
182 
183  KBD_KPLEFTPAREN = 0xb6,
184  KBD_KPRIGHTPAREN = 0xb7,
185 
186  KBD_LEFTCTRL = 0xe0,
187  KBD_LEFTSHIFT = 0xe1,
188  KBD_LEFTALT = 0xe2,
189  KBD_LEFTMETA = 0xe3,
190  KBD_RIGHTCTRL = 0xe4,
191  KBD_RIGHTSHIFT = 0xe5,
192  KBD_RIGHTALT = 0xe6,
193  KBD_RIGHTMETA = 0xe7,
194 
195  KBD_MEDIA_PLAYPAUSE = 0xe8,
196  KBD_MEDIA_STOPCD = 0xe9,
197  KBD_MEDIA_PREVIOUSSONG = 0xea,
198  KBD_MEDIA_NEXTSONG = 0xeb,
199  KBD_MEDIA_EJECTCD = 0xec,
200  KBD_MEDIA_VOLUMEUP = 0xed,
201  KBD_MEDIA_VOLUMEDOWN = 0xee,
202  KBD_MEDIA_MUTE = 0xef,
203  KBD_MEDIA_WWW = 0xf0,
204  KBD_MEDIA_BACK = 0xf1,
205  KBD_MEDIA_FORWARD = 0xf2,
206  KBD_MEDIA_STOP = 0xf3,
207  KBD_MEDIA_FIND = 0xf4,
208  KBD_MEDIA_SCROLLUP = 0xf5,
209  KBD_MEDIA_SCROLLDOWN = 0xf6,
210  KBD_MEDIA_EDIT = 0xf7,
211  KBD_MEDIA_SLEEP = 0xf8,
212  KBD_MEDIA_COFFEE = 0xf9,
213  KBD_MEDIA_REFRESH = 0xfa,
214  KBD_MEDIA_CALC = 0xfb
215 } HidKeyboardScancode;
216 
217 typedef enum
218 {
219  TYPE_PROCONTROLLER = BIT(0),
220  TYPE_HANDHELD = BIT(1),
221  TYPE_JOYCON_PAIR = BIT(2),
222  TYPE_JOYCON_LEFT = BIT(3),
223  TYPE_JOYCON_RIGHT = BIT(4),
224 } HidControllerType;
225 
226 typedef enum
227 {
228  LAYOUT_PROCONTROLLER = 0, // Pro Controller or Hid gamepad
229  LAYOUT_HANDHELD = 1, // Two Joy-Con docked to rails
230  LAYOUT_SINGLE = 2, // Horizontal single Joy-Con or pair of Joy-Con, adjusted for orientation
231  LAYOUT_LEFT = 3, // Only raw left Joy-Con state, no orientation adjustment
232  LAYOUT_RIGHT = 4, // Only raw right Joy-Con state, no orientation adjustment
233  LAYOUT_DEFAULT_DIGITAL = 5, // Same as next, but sticks have 8-direction values only
234  LAYOUT_DEFAULT = 6, // Safe default, single Joy-Con have buttons/sticks rotated for orientation
235 } HidControllerLayoutType;
236 
237 typedef enum
238 {
239  COLORS_NONEXISTENT = BIT(1),
240 } HidControllerColorDescription;
241 
242 typedef enum
243 {
244  KEY_A = BIT(0), ///< A
245  KEY_B = BIT(1), ///< B
246  KEY_X = BIT(2), ///< X
247  KEY_Y = BIT(3), ///< Y
248  KEY_LSTICK = BIT(4), ///< Left Stick Button
249  KEY_RSTICK = BIT(5), ///< Right Stick Button
250  KEY_L = BIT(6), ///< L
251  KEY_R = BIT(7), ///< R
252  KEY_ZL = BIT(8), ///< ZL
253  KEY_ZR = BIT(9), ///< ZR
254  KEY_PLUS = BIT(10), ///< Plus
255  KEY_MINUS = BIT(11), ///< Minus
256  KEY_DLEFT = BIT(12), ///< D-Pad Left
257  KEY_DUP = BIT(13), ///< D-Pad Up
258  KEY_DRIGHT = BIT(14), ///< D-Pad Right
259  KEY_DDOWN = BIT(15), ///< D-Pad Down
260  KEY_LSTICK_LEFT = BIT(16), ///< Left Stick Left
261  KEY_LSTICK_UP = BIT(17), ///< Left Stick Up
262  KEY_LSTICK_RIGHT = BIT(18), ///< Left Stick Right
263  KEY_LSTICK_DOWN = BIT(19), ///< Left Stick Down
264  KEY_RSTICK_LEFT = BIT(20), ///< Right Stick Left
265  KEY_RSTICK_UP = BIT(21), ///< Right Stick Up
266  KEY_RSTICK_RIGHT = BIT(22), ///< Right Stick Right
267  KEY_RSTICK_DOWN = BIT(23), ///< Right Stick Down
268  KEY_SL = BIT(24), ///< SL
269  KEY_SR = BIT(25), ///< SR
270 
271  // Pseudo-key for at least one finger on the touch screen
272  KEY_TOUCH = BIT(26),
273 
274  // Buttons by orientation (for single Joy-Con), also works with Joy-Con pairs, Pro Controller
275  KEY_JOYCON_RIGHT = BIT(0),
276  KEY_JOYCON_DOWN = BIT(1),
277  KEY_JOYCON_UP = BIT(2),
278  KEY_JOYCON_LEFT = BIT(3),
279 
280  // Generic catch-all directions, also works for single Joy-Con
281  KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP, ///< D-Pad Up or Sticks Up
282  KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN, ///< D-Pad Down or Sticks Down
283  KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT, ///< D-Pad Left or Sticks Left
284  KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT, ///< D-Pad Right or Sticks Right
286 
287 typedef enum
288 {
289  JOYSTICK_LEFT = 0,
290  JOYSTICK_RIGHT = 1,
291 
292  JOYSTICK_NUM_STICKS = 2,
293 } HidControllerJoystick;
294 
295 typedef enum
296 {
297  CONTROLLER_STATE_CONNECTED = BIT(0),
298  CONTROLLER_STATE_WIRED = BIT(1),
299 } HidControllerConnectionState;
300 
301 typedef enum
302 {
303  CONTROLLER_PLAYER_1 = 0,
304  CONTROLLER_PLAYER_2 = 1,
305  CONTROLLER_PLAYER_3 = 2,
306  CONTROLLER_PLAYER_4 = 3,
307  CONTROLLER_PLAYER_5 = 4,
308  CONTROLLER_PLAYER_6 = 5,
309  CONTROLLER_PLAYER_7 = 6,
310  CONTROLLER_PLAYER_8 = 7,
311  CONTROLLER_HANDHELD = 8,
312  CONTROLLER_UNKNOWN = 9,
313  CONTROLLER_P1_AUTO = 10, /// Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
314 } HidControllerID;
315 
316 typedef struct touchPosition
317 {
318  u32 px;
319  u32 py;
320  u32 dx;
321  u32 dy;
322  u32 angle;
323 } touchPosition;
324 
325 typedef struct JoystickPosition
326 {
327  s32 dx;
328  s32 dy;
330 
331 typedef struct MousePosition
332 {
333  u32 x;
334  u32 y;
335  u32 velocityX;
336  u32 velocityY;
337  u32 scrollVelocityX;
338  u32 scrollVelocityY;
339 } MousePosition;
340 
341 #define JOYSTICK_MAX (0x8000)
342 #define JOYSTICK_MIN (-0x8000)
343 
344 // End enums and output structs
345 
346 // Begin HidTouchScreen
347 
348 typedef struct HidTouchScreenHeader
349 {
350  u64 timestampTicks;
351  u64 numEntries;
352  u64 latestEntry;
353  u64 maxEntryIndex;
354  u64 timestamp;
356 static_assert(sizeof(HidTouchScreenHeader) == 0x28, "Hid touch screen header structure has incorrect size");
357 
359 {
360  u64 timestamp;
361  u64 numTouches;
363 static_assert(sizeof(HidTouchScreenEntryHeader) == 0x10, "Hid touch screen entry header structure has incorrect size");
364 
366 {
367  u64 timestamp;
368  u32 padding;
369  u32 touchIndex;
370  u32 x;
371  u32 y;
372  u32 diameterX;
373  u32 diameterY;
374  u32 angle;
375  u32 padding_2;
377 static_assert(sizeof(HidTouchScreenEntryTouch) == 0x28, "Hid touch screen touch structure has incorrect size");
378 
379 typedef struct HidTouchScreenEntry
380 {
382  HidTouchScreenEntryTouch touches[16];
383  u64 unk;
385 static_assert(sizeof(HidTouchScreenEntry) == 0x298, "Hid touch screen entry structure has incorrect size");
386 
387 typedef struct HidTouchScreen
388 {
389  HidTouchScreenHeader header;
390  HidTouchScreenEntry entries[17];
391  u8 padding[0x3c0];
393 static_assert(sizeof(HidTouchScreen) == 0x3000, "Hid touch screen structure has incorrect size");
394 
395 // End HidTouchScreen
396 
397 // Begin HidMouse
398 
399 typedef struct HidMouseHeader
400 {
401  u64 timestampTicks;
402  u64 numEntries;
403  u64 latestEntry;
404  u64 maxEntryIndex;
406 static_assert(sizeof(HidMouseHeader) == 0x20, "Hid mouse header structure has incorrect size");
407 
408 typedef struct HidMouseEntry
409 {
410  u64 timestamp;
411  u64 timestamp_2;
412  MousePosition position;
413  u64 buttons;
414 } HidMouseEntry;
415 static_assert(sizeof(HidMouseEntry) == 0x30, "Hid mouse entry structure has incorrect size");
416 
417 typedef struct HidMouse
418 {
419  HidMouseHeader header;
420  HidMouseEntry entries[17];
421  u8 padding[0xB0];
422 } HidMouse;
423 static_assert(sizeof(HidMouse) == 0x400, "Hid mouse structure has incorrect size");
424 
425 // End HidMouse
426 
427 // Begin HidKeyboard
428 
429 typedef struct HidKeyboardHeader
430 {
431  u64 timestampTicks;
432  u64 numEntries;
433  u64 latestEntry;
434  u64 maxEntryIndex;
436 static_assert(sizeof(HidKeyboardHeader) == 0x20, "Hid keyboard header structure has incorrect size");
437 
438 typedef struct HidKeyboardEntry
439 {
440  u64 timestamp;
441  u64 timestamp_2;
442  u64 modifier;
443  u32 keys[8];
445 static_assert(sizeof(HidKeyboardEntry) == 0x38, "Hid keyboard entry structure has incorrect size");
446 
447 typedef struct HidKeyboard
448 {
449  HidKeyboardHeader header;
450  HidKeyboardEntry entries[17];
451  u8 padding[0x28];
452 } HidKeyboard;
453 static_assert(sizeof(HidKeyboard) == 0x400, "Hid keyboard structure has incorrect size");
454 
455 // End HidKeyboard
456 
457 // Begin HidController
458 
459 typedef struct HidControllerMAC
460 {
461  u64 timestamp;
462  u8 mac[0x8];
463  u64 unk;
464  u64 timestamp_2;
466 static_assert(sizeof(HidControllerMAC) == 0x20, "Hid controller MAC structure has incorrect size");
467 
468 typedef struct HidControllerHeader
469 {
470  u32 type;
471  u32 isHalf;
472  u32 singleColorsDescriptor;
473  u32 singleColorBody;
474  u32 singleColorButtons;
475  u32 splitColorsDescriptor;
476  u32 leftColorBody;
477  u32 leftColorButtons;
478  u32 rightColorBody;
479  u32 rightColorbuttons;
481 static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size");
482 
484 {
485  u64 timestampTicks;
486  u64 numEntries;
487  u64 latestEntry;
488  u64 maxEntryIndex;
490 static_assert(sizeof(HidControllerLayoutHeader) == 0x20, "Hid controller layout header structure has incorrect size");
491 
493 {
494  u64 timestamp;
495  u64 timestamp_2;
496  u64 buttons;
497  JoystickPosition joysticks[JOYSTICK_NUM_STICKS];
498  u64 connectionState;
500 static_assert(sizeof(HidControllerInputEntry) == 0x30, "Hid controller input entry structure has incorrect size");
501 
502 typedef struct HidControllerLayout
503 {
505  HidControllerInputEntry entries[17];
507 static_assert(sizeof(HidControllerLayout) == 0x350, "Hid controller layout structure has incorrect size");
508 
509 typedef struct HidController
510 {
511  HidControllerHeader header;
512  HidControllerLayout layouts[7];
513  u8 unk_1[0x2A70];
514  HidControllerMAC macLeft;
515  HidControllerMAC macRight;
516  u8 unk_2[0xDF8];
517 } HidController;
518 static_assert(sizeof(HidController) == 0x5000, "Hid controller structure has incorrect size");
519 
520 // End HidController
521 
522 typedef struct HidSharedMemory
523 {
524  u8 header[0x400];
525  HidTouchScreen touchscreen;
526  HidMouse mouse;
527  HidKeyboard keyboard;
528  u8 unkSection1[0x400];
529  u8 unkSection2[0x400];
530  u8 unkSection3[0x400];
531  u8 unkSection4[0x400];
532  u8 unkSection5[0x200];
533  u8 unkSection6[0x200];
534  u8 unkSection7[0x200];
535  u8 unkSection8[0x800];
536  u8 controllerSerials[0x4000];
537  HidController controllers[10];
538  u8 unkSection9[0x4600];
540 static_assert(sizeof(HidSharedMemory) == 0x40000, "Hid Shared Memory structure has incorrect size");
541 
543 {
544  u32 unk_x0;
545  u32 unk_x4; ///< 0x1 for left-joycon, 0x2 for right-joycon.
547 static_assert(sizeof(HidVibrationDeviceInfo) == 0x8, "Hid VibrationDeviceInfo structure has incorrect size");
548 
549 typedef struct HidVibrationValue
550 {
551  float amp_low; ///< Low Band amplitude. 1.0f: Max amplitude.
552  float freq_low; ///< Low Band frequency in Hz.
553  float amp_high; ///< High Band amplitude. 1.0f: Max amplitude.
554  float freq_high; ///< High Band frequency in Hz.
556 static_assert(sizeof(HidVibrationValue) == 0x10, "Hid VibrationValue structure has incorrect size");
557 
558 Result hidInitialize(void);
559 void hidExit(void);
560 void hidReset(void);
561 
562 Service* hidGetSessionService(void);
563 void* hidGetSharedmemAddr(void);
564 
565 void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType);
566 HidControllerLayoutType hidGetControllerLayout(HidControllerID id);
567 void hidScanInput(void);
568 
569 u64 hidKeysHeld(HidControllerID id);
570 u64 hidKeysDown(HidControllerID id);
571 u64 hidKeysUp(HidControllerID id);
572 
573 u64 hidMouseButtonsHeld(void);
574 u64 hidMouseButtonsDown(void);
575 u64 hidMouseButtonsUp(void);
576 void hidMouseRead(MousePosition *pos);
577 
578 bool hidKeyboardModifierHeld(HidKeyboardModifier modifier);
579 bool hidKeyboardModifierDown(HidKeyboardModifier modifier);
580 bool hidKeyboardModifierUp(HidKeyboardModifier modifier);
581 
582 bool hidKeyboardHeld(HidKeyboardScancode key);
583 bool hidKeyboardDown(HidKeyboardScancode key);
584 bool hidKeyboardUp(HidKeyboardScancode key);
585 
586 u32 hidTouchCount(void);
587 void hidTouchRead(touchPosition *pos, u32 point_id);
588 
589 void hidJoystickRead(JoystickPosition *pos, HidControllerID id, HidControllerJoystick stick);
590 
591 /// This can be used to check what CONTROLLER_P1_AUTO uses.
592 /// Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode.
593 bool hidGetHandheldMode(void);
594 
595 /// Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*.
596 /// When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example).
597 /// id must be CONTROLLER_PLAYER_*.
599 /// Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*. Only necessary if you want to use this mode in your application after \ref hidSetNpadJoyAssignmentModeSingleByDefault was used with this pair of joy-cons.
600 /// Used automatically during app startup/exit for all controllers.
601 /// When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example).
602 /// id must be CONTROLLER_PLAYER_*.
603 Result hidSetNpadJoyAssignmentModeDual(HidControllerID id);
604 
605 Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, size_t total_handles, HidControllerID id, HidControllerType type);
606 
607 /// Gets HidVibrationDeviceInfo for the specified VibrationDeviceHandle.
608 Result hidGetVibrationDeviceInfo(u32 *VibrationDeviceHandle, HidVibrationDeviceInfo *VibrationDeviceInfo);
609 
610 /// Send the VibrationValue to the specified VibrationDeviceHandle.
611 Result hidSendVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue);
612 
613 /// Gets the current HidVibrationValue for the specified VibrationDeviceHandle.
614 Result hidGetActualVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue);
615 
616 /// Sets whether vibration is allowed, this also affects the config displayed by System Settings.
617 Result hidPermitVibration(bool flag);
618 
619 /// Gets whether vibration is allowed.
620 Result hidIsVibrationPermitted(bool *flag);
621 
622 /// Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in the VibrationDeviceHandles/VibrationValues arrays.
623 Result hidSendVibrationValues(u32 *VibrationDeviceHandles, HidVibrationValue *VibrationValues, size_t count);
Left Stick Down.
Definition: hid.h:263
Definition: hid.h:492
Definition: hid.h:483
Definition: hid.h:365
Definition: hid.h:502
D-Pad Down.
Definition: hid.h:259
Result hidGetActualVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue)
Gets the current HidVibrationValue for the specified VibrationDeviceHandle.
float amp_high
High Band amplitude. 1.0f: Max amplitude.
Definition: hid.h:553
Result hidSendVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue)
Send the VibrationValue to the specified VibrationDeviceHandle.
bool hidGetHandheldMode(void)
This can be used to check what CONTROLLER_P1_AUTO uses.
D-Pad Left or Sticks Left.
Definition: hid.h:283
Definition: hid.h:459
X.
Definition: hid.h:246
Result hidSetNpadJoyAssignmentModeSingleByDefault(HidControllerID id)
Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*.
Definition: hid.h:509
Definition: hid.h:438
Result hidPermitVibration(bool flag)
Sets whether vibration is allowed, this also affects the config displayed by System Settings...
Left Stick Right.
Definition: hid.h:262
float freq_high
High Band frequency in Hz.
Definition: hid.h:554
Plus.
Definition: hid.h:254
SL.
Definition: hid.h:268
Definition: hid.h:408
Definition: hid.h:468
Result hidGetVibrationDeviceInfo(u32 *VibrationDeviceHandle, HidVibrationDeviceInfo *VibrationDeviceInfo)
Gets HidVibrationDeviceInfo for the specified VibrationDeviceHandle.
SR.
Definition: hid.h:269
Service object structure.
Definition: sm.h:23
u32 Result
Function error code result type.
Definition: types.h:46
Right Stick Left.
Definition: hid.h:264
float amp_low
Low Band amplitude. 1.0f: Max amplitude.
Definition: hid.h:551
Left Stick Up.
Definition: hid.h:261
Definition: hid.h:387
uint8_t u8
8-bit unsigned integer.
Definition: types.h:21
Right Stick Up.
Definition: hid.h:265
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
B.
Definition: hid.h:245
Definition: hid.h:358
Definition: hid.h:417
D-Pad Up or Sticks Up.
Definition: hid.h:281
Definition: hid.h:542
Definition: hid.h:331
A.
Definition: hid.h:244
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
Right Stick Down.
Definition: hid.h:267
ZR.
Definition: hid.h:253
Definition: hid.h:348
Definition: hid.h:399
Result hidIsVibrationPermitted(bool *flag)
Gets whether vibration is allowed.
int32_t s32
32-bit signed integer.
Definition: types.h:29
Definition: hid.h:447
D-Pad Up.
Definition: hid.h:257
D-Pad Left.
Definition: hid.h:256
HidControllerKeys
Definition: hid.h:242
Definition: hid.h:316
Definition: hid.h:429
ZL.
Definition: hid.h:252
u32 unk_x4
0x1 for left-joycon, 0x2 for right-joycon.
Definition: hid.h:545
Right Stick Right.
Definition: hid.h:266
Result hidSetNpadJoyAssignmentModeDual(HidControllerID id)
Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*.
Minus.
Definition: hid.h:255
D-Pad Right.
Definition: hid.h:258
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:51
Left Stick Left.
Definition: hid.h:260
D-Pad Right or Sticks Right.
Definition: hid.h:284
Y.
Definition: hid.h:247
Definition: hid.h:549
L.
Definition: hid.h:250
float freq_low
Low Band frequency in Hz.
Definition: hid.h:552
Definition: hid.h:325
Result hidSendVibrationValues(u32 *VibrationDeviceHandles, HidVibrationValue *VibrationValues, size_t count)
Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in...
Right Stick Button.
Definition: hid.h:249
Left Stick Button.
Definition: hid.h:248
Definition: hid.h:379
Definition: hid.h:522
D-Pad Down or Sticks Down.
Definition: hid.h:282
R.
Definition: hid.h:251