libnx  v4.8.0
hiddbg.h
Go to the documentation of this file.
1 /**
2  * @file hiddbg.h
3  * @brief hid:dbg service IPC wrapper.
4  * @author yellows8
5  */
6 #pragma once
7 #include "../types.h"
8 #include "../services/hid.h"
9 #include "../services/hidsys.h"
10 #include "../sf/service.h"
11 
12 /// HiddbgNpadButton. For the remaining buttons, see \ref HidNpadButton.
13 typedef enum {
14  HiddbgNpadButton_Home = BIT(18), ///< HOME button
15  HiddbgNpadButton_Capture = BIT(19), ///< Capture button
17 
18 /// HdlsAttribute
19 typedef enum {
20  HiddbgHdlsAttribute_HasVirtualSixAxisSensorAcceleration = BIT(0), ///< HasVirtualSixAxisSensorAcceleration
21  HiddbgHdlsAttribute_HasVirtualSixAxisSensorAngle = BIT(1), ///< HasVirtualSixAxisSensorAngle
23 
24 /// State for overriding \ref HidDebugPadState.
25 typedef struct {
26  u32 attributes; ///< Bitfield of \ref HidDebugPadAttribute.
27  u32 buttons; ///< Bitfield of \ref HidDebugPadButton.
31 
32 /// State for overriding \ref HidMouseState.
33 typedef struct {
34  s32 x; ///< X
35  s32 y; ///< Y
36  s32 delta_x; ///< DeltaX
37  s32 delta_y; ///< DeltaY
38  s32 wheel_delta; ///< WheelDelta
39  u32 buttons; ///< Bitfield of \ref HidMouseButton.
40  u32 attributes; ///< Bitfield of \ref HidMouseAttribute.
42 
43 /// State for overriding \ref HidKeyboardState.
44 typedef struct {
45  u64 modifiers; ///< Bitfield of \ref HidKeyboardModifier.
46  u64 keys[4];
48 
49 /// State for overriding SleepButtonState.
50 typedef struct {
51  u64 buttons; ///< Bitfield of buttons, only bit0 is used.
53 
54 /// HdlsHandle
55 typedef struct {
56  u64 handle; ///< Handle
58 
59 /// HdlsSessionId, returned by \ref hiddbgAttachHdlsWorkBuffer.
60 typedef struct {
61  u64 id; ///< Id
63 
64 /// HdlsDeviceInfo, for [7.0.0-8.1.0].
65 typedef struct {
66  u32 deviceTypeInternal; ///< Only one bit can be set. BIT(N*4+0) = Pro-Controller, BIT(N*4+1) = Joy-Con Left, BIT(N*4+2) = Joy-Con Right, BIT(N*4+3) = invalid. Where N is 0-1. BIT(8-10) = Pro-Controller, BIT(11) = Famicom-Controller, BIT(12) = Famicom-Controller II with microphone, BIT(13) = NES-Controller(DeviceType=0x200), BIT(14) = NES-Controller(DeviceType=0x400), BIT(15-16) = invalid, BIT(17) = unknown(DeviceType=0x8000), BIT(18-20) = invalid, BIT(21-23) = unknown(DeviceType=0x80000000).
67  u32 singleColorBody; ///< RGBA Single Body Color.
68  u32 singleColorButtons; ///< RGBA Single Buttons Color.
69  u8 npadInterfaceType; ///< \ref HidNpadInterfaceType. Additional type field used with the above type field (only applies to type bit0-bit2 and bit21), if the value doesn't match one of the following a default is used. Type Pro-Controller: value 0x3 indicates that the controller is connected via USB. Type BIT(21): value 0x3 = unknown. When value is 0x2, state is merged with an existing controller (when the type value is compatible with this). Otherwise, it's a dedicated controller.
70  u8 pad[0x3]; ///< Padding.
72 
73 /// HdlsDeviceInfo, for [9.0.0+]. Converted to/from \ref HiddbgHdlsDeviceInfoV7 on prior sysvers.
74 typedef struct {
75  u8 deviceType; ///< \ref HidDeviceType
76  u8 npadInterfaceType; ///< \ref HidNpadInterfaceType. Additional type field used with the above type field (only applies to ::HidDeviceType_JoyRight1, ::HidDeviceType_JoyLeft2, ::HidDeviceType_FullKey3, and ::HidDeviceType_System19), if the value doesn't match one of the following a default is used. ::HidDeviceType_FullKey3: ::HidNpadInterfaceType_USB indicates that the controller is connected via USB. :::HidDeviceType_System19: ::HidNpadInterfaceType_USB = unknown. When value is ::HidNpadInterfaceType_Rail, state is merged with an existing controller (with ::HidDeviceType_JoyRight1 / ::HidDeviceType_JoyLeft2). Otherwise, it's a dedicated controller.
77  u8 pad[0x2]; ///< Padding.
78  u32 singleColorBody; ///< RGBA Single Body Color.
79  u32 singleColorButtons; ///< RGBA Single Buttons Color.
80  u32 colorLeftGrip; ///< [9.0.0+] RGBA Left Grip Color.
81  u32 colorRightGrip; ///< [9.0.0+] RGBA Right Grip Color.
83 
84 /// HdlsState, for [7.0.0-8.1.0].
85 typedef struct {
86  u8 is_powered; ///< IsPowered for the main PowerInfo, see \ref HidNpadSystemProperties.
87  u8 flags; ///< ORRed with IsPowered to set the value of the first byte for \ref HidNpadSystemProperties. For example, value 1 here will set IsCharging for the main PowerInfo.
88  u8 unk_x2[0x6]; ///< Unknown
89  u32 battery_level; ///< BatteryLevel for the main PowerInfo, see \ref HidPowerInfo.
90  u32 buttons; ///< See \ref HiddbgNpadButton.
93  u8 indicator; ///< Indicator. Unused for input. Set with output from \ref hiddbgDumpHdlsStates. Not set by \ref hiddbgGetAbstractedPadsState.
94  u8 padding[0x3]; ///< Padding
96 
97 /// HdlsState, for [9.0.0-11.0.1].
98 typedef struct {
99  u32 battery_level; ///< BatteryLevel for the main PowerInfo, see \ref HidPowerInfo.
100  u32 flags; ///< Used to set the main PowerInfo for \ref HidNpadSystemProperties. BIT(0) -> IsPowered, BIT(1) -> IsCharging.
101  u64 buttons; ///< See \ref HiddbgNpadButton. [9.0.0+] Masked with 0xfffffffff00fffff.
104  u8 indicator; ///< Indicator. Unused for input. Set with output from \ref hiddbgDumpHdlsStates.
105  u8 padding[0x3]; ///< Padding
107 
108 /// HdlsState, for [12.0.0+].
109 typedef struct {
110  u32 battery_level; ///< BatteryLevel for the main PowerInfo, see \ref HidPowerInfo.
111  u32 flags; ///< Used to set the main PowerInfo for \ref HidNpadSystemProperties. BIT(0) -> IsPowered, BIT(1) -> IsCharging.
112  u64 buttons; ///< See \ref HiddbgNpadButton. [9.0.0+] Masked with 0xfffffffff00fffff.
115  HidVector six_axis_sensor_acceleration; ///< VirtualSixAxisSensorAcceleration
116  HidVector six_axis_sensor_angle; ///< VirtualSixAxisSensorAngle
117  u32 attribute; ///< Bitfield of \ref HiddbgHdlsAttribute.
118  u8 indicator; ///< Indicator. Unused for input.
119  u8 padding[0x3]; ///< Padding
121 
122 /// HdlsNpadAssignmentEntry
123 typedef struct {
124  HiddbgHdlsHandle handle; ///< \ref HiddbgHdlsHandle
125  u32 unk_x8; ///< Unknown
126  u32 unk_xc; ///< Unknown
127  u64 unk_x10; ///< Unknown
128  u8 unk_x18; ///< Unknown
129  u8 pad[0x7]; ///< Padding
131 
132 /// HdlsNpadAssignment. Same controllers as \ref HiddbgHdlsStateList, with different entry data.
133 typedef struct {
134  s32 total_entries; ///< Total entries for the below entries.
135  u32 pad; ///< Padding
136  HiddbgHdlsNpadAssignmentEntry entries[0x10]; ///< \ref HiddbgHdlsNpadAssignmentEntry
138 
139 /// HdlsStateListEntryV7, for [7.0.0-8.1.0].
140 typedef struct {
141  HiddbgHdlsHandle handle; ///< \ref HiddbgHdlsHandle
142  HiddbgHdlsDeviceInfoV7 device; ///< \ref HiddbgHdlsDeviceInfoV7. With \ref hiddbgApplyHdlsStateList this is only used when creating new devices.
143  HiddbgHdlsStateV7 state; ///< \ref HiddbgHdlsStateV7
145 
146 /// HdlsStateListV7, for [7.0.0-8.1.0]. This contains a list of all controllers, including non-virtual controllers.
147 typedef struct {
148  s32 total_entries; ///< Total entries for the below entries.
149  u32 pad; ///< Padding
150  HiddbgHdlsStateListEntryV7 entries[0x10]; ///< \ref HiddbgHdlsStateListEntryV7
152 
153 /// HdlsStateListEntry, for [9.0.0-11.0.1].
154 typedef struct {
155  HiddbgHdlsHandle handle; ///< \ref HiddbgHdlsHandle
156  HiddbgHdlsDeviceInfo device; ///< \ref HiddbgHdlsDeviceInfo. With \ref hiddbgApplyHdlsStateList this is only used when creating new devices.
157  alignas(8) HiddbgHdlsStateV9 state; ///< \ref HiddbgHdlsStateV9
159 
160 /// HdlsStateList, for [9.0.0-11.0.1].
161 typedef struct {
162  s32 total_entries; ///< Total entries for the below entries.
163  u32 pad; ///< Padding
164  HiddbgHdlsStateListEntryV9 entries[0x10]; ///< \ref HiddbgHdlsStateListEntryV9
166 
167 /// HdlsStateListEntry, for [12.0.0+].
168 typedef struct {
169  HiddbgHdlsHandle handle; ///< \ref HiddbgHdlsHandle
170  HiddbgHdlsDeviceInfo device; ///< \ref HiddbgHdlsDeviceInfo. With \ref hiddbgApplyHdlsStateList this is only used when creating new devices.
171  alignas(8) HiddbgHdlsState state; ///< \ref HiddbgHdlsState
173 
174 /// HdlsStateList, for [12.0.0+].
175 /// This contains a list of all controllers, including non-virtual controllers.
176 typedef struct {
177  s32 total_entries; ///< Total entries for the below entries.
178  u32 pad; ///< Padding
179  HiddbgHdlsStateListEntry entries[0x10]; ///< \ref HiddbgHdlsStateListEntry
181 
182 /// AbstractedPadHandle
183 typedef struct {
184  u64 handle; ///< Handle
186 
187 /// AbstractedPadState
188 typedef struct {
189  u32 type; ///< Type. Converted to HiddbgHdlsDeviceInfoV7::type internally by \ref hiddbgSetAutoPilotVirtualPadState. BIT(0) -> BIT(0), BIT(1) -> BIT(15), BIT(2-3) -> BIT(1-2), BIT(4-5) -> BIT(1-2), BIT(6) -> BIT(3). BIT(7-11) -> BIT(11-15), BIT(12-14) -> BIT(12-14), BIT(15) -> BIT(17), BIT(31) -> BIT(21).
190  u8 flags; ///< Flags. Only bit0 is used by \ref hiddbgSetAutoPilotVirtualPadState, when clear it will skip using the rest of the input and run \ref hiddbgUnsetAutoPilotVirtualPadState internally.
191  u8 pad[0x3]; ///< Padding
192 
193  u32 singleColorBody; ///< RGBA Single Body Color
194  u32 singleColorButtons; ///< RGBA Single Buttons Color
195  u8 npadInterfaceType; ///< See HiddbgHdlsDeviceInfo::npadInterfaceType.
196  u8 pad2[0x3]; ///< Padding
197 
199 
200  u8 unused[0x60]; ///< Unused with \ref hiddbgSetAutoPilotVirtualPadState. Not set by \ref hiddbgGetAbstractedPadsState.
202 
203 /// Initialize hiddbg.
205 
206 /// Exit hiddbg.
207 void hiddbgExit(void);
208 
209 /// Gets the Service object for the actual hiddbg service session.
211 
212 /**
213  * @brief SetDebugPadAutoPilotState
214  * @param[in] state \ref HiddbgDebugPadAutoPilotState
215  */
217 
218 /**
219  * @brief UnsetDebugPadAutoPilotState
220  */
222 
223 /**
224  * @brief SetTouchScreenAutoPilotState
225  * @param[in] states Input array of \ref HiddbgMouseAutoPilotState.
226  * @param[in] count Total entries in the states array. Max is 16.
227  */
229 
230 /**
231  * @brief UnsetTouchScreenAutoPilotState
232  */
234 
235 /**
236  * @brief SetMouseAutoPilotState
237  * @param[in] state \ref HiddbgMouseAutoPilotState
238  */
240 
241 /**
242  * @brief UnsetMouseAutoPilotState
243  */
245 
246 /**
247  * @brief SetKeyboardAutoPilotState
248  * @param[in] state \ref HiddbgKeyboardAutoPilotState
249  */
251 
252 /**
253  * @brief UnsetKeyboardAutoPilotState
254  */
256 
257 /**
258  * @brief Deactivates the HomeButton.
259  */
261 
262 /**
263  * @brief SetSleepButtonAutoPilotState
264  * @param[in] state \ref HiddbgSleepButtonAutoPilotState
265  */
267 
268 /**
269  * @brief UnsetSleepButtonAutoPilotState
270  */
272 
273 /**
274  * @brief Writes the input RGB colors to the spi-flash for the specified UniquePad (offset 0x6050 size 0x6).
275  * @note Only available with [3.0.0+].
276  * @param[in] colorBody RGB body color.
277  * @param[in] colorButtons RGB buttons color.
278  * @param[in] unique_pad_id \ref HidsysUniquePadId
279  */
280 Result hiddbgUpdateControllerColor(u32 colorBody, u32 colorButtons, HidsysUniquePadId unique_pad_id);
281 
282 /**
283  * @brief Writes the input RGB colors followed by inval to the spi-flash for the specified UniquePad (offset 0x6050 size 0xD).
284  * @note Only available with [5.0.0+].
285  * @param[in] colorBody RGB body color.
286  * @param[in] colorButtons RGB buttons color.
287  * @param[in] colorLeftGrip RGB left grip color.
288  * @param[in] colorRightGrip RGB right grip color.
289  * @param[in] inval Input value.
290  * @param[in] unique_pad_id \ref HidsysUniquePadId
291  */
292 Result hiddbgUpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip, u32 colorRightGrip, u8 inval, HidsysUniquePadId unique_pad_id);
293 
294 /**
295  * @brief Get the OperationEvent for the specified UniquePad.
296  * @note The Event must be closed by the user once finished with it.
297  * @note Only available with [6.0.0+].
298  * @param[out] out_event Output Event.
299  * @param[in] autoclear The autoclear for the Event.
300  * @param[in] unique_pad_id \ref HidsysUniquePadId
301 **/
302 Result hiddbgAcquireOperationEventHandle(Event* out_event, bool autoclear, HidsysUniquePadId unique_pad_id);
303 
304 /**
305  * @brief Reads spi-flash for the specified UniquePad.
306  * @note This also uses \ref hiddbgAcquireOperationEventHandle to wait for the operation to finish, then \ref hiddbgGetOperationResult is used.
307  * @note Only available with [6.0.0+].
308  * @param[in] offset Offset in spi-flash.
309  * @param[out] buffer Output buffer.
310  * @param[in] size Output buffer size.
311  * @param[in] unique_pad_id \ref HidsysUniquePadId
312 **/
313 Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, HidsysUniquePadId unique_pad_id);
314 
315 /**
316  * @brief Writes spi-flash for the specified UniquePad.
317  * @note This also uses \ref hiddbgAcquireOperationEventHandle to wait for the operation to finish, then \ref hiddbgGetOperationResult is used.
318  * @note Only available with [6.0.0+].
319  * @param[in] offset Offset in spi-flash.
320  * @param[in] buffer Input buffer, must be 0x1000-byte aligned.
321  * @param[in] tmem_size Size of the buffer, must be 0x1000-byte aligned.
322  * @param[in] size Actual transfer size.
323  * @param[in] unique_pad_id \ref HidsysUniquePadId
324 **/
325 Result hiddbgWriteSerialFlash(u32 offset, void* buffer, size_t tmem_size, size_t size, HidsysUniquePadId unique_pad_id);
326 
327 /**
328  * @brief Get the Result for the Operation and handles cleanup, for the specified UniquePad.
329  * @note Only available with [6.0.0+].
330  * @param[in] unique_pad_id \ref HidsysUniquePadId
331 **/
333 
334 /**
335  * @brief Gets the internal DeviceType for the specified controller.
336  * @note Only available with [6.0.0+].
337  * @param[in] unique_pad_id \ref HidsysUniquePadId
338  * @param[out] out Pre-9.0.0 this is an u32, with [9.0.0+] it's an u8.
339 **/
341 
342 /** @name AbstractedPad
343  * This is for virtual HID controllers. Only use this on pre-7.0.0, Hdls should be used otherwise.
344  */
345 ///@{
346 
347 /**
348  * @brief Gets a list of \ref HiddbgAbstractedPadHandle.
349  * @note Only available with [5.0.0-8.1.0].
350  * @param[out] handles Output array of \ref HiddbgAbstractedPadHandle.
351  * @param[in] count Max number of entries for the handles array.
352  * @param[out] total_out Total output entries.
353  */
355 
356 /**
357  * @brief Gets the state for the specified \ref HiddbgAbstractedPadHandle.
358  * @note Only available with [5.0.0-8.1.0].
359  * @param[in] handle \ref HiddbgAbstractedPadHandle
360  * @param[out] state \ref HiddbgAbstractedPadState
361  */
363 
364 /**
365  * @brief Similar to \ref hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output array states.
366  * @note Only available with [5.0.0-8.1.0].
367  * @param[out] handles Output array of \ref HiddbgAbstractedPadHandle.
368  * @param[out] states Output array of \ref HiddbgAbstractedPadState.
369  * @param[in] count Max number of entries for the handles/states arrays.
370  * @param[out] total_out Total output entries.
371  */
373 
374 /**
375  * @brief Sets AutoPilot state for the specified pad.
376  * @note Only available with [5.0.0-8.1.0].
377  * @param[in] AbstractedVirtualPadId This can be any unique value as long as it's within bounds. For example, 0-7 is usable.
378  * @param[in] state \ref HiddbgAbstractedPadState
379  */
381 
382 /**
383  * @brief Clears AutoPilot state for the specified pad set by \ref hiddbgSetAutoPilotVirtualPadState.
384  * @note Only available with [5.0.0-8.1.0].
385  * @param[in] AbstractedVirtualPadId Id from \ref hiddbgSetAutoPilotVirtualPadState.
386  */
388 
389 /**
390  * @brief Clears AutoPilot state for all pads set by \ref hiddbgSetAutoPilotVirtualPadState.
391  */
393 
394 ///@}
395 
396 /** @name Hdls
397  * This is for virtual HID controllers.
398  */
399 ///@{
400 
401 /**
402  * @brief Initialize Hdls.
403  * @note Only available with [7.0.0+].
404  * @param[out] session_id [13.0.0+] \ref HiddbgHdlsSessionId
405  * @param[in] buffer An existing buffer to be used as transfer memory.
406  * @param[in] size Size of the supplied buffer.
407  */
408 Result hiddbgAttachHdlsWorkBuffer(HiddbgHdlsSessionId *session_id, void *buffer, size_t size);
409 
410 /**
411  * @brief Exit Hdls, must be called at some point prior to \ref hiddbgExit.
412  * @note Only available with [7.0.0+].
413  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
414  */
416 
417 /**
418  * @brief Checks if the given device is still attached.
419  * @note Only available with [7.0.0+].
420  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
421  * @param[in] handle \ref HiddbgHdlsHandle
422  * @param[out] out Whether the device is attached.
423  */
425 
426 /**
427  * @brief Gets state for \ref HiddbgHdlsNpadAssignment.
428  * @note Only available with [7.0.0+].
429  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
430  * @param[out] state \ref HiddbgHdlsNpadAssignment
431  */
433 
434 /**
435  * @brief Gets state for \ref HiddbgHdlsStateList.
436  * @note Only available with [7.0.0+].
437  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
438  * @param[out] state \ref HiddbgHdlsStateList
439  */
441 
442 /**
443  * @brief Sets state for \ref HiddbgHdlsNpadAssignment.
444  * @note Only available with [7.0.0+].
445  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
446  * @param[in] state \ref HiddbgHdlsNpadAssignment
447  * @param[in] flag Flag
448  */
450 
451 /**
452  * @brief Sets state for \ref HiddbgHdlsStateList.
453  * @note The \ref HiddbgHdlsState will be applied for each \ref HiddbgHdlsHandle. If a \ref HiddbgHdlsHandle is not found, code similar to \ref hiddbgAttachHdlsVirtualDevice will run with the \ref HiddbgHdlsDeviceInfo, then it will continue with applying state with the new device.
454  * @note Only available with [7.0.0+].
455  * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId
456  * @param[in] state \ref HiddbgHdlsStateList
457  */
459 
460 /**
461  * @brief Attach a device with the input info.
462  * @note Only available with [7.0.0+].
463  * @param[out] handle \ref HiddbgHdlsHandle
464  * @param[in] info \ref HiddbgHdlsDeviceInfo
465  */
467 
468 /**
469  * @brief Detach the specified device.
470  * @note Only available with [7.0.0+].
471  * @param[in] handle \ref HiddbgHdlsHandle
472  */
474 
475 /**
476  * @brief Sets state for the specified device.
477  * @note Only available with [7.0.0+].
478  * @param[in] handle \ref HiddbgHdlsHandle
479  * @param[in] state \ref HiddbgHdlsState
480  */
482 
483 ///@}
484 
Result hiddbgGetUniquePadDeviceTypeSetInternal(HidsysUniquePadId unique_pad_id, u32 *out)
Gets the internal DeviceType for the specified controller.
Result hiddbgUpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip, u32 colorRightGrip, u8 inval, HidsysUniquePadId unique_pad_id)
Writes the input RGB colors followed by inval to the spi-flash for the specified UniquePad (offset 0x...
Result hiddbgWriteSerialFlash(u32 offset, void *buffer, size_t tmem_size, size_t size, HidsysUniquePadId unique_pad_id)
Writes spi-flash for the specified UniquePad.
Result hiddbgSetMouseAutoPilotState(const HiddbgMouseAutoPilotState *state)
SetMouseAutoPilotState.
Result hiddbgUnsetSleepButtonAutoPilotState(void)
UnsetSleepButtonAutoPilotState.
Result hiddbgGetAbstractedPadState(HiddbgAbstractedPadHandle handle, HiddbgAbstractedPadState *state)
Gets the state for the specified HiddbgAbstractedPadHandle.
Result hiddbgApplyHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, const HiddbgHdlsNpadAssignment *state, bool flag)
Sets state for HiddbgHdlsNpadAssignment.
Result hiddbgGetAbstractedPadsState(HiddbgAbstractedPadHandle *handles, HiddbgAbstractedPadState *states, s32 count, s32 *total_out)
Similar to hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output ar...
Result hiddbgDumpHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, HiddbgHdlsNpadAssignment *state)
Gets state for HiddbgHdlsNpadAssignment.
Result hiddbgSetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state)
Sets AutoPilot state for the specified pad.
Result hiddbgAcquireOperationEventHandle(Event *out_event, bool autoclear, HidsysUniquePadId unique_pad_id)
Get the OperationEvent for the specified UniquePad.
void hiddbgExit(void)
Exit hiddbg.
Result hiddbgReadSerialFlash(u32 offset, void *buffer, size_t size, HidsysUniquePadId unique_pad_id)
Reads spi-flash for the specified UniquePad.
Result hiddbgDetachHdlsVirtualDevice(HiddbgHdlsHandle handle)
Detach the specified device.
Result hiddbgReleaseHdlsWorkBuffer(HiddbgHdlsSessionId session_id)
Exit Hdls, must be called at some point prior to hiddbgExit.
Result hiddbgDumpHdlsStates(HiddbgHdlsSessionId session_id, HiddbgHdlsStateList *state)
Gets state for HiddbgHdlsStateList.
Result hiddbgUpdateControllerColor(u32 colorBody, u32 colorButtons, HidsysUniquePadId unique_pad_id)
Writes the input RGB colors to the spi-flash for the specified UniquePad (offset 0x6050 size 0x6).
Result hiddbgSetTouchScreenAutoPilotState(const HidTouchState *states, s32 count)
SetTouchScreenAutoPilotState.
HiddbgHdlsAttribute
HdlsAttribute.
Definition: hiddbg.h:19
@ HiddbgHdlsAttribute_HasVirtualSixAxisSensorAngle
HasVirtualSixAxisSensorAngle.
Definition: hiddbg.h:21
@ HiddbgHdlsAttribute_HasVirtualSixAxisSensorAcceleration
HasVirtualSixAxisSensorAcceleration.
Definition: hiddbg.h:20
Result hiddbgUnsetMouseAutoPilotState(void)
UnsetMouseAutoPilotState.
Result hiddbgUnsetKeyboardAutoPilotState(void)
UnsetKeyboardAutoPilotState.
Service * hiddbgGetServiceSession(void)
Gets the Service object for the actual hiddbg service session.
Result hiddbgApplyHdlsStateList(HiddbgHdlsSessionId session_id, const HiddbgHdlsStateList *state)
Sets state for HiddbgHdlsStateList.
Result hiddbgGetOperationResult(HidsysUniquePadId unique_pad_id)
Get the Result for the Operation and handles cleanup, for the specified UniquePad.
Result hiddbgSetHdlsState(HiddbgHdlsHandle handle, const HiddbgHdlsState *state)
Sets state for the specified device.
Result hiddbgSetSleepButtonAutoPilotState(const HiddbgSleepButtonAutoPilotState *state)
SetSleepButtonAutoPilotState.
Result hiddbgIsHdlsVirtualDeviceAttached(HiddbgHdlsSessionId session_id, HiddbgHdlsHandle handle, bool *out)
Checks if the given device is still attached.
Result hiddbgSetDebugPadAutoPilotState(const HiddbgDebugPadAutoPilotState *state)
SetDebugPadAutoPilotState.
Result hiddbgDeactivateHomeButton(void)
Deactivates the HomeButton.
Result hiddbgUnsetDebugPadAutoPilotState(void)
UnsetDebugPadAutoPilotState.
Result hiddbgAttachHdlsWorkBuffer(HiddbgHdlsSessionId *session_id, void *buffer, size_t size)
Initialize Hdls.
Result hiddbgSetKeyboardAutoPilotState(const HiddbgKeyboardAutoPilotState *state)
SetKeyboardAutoPilotState.
Result hiddbgAttachHdlsVirtualDevice(HiddbgHdlsHandle *handle, const HiddbgHdlsDeviceInfo *info)
Attach a device with the input info.
Result hiddbgInitialize(void)
Initialize hiddbg.
Result hiddbgUnsetTouchScreenAutoPilotState(void)
UnsetTouchScreenAutoPilotState.
Result hiddbgUnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId)
Clears AutoPilot state for the specified pad set by hiddbgSetAutoPilotVirtualPadState.
Result hiddbgGetAbstractedPadHandles(HiddbgAbstractedPadHandle *handles, s32 count, s32 *total_out)
Gets a list of HiddbgAbstractedPadHandle.
HiddbgNpadButton
HiddbgNpadButton. For the remaining buttons, see HidNpadButton.
Definition: hiddbg.h:13
@ HiddbgNpadButton_Capture
Capture button.
Definition: hiddbg.h:15
@ HiddbgNpadButton_Home
HOME button.
Definition: hiddbg.h:14
Result hiddbgUnsetAllAutoPilotVirtualPadState(void)
Clears AutoPilot state for all pads set by hiddbgSetAutoPilotVirtualPadState.
Kernel-mode event structure.
Definition: event.h:13
HidAnalogStickState.
Definition: hid.h:584
HidTouchState.
Definition: hid.h:648
HidVector.
Definition: hid.h:590
AbstractedPadHandle.
Definition: hiddbg.h:183
u64 handle
Handle.
Definition: hiddbg.h:184
AbstractedPadState.
Definition: hiddbg.h:188
u8 npadInterfaceType
See HiddbgHdlsDeviceInfo::npadInterfaceType.
Definition: hiddbg.h:195
u32 type
Type. Converted to HiddbgHdlsDeviceInfoV7::type internally by hiddbgSetAutoPilotVirtualPadState....
Definition: hiddbg.h:189
u32 singleColorButtons
RGBA Single Buttons Color.
Definition: hiddbg.h:194
HiddbgHdlsStateV7 state
State.
Definition: hiddbg.h:198
u32 singleColorBody
RGBA Single Body Color.
Definition: hiddbg.h:193
u8 flags
Flags. Only bit0 is used by hiddbgSetAutoPilotVirtualPadState, when clear it will skip using the rest...
Definition: hiddbg.h:190
State for overriding HidDebugPadState.
Definition: hiddbg.h:25
HidAnalogStickState analog_stick_l
AnalogStickL.
Definition: hiddbg.h:28
u32 attributes
Bitfield of HidDebugPadAttribute.
Definition: hiddbg.h:26
u32 buttons
Bitfield of HidDebugPadButton.
Definition: hiddbg.h:27
HidAnalogStickState analog_stick_r
AnalogStickR.
Definition: hiddbg.h:29
HdlsDeviceInfo, for [7.0.0-8.1.0].
Definition: hiddbg.h:65
u32 singleColorButtons
RGBA Single Buttons Color.
Definition: hiddbg.h:68
u32 deviceTypeInternal
Only one bit can be set. BIT(N*4+0) = Pro-Controller, BIT(N*4+1) = Joy-Con Left, BIT(N*4+2) = Joy-Con...
Definition: hiddbg.h:66
u8 npadInterfaceType
HidNpadInterfaceType. Additional type field used with the above type field (only applies to type bit0...
Definition: hiddbg.h:69
u32 singleColorBody
RGBA Single Body Color.
Definition: hiddbg.h:67
HdlsDeviceInfo, for [9.0.0+]. Converted to/from HiddbgHdlsDeviceInfoV7 on prior sysvers.
Definition: hiddbg.h:74
u32 singleColorBody
RGBA Single Body Color.
Definition: hiddbg.h:78
u32 singleColorButtons
RGBA Single Buttons Color.
Definition: hiddbg.h:79
u8 npadInterfaceType
HidNpadInterfaceType. Additional type field used with the above type field (only applies to HidDevice...
Definition: hiddbg.h:76
u32 colorLeftGrip
[9.0.0+] RGBA Left Grip Color.
Definition: hiddbg.h:80
u8 deviceType
HidDeviceType
Definition: hiddbg.h:75
u32 colorRightGrip
[9.0.0+] RGBA Right Grip Color.
Definition: hiddbg.h:81
HdlsHandle.
Definition: hiddbg.h:55
u64 handle
Handle.
Definition: hiddbg.h:56
HdlsNpadAssignmentEntry.
Definition: hiddbg.h:123
HiddbgHdlsHandle handle
HiddbgHdlsHandle
Definition: hiddbg.h:124
u8 unk_x18
Unknown.
Definition: hiddbg.h:128
u32 unk_xc
Unknown.
Definition: hiddbg.h:126
u64 unk_x10
Unknown.
Definition: hiddbg.h:127
u32 unk_x8
Unknown.
Definition: hiddbg.h:125
HdlsNpadAssignment. Same controllers as HiddbgHdlsStateList, with different entry data.
Definition: hiddbg.h:133
s32 total_entries
Total entries for the below entries.
Definition: hiddbg.h:134
u32 pad
Padding.
Definition: hiddbg.h:135
HdlsSessionId, returned by hiddbgAttachHdlsWorkBuffer.
Definition: hiddbg.h:60
u64 id
Id.
Definition: hiddbg.h:61
HdlsStateListEntryV7, for [7.0.0-8.1.0].
Definition: hiddbg.h:140
HiddbgHdlsDeviceInfoV7 device
HiddbgHdlsDeviceInfoV7. With hiddbgApplyHdlsStateList this is only used when creating new devices.
Definition: hiddbg.h:142
HiddbgHdlsHandle handle
HiddbgHdlsHandle
Definition: hiddbg.h:141
HiddbgHdlsStateV7 state
HiddbgHdlsStateV7
Definition: hiddbg.h:143
HdlsStateListEntry, for [9.0.0-11.0.1].
Definition: hiddbg.h:154
HiddbgHdlsHandle handle
HiddbgHdlsHandle
Definition: hiddbg.h:155
HiddbgHdlsDeviceInfo device
HiddbgHdlsDeviceInfo. With hiddbgApplyHdlsStateList this is only used when creating new devices.
Definition: hiddbg.h:156
HdlsStateListEntry, for [12.0.0+].
Definition: hiddbg.h:168
HiddbgHdlsDeviceInfo device
HiddbgHdlsDeviceInfo. With hiddbgApplyHdlsStateList this is only used when creating new devices.
Definition: hiddbg.h:170
HiddbgHdlsHandle handle
HiddbgHdlsHandle
Definition: hiddbg.h:169
HdlsStateListV7, for [7.0.0-8.1.0]. This contains a list of all controllers, including non-virtual co...
Definition: hiddbg.h:147
s32 total_entries
Total entries for the below entries.
Definition: hiddbg.h:148
u32 pad
Padding.
Definition: hiddbg.h:149
HdlsStateList, for [9.0.0-11.0.1].
Definition: hiddbg.h:161
u32 pad
Padding.
Definition: hiddbg.h:163
s32 total_entries
Total entries for the below entries.
Definition: hiddbg.h:162
HdlsStateList, for [12.0.0+].
Definition: hiddbg.h:176
s32 total_entries
Total entries for the below entries.
Definition: hiddbg.h:177
u32 pad
Padding.
Definition: hiddbg.h:178
HdlsState, for [7.0.0-8.1.0].
Definition: hiddbg.h:85
HidAnalogStickState analog_stick_r
AnalogStickR.
Definition: hiddbg.h:92
u8 flags
ORRed with IsPowered to set the value of the first byte for HidNpadSystemProperties....
Definition: hiddbg.h:87
u8 is_powered
IsPowered for the main PowerInfo, see HidNpadSystemProperties.
Definition: hiddbg.h:86
HidAnalogStickState analog_stick_l
AnalogStickL.
Definition: hiddbg.h:91
u32 battery_level
BatteryLevel for the main PowerInfo, see HidPowerInfo.
Definition: hiddbg.h:89
u32 buttons
See HiddbgNpadButton.
Definition: hiddbg.h:90
u8 indicator
Indicator. Unused for input. Set with output from hiddbgDumpHdlsStates. Not set by hiddbgGetAbstracte...
Definition: hiddbg.h:93
HdlsState, for [9.0.0-11.0.1].
Definition: hiddbg.h:98
HidAnalogStickState analog_stick_l
AnalogStickL.
Definition: hiddbg.h:102
u8 indicator
Indicator. Unused for input. Set with output from hiddbgDumpHdlsStates.
Definition: hiddbg.h:104
u32 battery_level
BatteryLevel for the main PowerInfo, see HidPowerInfo.
Definition: hiddbg.h:99
HidAnalogStickState analog_stick_r
AnalogStickR.
Definition: hiddbg.h:103
u32 flags
Used to set the main PowerInfo for HidNpadSystemProperties. BIT(0) -> IsPowered, BIT(1) -> IsCharging...
Definition: hiddbg.h:100
u64 buttons
See HiddbgNpadButton. [9.0.0+] Masked with 0xfffffffff00fffff.
Definition: hiddbg.h:101
HdlsState, for [12.0.0+].
Definition: hiddbg.h:109
u8 indicator
Indicator. Unused for input.
Definition: hiddbg.h:118
u32 battery_level
BatteryLevel for the main PowerInfo, see HidPowerInfo.
Definition: hiddbg.h:110
HidVector six_axis_sensor_angle
VirtualSixAxisSensorAngle.
Definition: hiddbg.h:116
HidAnalogStickState analog_stick_l
AnalogStickL.
Definition: hiddbg.h:113
u32 flags
Used to set the main PowerInfo for HidNpadSystemProperties. BIT(0) -> IsPowered, BIT(1) -> IsCharging...
Definition: hiddbg.h:111
u32 attribute
Bitfield of HiddbgHdlsAttribute.
Definition: hiddbg.h:117
HidAnalogStickState analog_stick_r
AnalogStickR.
Definition: hiddbg.h:114
u64 buttons
See HiddbgNpadButton. [9.0.0+] Masked with 0xfffffffff00fffff.
Definition: hiddbg.h:112
HidVector six_axis_sensor_acceleration
VirtualSixAxisSensorAcceleration.
Definition: hiddbg.h:115
State for overriding HidKeyboardState.
Definition: hiddbg.h:44
u64 modifiers
Bitfield of HidKeyboardModifier.
Definition: hiddbg.h:45
State for overriding HidMouseState.
Definition: hiddbg.h:33
s32 delta_y
DeltaY.
Definition: hiddbg.h:37
s32 y
Y.
Definition: hiddbg.h:35
s32 delta_x
DeltaX.
Definition: hiddbg.h:36
u32 buttons
Bitfield of HidMouseButton.
Definition: hiddbg.h:39
u32 attributes
Bitfield of HidMouseAttribute.
Definition: hiddbg.h:40
s32 wheel_delta
WheelDelta.
Definition: hiddbg.h:38
s32 x
X.
Definition: hiddbg.h:34
State for overriding SleepButtonState.
Definition: hiddbg.h:50
u64 buttons
Bitfield of buttons, only bit0 is used.
Definition: hiddbg.h:51
UniquePadId for a controller.
Definition: hidsys.h:57
Service object structure.
Definition: service.h:14
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
int8_t s8
8-bit signed integer.
Definition: types.h:25
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21