HID services: Difference between revisions

No edit summary
(13 intermediate revisions by 2 users not shown)
Line 265: Line 265:


== SetSupportedNpadStyleSet ==
== SetSupportedNpadStyleSet ==
Takes an u32 [[#NpadStyleTag]].
Takes a PID-descriptor, an u32 [[#NpadStyleTag]], and an u64 [[AM_services|AppletResourceUserId]], no output.


== GetSupportedNpadStyleSet ==
== GetSupportedNpadStyleSet ==
Returns an u32 [[#NpadStyleTag]].
Takes a PID-descriptor and an u64 [[AM_services|AppletResourceUserId]], returns an u32 [[#NpadStyleTag]].


== SetSupportedNpadIdType ==
== SetSupportedNpadIdType ==
Line 421: Line 421:
| 7
| 7
| NpadLark
| NpadLark
| NES controller.
| NES/Famicom controller.
|-
|-
| 8
| 8
| NpadHandheldLark
| NpadHandheldLark
| NES controller in handheld mode.
| NES/Famicom controller in handheld mode.
|-
|-
| 9
| 9
| NpadLucia
| NpadLucia
|  
| Unknown.
|-
|-
| 10-28
| 10-28
Line 437: Line 437:
| 29
| 29
| NpadSystemExt
| NpadSystemExt
|
| Generic external controller.
|-
|-
| 30
| 30
| NpadSystem
| NpadSystem
|
| Generic controller.
|-
|-
| 31
| 31
Line 606: Line 606:
| 303 || [5.0.0+] [[#GetAbstractedPadsState]]
| 303 || [5.0.0+] [[#GetAbstractedPadsState]]
|-
|-
| 321 || [5.0.0+] SetAutoPilotVirtualPadState
| 321 || [5.0.0+] [[#SetAutoPilotVirtualPadState]]
|-
|-
| 322 || [5.0.0+] UnsetAutoPilotVirtualPadState
| 322 || [5.0.0+] [[#UnsetAutoPilotVirtualPadState]]
|-
|-
| 323 || [5.0.0+] UnsetAllAutoPilotVirtualPadState
| 323 || [5.0.0+] [[#UnsetAllAutoPilotVirtualPadState]]
|-
|-
| 324 || [7.0.0+] [[#AttachHdlsWorkBuffer]]
| 324 || [7.0.0+] [[#AttachHdlsWorkBuffer]]
Line 692: Line 692:
== GetAbstractedPadsState ==
== GetAbstractedPadsState ==
Takes a type-0xA output buffer containing an array of u64 '''AbstractedPadHandle''', a type-0x22 output buffer containing an array of [[#AbstractedPadState]], and returns an output s32 for total entries.
Takes a type-0xA output buffer containing an array of u64 '''AbstractedPadHandle''', a type-0x22 output buffer containing an array of [[#AbstractedPadState]], and returns an output s32 for total entries.
== SetAutoPilotVirtualPadState ==
Takes an input s8 '''AbstractedVirtualPadId''' and an input [[#AbstractedPadState]], no output.
== UnsetAutoPilotVirtualPadState ==
Takes an input s8 '''AbstractedVirtualPadId''', no output.
Clears AutoPilot state for the specified pad.
== UnsetAllAutoPilotVirtualPadState ==
No input/output.
Same as [[#UnsetAutoPilotVirtualPadState]] except this clears state for every pad.


== AttachHdlsWorkBuffer ==
== AttachHdlsWorkBuffer ==
Line 735: Line 748:
== SetHdlsState ==
== SetHdlsState ==
Takes an input [[#HdlsState]] and an input 8-byte '''HdlsHandle''', no output.
Takes an input [[#HdlsState]] and an input 8-byte '''HdlsHandle''', no output.
== AbstractedPadState ==
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x4 || Type, only 1 bit can be set. Converted to [[#HdlsDeviceInfo]]::type internally by [[#SetAutoPilotVirtualPadState]].
|-
| 0x4 || 0x1 || Flags. [[#SetAutoPilotVirtualPadState]] only uses bit0: when clear it will skip using the rest of the input and run [[#UnsetAutoPilotVirtualPadState]] internally.
|-
| 0x5 || 0x3 || Padding
|-
| 0x8 || 0x4 || RGBA Single Body Color
|-
| 0xC || 0x4 || RGBA Single Buttons Color
|-
| 0x10 || 0x1 || Type2. See [[#HiddbgHdlsDeviceInfo]]::type2.
|-
| 0x11 || 0x3 || Padding
|-
| 0x14 || 0x24 || [[#HdlsState]]. Unknown if the last 4-bytes are included in this struct, [[#SetAutoPilotVirtualPadState]]/[[#hiddbgGetAbstractedPadsState]] only uses the first 0x20-bytes.
|-
| 0x38 || 0x60 || Unused with [[#SetAutoPilotVirtualPadState]]/[[#GetAbstractedPadsState]].
|}
Normally the input state is merged with an existing controller selected by Type. However in some cases (BIT(2-5) with type2!=0x2 and BIT(31)) it's detected as a dedicated controller.
Type:
{| class="wikitable" border="1"
!  Bits
!  [[#HdlsDeviceInfo]]::type bits
!  Description
!  Notes
|-
| 0 || 0 || ||
|-
| 1 || 15 || || [[#DeviceType]] |= BIT(1)
|-
| 2 || 1 || ||
|-
| 3 || 2 || ||
|-
| 4 || 1 || ||
|-
| 5 || 2 || ||
|-
| 6 || 3 || ||
|-
| 7 || 11 || || [[#DeviceType]] |= BIT(11)
|-
| 8 || 12 || || [[#DeviceType]] |= BIT(12)
|-
| 9 || 13 || || [[#DeviceType]] |= BIT(13)
|-
| 10 || 14 || || [[#DeviceType]] |= BIT(14)
|-
| 11 || 15 || || [[#DeviceType]] |= BIT(11)
|-
| 12 || 12 || || [[#DeviceType]] |= BIT(12)
|-
| 13 || 13 || || [[#DeviceType]] |= BIT(13)
|-
| 14 || 14 || || [[#DeviceType]] |= BIT(14)
|-
| 15 || 17 || ||
|-
| 31 || 21 || || [[#DeviceType]] = BIT(31)
|-
|}
The above "[[#DeviceType]] |=" notes only apply when type2 is 0x2.


== HdlsNpadAssignment ==
== HdlsNpadAssignment ==
This is a 0x208-byte struct. This seems to be an array, structure unknown.
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x4 || s32 Total entries
|-
| 0x4 || 0x4 || Padding
|-
| 0x8 || 0x200(0x20*0x10) || Array of [[#HdlsNpadAssignmentEntry]].
|}


== AbstractedPadState ==
This is a 0x208-byte struct.
 
=== HdlsNpadAssignmentEntry ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x98 || ?
| 0x0 || 0x8 || HdlsHandle
|-
| 0x8 || 0x4 || ?
|-
| 0xC || 0x4 || ?
|-
| 0x10 || 0x8 || ?
|-
| 0x18 || 0x1 || ?
|-
| 0x19 || 0x7 || Padding
|}
|}
This is a 0x20-byte struct.


== HdlsStateList ==
== HdlsStateList ==
Line 752: Line 859:
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x4 || Total entries
| 0x0 || 0x4 || s32 Total entries
|-
|-
| 0x4 || 0x4 || Padding
| 0x4 || 0x4 || Padding
Line 790: Line 897:
| 0x8 || 0x4 || RGBA Single Buttons Color
| 0x8 || 0x4 || RGBA Single Buttons Color
|-
|-
| 0xC || 0x1 || Additional type field used with the above type field, 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 Joy-Con Left/Right: with value 0x2 the system doesn't list the controller in hid sharedmem. Type bit21: value 0x3 = unknown.
| 0xC || 0x1 || Additional type field used with the above type field, 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 bit21: 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.
|-
|-
| 0xD || 0x3 || Padding
| 0xD || 0x3 || Padding
Line 806: Line 913:
| 0-7
| 0-7
|  
|  
| 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(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.
|-
|-
| 8-10
| 8-10
|  
|  
| Pro-Controller
| Pro Controller
|-
|-
| 11
| 11
|  
|  
| Famicom-Controller
| Famicom left controller
|-
|-
| 12
| 12
|  
|  
| Famicom-Controller II with microphone
| Famicom right controller (with microphone)
|-
|-
| 13
| 13
|  
|  
| NES-Controller ([[#DeviceType]]=0x200)
| NES left controller
|-
|-
| 14
| 14
|  
|  
| NES-Controller ([[#DeviceType]]=0x400)
| NES right controller
|-
|-
| 15-16
| 15-16
Line 834: Line 941:
| 17
| 17
|  
|  
| Unknown ([[#DeviceType]]=0x8000)
| Generic external controller
|-
|-
| 18-20
| 18-20
Line 842: Line 949:
| 21-23
| 21-23
|  
|  
| Unknown ([[#DeviceType]]=0x80000000)
| Generic controller
|}
|}


Line 858: Line 965:
| 0x8 || 0x4 || batteryCharge for the main [[HID_Shared_Memory#Controllers|PowerInfo]].
| 0x8 || 0x4 || batteryCharge for the main [[HID_Shared_Memory#Controllers|PowerInfo]].
|-
|-
| 0xC || 0x4 || Buttons
| 0xC || 0x4 || [[HID_Shared_Memory#Button_State|Buttons]]. Bit18 = HOME and bit19 = Capture.
|-
|-
| 0x10 || 0x10(4*2*2) || Joystick data, see [[HID_Shared_Memory#Controller_State]].
| 0x10 || 0x10(4*2*2) || Joystick data, see [[HID_Shared_Memory#Controller_State]].
Line 924: Line 1,031:
| 309 || [5.0.0+] GetNpadFullKeyGripColor
| 309 || [5.0.0+] GetNpadFullKeyGripColor
|-
|-
| 310 || [6.0.0+] GetMaskedSupportedNpadStyleSet
| 310 || [6.0.0+] [[#GetMaskedSupportedNpadStyleSet]]
|-
|-
| 311 || SetNpadPlayerLedBlinkingDevice
| 311 || SetNpadPlayerLedBlinkingDevice
Line 1,094: Line 1,201:
| 1150 || [8.0.0+] SetTouchScreenMagnification
| 1150 || [8.0.0+] SetTouchScreenMagnification
|}
|}
== GetMaskedSupportedNpadStyleSet ==
Takes an input u64 AppletResourceUserId, returns an output u32 [[#NpadStyleTag]].
Official sw uses the output from [[Applet_Manager_services|GetAppletResourceUserIdOfCallerApplet]] with this.


== GetUniquePadsFromNpad ==
== GetUniquePadsFromNpad ==
Line 1,310: Line 1,422:
| 0
| 0
| FullKey
| FullKey
| Pro Controller.
| Pro Controller and Gc controller.
|-
|-
| 1
| 1
Line 1,318: Line 1,430:
| 2
| 2
| HandheldLeft
| HandheldLeft
| Joy-Con left controller in handheld mode.
| Joy-Con/Famicom/NES left controller in handheld mode.
|-
|-
| 3
| 3
| HandheldRight
| HandheldRight
| Joy-Con right controller in handheld mode.
| Joy-Con/Famicom/NES right controller in handheld mode.
|-
|-
| 4
| 4
| JoyLeft
| JoyLeft
| Joy-Con left controller in single mode.
| Joy-Con left controller.
|-
|-
| 5
| 5
| JoyRight
| JoyRight
| Joy-Con right controller in single mode.
| Joy-Con right controller.
|-
|-
| 6
| 6
Line 1,337: Line 1,449:
|-
|-
| 7
| 7
|  
| LarkLeft (HVC)
| Famicom controller.
| Famicom left controller.
|-
|-
| 8
| 8
|  
| LarkRight (HVC)
| Famicom controller II with microphone.
| Famicom right controller (with microphone).
|-
|-
| 9
| 9
|  
| LarkLeft (NES)
| NES controller.
| NES left controller.
|-
|-
| 10
| 10
|  
| LarkRight (NES)
| NES controller (same as above?).
| NES right controller.
|-
|-
| 11-14
| 11-14
|  
|  
| Unknown
| Reserved
|-
|-
| 15
| 15
|  
| SystemExt
| Unknown controller type.
| Generic external controller.
|-
|-
| 16-30
| 16-30
|  
|  
| Unknown
| Reserved
|-
|-
| 31
| 31
|  
| System
| Unknown controller type (similar to bit15?).
| Generic controller.
|}
|}