HID services: Difference between revisions

Line 2,864: Line 2,864:


== GetBusHandle ==
== GetBusHandle ==
Takes an input u32 [[#NpadIdType]], an u64 [[#BusType]], an u64 [[AM_services|AppletResourceUserId]], returns an output u8 bool and a [[#BusHandle]].
Takes an input u32 [[#NpadIdType]], an u64 [[#BusType]] and an u64 [[AM_services|AppletResourceUserId]]. Returns an output bool '''HasHandle''' and a [[#BusHandle]].


The bool indicates whether the [[#BusHandle]] is valid.
'''HasHandle''' indicates whether the [[#BusHandle]] is valid.


Official sw will assert when [[#BusHandle]] InternalIndex is >=0x11 (>=0x13 with [6.0.0+]). This same check is also done for all funcs using [[#BusHandle]] as input.
Official sw will assert when [[#BusHandle]] InternalIndex is >=0x11 (>=0x13 with [6.0.0+]). This same check is also done for all funcs using [[#BusHandle]] as input.
Line 2,873: Line 2,873:


== IsExternalDeviceConnected ==
== IsExternalDeviceConnected ==
Takes an input [[#BusHandle]], returns an output u8 bool.
Takes an input [[#BusHandle]]. Returns an output bool '''IsAttached'''.


This is not used by sdknso.
This is not used by sdknso.


== Initialize ==
== Initialize ==
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.
Takes an input [[#BusHandle]] and an u64 [[AM_services|AppletResourceUserId]]. No output.


Prior to using this cmd, sdknso handles [[#GetSharedMemoryHandle|sharedmem]] mapping if not done previously.
Prior to using this cmd, sdknso handles [[#GetSharedMemoryHandle|sharedmem]] mapping if not done previously.


== Finalize ==
== Finalize ==
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.
Takes an input [[#BusHandle]] and an u64 [[AM_services|AppletResourceUserId]]. No output.


== EnableExternalDevice ==
== EnableExternalDevice ==
Takes an input u8 bool, a [[#BusHandle]], an u64, an u64 [[AM_services|AppletResourceUserId]], no output.
Takes an input bool '''IsEnabled''', a [[#BusHandle]], an u64 '''Version''' and an u64 [[AM_services|AppletResourceUserId]]. No output.


sdknso passes value 0x38900050018 (0x3A600050018 with 7.x+) for the u64.
sdknso passes value 0x38900050018 (0x3A600050018 with 7.x+) for '''Version'''.


The bool flag indicates whether to enable the device (true = enable, false = disable).  When false, this will use [[#DisableJoyPollingReceiveMode]] if needed.
'''IsEnabled''' indicates whether to enable the device (true = enable, false = disable).  When false, this will use [[#DisableJoyPollingReceiveMode]] if needed.


== GetExternalDeviceId ==
== GetExternalDeviceId ==
Takes an input [[#BusHandle]], returns an output u32 ExternalDeviceId.
Takes an input [[#BusHandle]]. Returns an output u32 '''DeviceId'''.


== SendCommandAsync ==
== SendCommandAsync ==
Takes a type-0x21 input buffer and a [[#BusHandle]], no output.
Takes a type-0x21 input buffer and a [[#BusHandle]]. No output.


== GetSendCommandAsynceResult ==
== GetSendCommandAsynceResult ==
Takes a type-0x22 output buffer and a [[#BusHandle]], returns an output u32.
Takes a type-0x22 output buffer and a [[#BusHandle]]. Returns an output u32 '''OutSize'''.


Official sw copies the u32 to an output u64, for the actual output size.
Official sw copies '''OutSize''' to an output u64, for the actual output size.


== SetEventForSendCommandAsycResult ==
== SetEventForSendCommandAsycResult ==
Takes an input [[#BusHandle]], returns an output Event handle with EventClearMode=0.
Takes an input [[#BusHandle]]. Returns an output Event handle '''AttachmentDataReceiveEventHandle''' with EventClearMode=0.


Official sw with SendAndReceive clears this event (6.x+ sdknso), uses [[#SendCommandAsync]], waits on + clears this event, then uses [[#GetSendCommandAsynceResult]].
Official sw with SendAndReceive clears this event (6.x+ sdknso), uses [[#SendCommandAsync]], waits on + clears this event, then uses [[#GetSendCommandAsynceResult]].


== GetSharedMemoryHandle ==
== GetSharedMemoryHandle ==
No input, returns an output SharedMemory handle.
No input. Returns an output SharedMemory handle.


The SharedMemory is mapped with size 0x1000 and permissions=R--.
The SharedMemory is mapped with size 0x1000 and permissions=R--.
Line 2,941: Line 2,941:


== EnableJoyPollingReceiveMode ==
== EnableJoyPollingReceiveMode ==
Takes a type-0x21 input buffer, a TransferMemory handle, an u32 tmem_size, an u32 [[#JoyPollingMode]], a [[#BusHandle]], no output.
Takes a type-0x21 input buffer, a TransferMemory handle, an u32 '''TransferMemorySize''', an u32 [[#JoyPollingMode]] and a [[#BusHandle]]. No output.


The TransferMemory is created with an user-specified output buffer, with permissions=R--.
The TransferMemory is created with an user-specified output buffer, with permissions=R--.
Line 3,010: Line 3,010:


== DisableJoyPollingReceiveMode ==
== DisableJoyPollingReceiveMode ==
Takes an input [[#BusHandle]], no output.
Takes an input [[#BusHandle]]. No output.


== SetStatusManagerType ==
== SetStatusManagerType ==
Takes an input u32, no output.
Takes an input u32 [[#StatusManagerType]]. No output.


This is used by sdknso immediately after mapping [[#GetSharedMemoryHandle|sharedmem]] (before [[#Initialize]]) with hard-coded value 0x2.
This is used by sdknso immediately after mapping [[#GetSharedMemoryHandle|sharedmem]] (before [[#Initialize]]) with hard-coded value 0x2.