11 #include "../services/sm.h" 19 MOUSE_MIDDLE =
BIT(2),
20 MOUSE_FORWARD =
BIT(3),
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;
90 KBD_RIGHTBRACE = 0x30,
94 KBD_APOSTROPHE = 0x34,
115 KBD_SCROLLLOCK = 0x47,
130 KBD_KPASTERISK = 0x55,
177 KBD_VOLUMEDOWN = 0x81,
178 KBD_CAPSLOCK_ACTIVE = 0x82 ,
179 KBD_NUMLOCK_ACTIVE = 0x83 ,
180 KBD_SCROLLLOCK_ACTIVE = 0x84 ,
183 KBD_KPLEFTPAREN = 0xb6,
184 KBD_KPRIGHTPAREN = 0xb7,
187 KBD_LEFTSHIFT = 0xe1,
190 KBD_RIGHTCTRL = 0xe4,
191 KBD_RIGHTSHIFT = 0xe5,
193 KBD_RIGHTMETA = 0xe7,
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;
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),
228 LAYOUT_PROCONTROLLER = 0,
233 LAYOUT_DEFAULT_DIGITAL = 5,
235 } HidControllerLayoutType;
239 COLORS_NONEXISTENT =
BIT(1),
240 } HidControllerColorDescription;
275 KEY_JOYCON_RIGHT =
BIT(0),
276 KEY_JOYCON_DOWN =
BIT(1),
277 KEY_JOYCON_UP =
BIT(2),
278 KEY_JOYCON_LEFT =
BIT(3),
292 JOYSTICK_NUM_STICKS = 2,
293 } HidControllerJoystick;
297 CONTROLLER_STATE_CONNECTED =
BIT(0),
298 CONTROLLER_STATE_WIRED =
BIT(1),
299 } HidControllerConnectionState;
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,
341 #define JOYSTICK_MAX (0x8000) 342 #define JOYSTICK_MIN (-0x8000) 356 static_assert(
sizeof(
HidTouchScreenHeader) == 0x28,
"Hid touch screen header structure has incorrect size");
385 static_assert(
sizeof(
HidTouchScreenEntry) == 0x298,
"Hid touch screen entry structure has incorrect size");
393 static_assert(
sizeof(
HidTouchScreen) == 0x3000,
"Hid touch screen structure has incorrect size");
406 static_assert(
sizeof(
HidMouseHeader) == 0x20,
"Hid mouse header structure has incorrect size");
415 static_assert(
sizeof(
HidMouseEntry) == 0x30,
"Hid mouse entry structure has incorrect size");
423 static_assert(
sizeof(
HidMouse) == 0x400,
"Hid mouse structure has incorrect size");
436 static_assert(
sizeof(
HidKeyboardHeader) == 0x20,
"Hid keyboard header structure has incorrect size");
445 static_assert(
sizeof(
HidKeyboardEntry) == 0x38,
"Hid keyboard entry structure has incorrect size");
453 static_assert(
sizeof(
HidKeyboard) == 0x400,
"Hid keyboard structure has incorrect size");
466 static_assert(
sizeof(
HidControllerMAC) == 0x20,
"Hid controller MAC structure has incorrect size");
472 u32 singleColorsDescriptor;
474 u32 singleColorButtons;
475 u32 splitColorsDescriptor;
477 u32 leftColorButtons;
479 u32 rightColorbuttons;
481 static_assert(
sizeof(
HidControllerHeader) == 0x28,
"Hid controller header structure has incorrect size");
500 static_assert(
sizeof(
HidControllerInputEntry) == 0x30,
"Hid controller input entry structure has incorrect size");
507 static_assert(
sizeof(
HidControllerLayout) == 0x350,
"Hid controller layout structure has incorrect size");
518 static_assert(
sizeof(
HidController) == 0x5000,
"Hid controller structure has incorrect size");
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];
538 u8 unkSection9[0x4600];
540 static_assert(
sizeof(
HidSharedMemory) == 0x40000,
"Hid Shared Memory structure has incorrect size");
547 static_assert(
sizeof(
HidVibrationDeviceInfo) == 0x8,
"Hid VibrationDeviceInfo structure has incorrect size");
556 static_assert(
sizeof(
HidVibrationValue) == 0x10,
"Hid VibrationValue structure has incorrect size");
558 Result hidInitialize(
void);
562 Service* hidGetSessionService(
void);
563 void* hidGetSharedmemAddr(
void);
565 void hidSetControllerLayout(HidControllerID
id, HidControllerLayoutType layoutType);
566 HidControllerLayoutType hidGetControllerLayout(HidControllerID
id);
567 void hidScanInput(
void);
569 u64 hidKeysHeld(HidControllerID
id);
570 u64 hidKeysDown(HidControllerID
id);
571 u64 hidKeysUp(HidControllerID
id);
573 u64 hidMouseButtonsHeld(
void);
574 u64 hidMouseButtonsDown(
void);
575 u64 hidMouseButtonsUp(
void);
578 bool hidKeyboardModifierHeld(HidKeyboardModifier modifier);
579 bool hidKeyboardModifierDown(HidKeyboardModifier modifier);
580 bool hidKeyboardModifierUp(HidKeyboardModifier modifier);
582 bool hidKeyboardHeld(HidKeyboardScancode key);
583 bool hidKeyboardDown(HidKeyboardScancode key);
584 bool hidKeyboardUp(HidKeyboardScancode key);
586 u32 hidTouchCount(
void);
589 void hidJoystickRead(
JoystickPosition *pos, HidControllerID
id, HidControllerJoystick stick);
605 Result hidInitializeVibrationDevices(
u32 *VibrationDeviceHandles,
size_t total_handles, HidControllerID
id, HidControllerType type);
Left Stick Down.
Definition: hid.h:263
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
Result hidSetNpadJoyAssignmentModeSingleByDefault(HidControllerID id)
Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*.
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
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
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
D-Pad Up or Sticks Up.
Definition: hid.h:281
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
Right Stick Down.
Definition: hid.h:267
ZR.
Definition: hid.h:253
Result hidIsVibrationPermitted(bool *flag)
Gets whether vibration is allowed.
int32_t s32
32-bit signed integer.
Definition: types.h:29
D-Pad Up.
Definition: hid.h:257
D-Pad Left.
Definition: hid.h:256
HidControllerKeys
Definition: hid.h:242
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
float freq_low
Low Band frequency in Hz.
Definition: hid.h:552
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
D-Pad Down or Sticks Down.
Definition: hid.h:282