HID services: Difference between revisions

No edit summary
No edit summary
(18 intermediate revisions by 2 users not shown)
Line 1,229: Line 1,229:
| 0x8 || 0x8 || [[#IrSensorMode]]
| 0x8 || 0x8 || [[#IrSensorMode]]
|-
|-
| 0x10 || 0xE20 || Array of ProcessorState
| 0x10 || 0xE20 || [[#ProcessorStateRingLifo]]
|}
|}
==== ProcessorStateRingLifo ====
This is "nn::irsensor::detail::RingLifo<X,Y>" where "X" is a specialized processor state (e.g.: "nn::irsensor::MomentProcessorState") and "Y" is the maximum element count (e.g.: 5).
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x8 || Start
|-
| 0x8 || 0x4 || Count
|-
| 0xC || 0x4 || Padding
|-
| 0x10 || Variable || ProcessorState
|}
The maximum element count is 6 for [[#PointingProcessorMarkerState]] or 5 for any of the other states.


ProcessorState is specialized depending on the value of [[#IrSensorMode]].
ProcessorState is specialized depending on the value of [[#IrSensorMode]].


The array of ProcessorState can hold up to 6 entries of [[#PointingProcessorState]] or 5 entries of any of the other states.  
===== MomentProcessorState =====
This is "nn::irsensor::MomentProcessorState".


==== MomentProcessorState ====
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 1,252: Line 1,270:
|}
|}


The array of [[#MomentStatistic]] can hold up to 48 entries.
The array of [[#MomentStatistic]] can hold up to 48 entries. This array can be accessed as [y + x*8] (this is a 6x8 array). region_x = image_x/6, region_y = image_y/8.
 
====== MomentStatistic ======
In sdknso GetMomentProcessorStates, this loops through each MomentProcessorState->MomentStatistic entry: <code>AverageIntensity *= scale;</code> The scale is calculated with: <code>scale = 76800.0f / (float)([[#PackedMomentProcessorConfig|WindowOfInterest]].width * [[#PackedMomentProcessorConfig|WindowOfInterest]].height);</code> Note that <code>76800 == 320*240</code>, hence with the default width/height the calculated scale is 1.0f.


===== MomentStatistic =====
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x4 || AverageIntensity
| 0x0 || 0x4 || float AverageIntensity
|-
|-
| 0x4 || 0x4 || CentroidX
| 0x4 || 0x4 || float CentroidX
|-
|-
| 0x8 || 0x4 || CentroidY
| 0x8 || 0x4 || float CentroidY
|}
|}


==== ClusteringProcessorState ====
===== ClusteringProcessorState =====
This is "nn::irsensor::ClusteringProcessorState".
 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 1,286: Line 1,308:
The array of [[#ClusteringData]] can hold up to 16 entries.
The array of [[#ClusteringData]] can hold up to 16 entries.


===== ClusteringData =====
====== ClusteringData ======
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x4 || AverageIntensity
| 0x0 || 0x4 || float AverageIntensity
|-
|-
| 0x4 || 0x4 || CentroidX
| 0x4 || 0x4 || float CentroidX
|-
|-
| 0x8 || 0x4 || CentroidY
| 0x8 || 0x4 || float CentroidY
|-
|-
| 0xC || 0x4 || PixelCount
| 0xC || 0x4 || PixelCount
Line 1,308: Line 1,330:
|}
|}


==== PointingProcessorState ====
===== PointingProcessorMarkerState =====
This is "nn::irsensor::PointingProcessorMarkerState".
 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 1,317: Line 1,341:
| 0x8 || 0x8 || TimeStamp
| 0x8 || 0x8 || TimeStamp
|-
|-
| 0x10 || 0x60 || Unknown
| 0x10 || 0x1 || PointingStatus
|}
|-
 
| 0x11 || 0xB || Reserved
==== TeraPluginProcessorState ====
|-
{| class="wikitable" border="1"
| 0x1C || 0x4 || float PositionX
|-
|-
! Offset || Size || Description
| 0x20 || 0x4 || float PositionY
|-
|-
| 0x0 || 0x8 || SamplingNumber
| 0x24 || 0xC || Reserved
|-
|-
| 0x8 || 0x8 || TimeStamp
| 0x30 || 0x1 || PointingStatus
|-
|-
| 0x10 || 0x130 || Unknown
| 0x31 || 0xB || Reserved
|}
 
=== AruidFormat ===
{| class="wikitable" border="1"
|-
|-
! Offset || Size || Description
| 0x3C || 0x4 || float PositionX
|-
|-
| 0x0 || 0x8 || IrSensorAruid
| 0x40 || 0x4 || float PositionY
|-
|-
| 0x8 || 0x8 || IrSensorAruidStatus
| 0x44 || 0xC || Reserved
|-
| 0x50 || 0x1 || PointingStatus
|-
| 0x51 || 0xB || Reserved
|-
| 0x5C || 0x4 || float PositionX
|-
| 0x60 || 0x4 || float PositionY
|-
| 0x64 || 0xC || Reserved
|}
|}


== StopImageProcessor ==
===== PointingProcessorState =====
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.
This is "nn::irsensor::PointingProcessorState".


== RunMomentProcessor ==
This is created from [[#PointingProcessorMarkerState]].
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], and a [[#PackedMomentProcessorConfig]]. No output.


== RunClusteringProcessor ==
{| class="wikitable" border="1"
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], and a [[#PackedClusteringProcessorConfig]]. No output.
|-
! Offset || Size || Description
|-
| 0x0 || 0x8 || SamplingNumber
|-
| 0x8 || 0x8 || TimeStamp
|-
| 0x10 || 0x4 || PointingStatus
|-
| 0x14 || 0x4 || float PositionX
|-
| 0x18 || 0x4 || float PositionY
|-
| 0x1C || 0x4 || Reserved
|}


== RunImageTransferProcessor ==
===== TeraPluginProcessorState =====
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], a [[#PackedImageTransferProcessorConfig]], an u64 for the TransferMemory's size, and a TransferMemory handle. No output.
This is "nn::irsensor::TeraPluginProcessorState".


The TransferMemory is created with an user specified buffer and permission none.
{| class="wikitable" border="1"
 
|-
== GetImageTransferProcessorState ==
! Offset || Size || Description
Takes a PID-descriptor, a type-0x6 output buffer, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. Returns an [[#ImageTransferProcessorState]]. No output.
|-
| 0x0 || 0x8 || SamplingNumber
|-
| 0x8 || 0x8 || TimeStamp
|-
| 0x10 || 0x4 || AmbientNoiseLevel
|-
| 0x14 || 0x12C || PluginData
|}


== RunTeraPluginProcessor==
===== AdaptiveClusteringProcessorState =====
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedTeraPluginProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.
This is "nn::irsensor::AdaptiveClusteringProcessorState".


== GetNpadIrCameraHandle ==
This is created from [[#TeraPluginProcessorState]].
Takes an input [[#NpadIdType]]. Returns an output [[#IrCameraHandle]].


== RunPointingProcessor ==
{| class="wikitable" border="1"
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedPointingProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.
|-
 
! Offset || Size || Description
== SuspendImageProcessor ==
|-
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.
| 0x0 || 0x8 || SamplingNumber
 
|-
sdknso uses this from the Run*Processor funcs to suspend the current Processor when the current [[#PackedFunctionLevel|FunctionLevel]] is >= 0x1, prior to starting another Processor if needed (depending on  what Processor was already active via a state field). Hence, this cmd is only used with [4.0.0+].
| 0x8 || 0x8 || TimeStamp
|-
| 0x10 || 0x4 || AmbientNoiseLevel
|-
| 0x14 || 0x4 || AccuracyLevel
|-
| 0x18 || 0x1 || ObjectCount
|-
| 0x19 || 0x1 || BackgroundIntensity
|-
| 0x1A || 0x6 || Reserved
|-
| 0x20 || 0x200 || Array of [[#AdaptiveClusteringData]]
|}


== CheckFirmwareVersion ==
The array of [[#AdaptiveClusteringData]] can hold up to 16 entries.
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedMcuVersion]], and an [[AM_services|AppletResourceUserId]]. No output.


sdknso didn't actually use this until 4.x (the RequiredMcuVersion was also updated with that version).
====== AdaptiveClusteringData ======
 
{| class="wikitable" border="1"
== SetFunctionLevel ==
|-
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedFunctionLevel]], and an [[AM_services|AppletResourceUserId]]. No output.
! Offset || Size || Description
|-
| 0x0 || 0x4 || float CentroidX
|-
| 0x4 || 0x4 || float CentroidY
|-
| 0x8 || 0x4 || float Area
|-
| 0xC || 0x4 || IsIncomplete
|}


== RunImageTransferExProcessor ==
===== HandAnalysisImageState =====
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], a [[#PackedImageTransferProcessorExConfig]], an u64 for the TransferMemory's size, and a TransferMemory handle. No output.
This is "nn::irsensor::HandAnalysisImageState".


The TransferMemory is created with an user specified buffer and permission none.
This is created from [[#TeraPluginProcessorState]].


== RunIrLedProcessor ==
{| class="wikitable" border="1"
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedIrLedProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.
|-
! Offset || Size || Description
|-
| 0x0 || 0x8 || SamplingNumber
|-
| 0x8 || 0x4 || AmbientNoiseLevel
|-
| 0xC || 0x960 || Image
|-
| 0x96C || 0x4 || Reserved
|}


== StopImageProcessorAsync ==
===== HandAnalysisSilhouetteState =====
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.
This is "nn::irsensor::HandAnalysisSilhouetteState".


== ActivateIrsensorWithFunctionLevel ==
This is created from [[#TeraPluginProcessorState]].
Takes a PID-descriptor, an [[#PackedFunctionLevel]], and an [[AM_services|AppletResourceUserId]]. No output.
 
= irs:sys =
This is "nn::irsensor::IIrSensorSystemServer".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Cmd || Name
! Offset || Size || Description
|-
|-
| 500 || [[#SetAppletResourceUserId]]
| 0x0 || 0x8 || SamplingNumber
|-
|-
| 501 || [[#RegisterAppletResourceUserId]]
| 0x8 || 0x4 || AmbientNoiseLevel
|-
|-
| 502 || [[#UnregisterAppletResourceUserId]]
| 0xC || 0x1354 || Unknown
|-
| 503 || [[#EnableAppletToGetInput]]
|}
|}


== SetAppletResourceUserId ==
===== HandAnalysisSilhouetteStateWithFullFrameShape =====
Takes an [[AM_services|AppletResourceUserId]]. No output.
This is "nn::irsensor::HandAnalysisSilhouetteStateWithFullFrameShape".


== RegisterAppletResourceUserId ==
This is created from [[#TeraPluginProcessorState]].
Takes a bool and an [[AM_services|AppletResourceUserId]]. No output.


== UnregisterAppletResourceUserId ==
{| class="wikitable" border="1"
Takes an [[AM_services|AppletResourceUserId]]. No output.
|-
 
! Offset || Size || Description
== EnableAppletToGetInput ==
Takes a bool and an [[AM_services|AppletResourceUserId]]. No output.
 
= ahid:cd =
This is "nn::ahid::IServerSession".
 
Used for USB HID devices.
 
This service no longer exists in [9.0.0+].
 
{| class="wikitable" border="1"
|-
|-
! Cmd || Name
| 0x0 || 0x8 || SamplingNumber
|-
|-
| 0 || [[#AcquireDevice]]
| 0x8 || 0x4 || AmbientNoiseLevel
|-
|-
| 1 || [[#ReleaseDevice]]
| 0xC || 0x156C || Unknown
|}
 
=== AruidFormat ===
{| class="wikitable" border="1"
|-
|-
| 2 || [[#GetCtrlSession]]
! Offset || Size || Description
|-
|-
| 3 || [[#GetReadSession]]
| 0x0 || 0x8 || IrSensorAruid
|-
|-
| 4 || [1.0.0-2.3.0] [[#GetWriteSession]]
| 0x8 || 0x8 || IrSensorAruidStatus
|}
|}


== AcquireDevice ==
== StopImageProcessor ==
Takes an input s32, no output.
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.


== ReleaseDevice ==
== RunMomentProcessor ==
Takes an input s32, no output.
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], and a [[#PackedMomentProcessorConfig]]. No output.


== GetCtrlSession ==
== RunClusteringProcessor ==
Takes an input u32, returns an [[#ICtrlSession]].
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], and a [[#PackedClusteringProcessorConfig]]. No output.


== GetReadSession ==
== RunImageTransferProcessor ==
Takes an input u32, returns an [[#IReadSession]].
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], a [[#PackedImageTransferProcessorConfig]], an u64 for the TransferMemory's size, and a TransferMemory handle. No output.


== GetWriteSession ==
The TransferMemory is created with an user specified buffer and permission none.
Takes an input u32, returns an [[#IWriteSession]].


== ICtrlSession ==
== GetImageTransferProcessorState ==
This is "nn::ahid::ICtrlSession".
Takes a PID-descriptor, a type-0x6 output buffer, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. Returns an [[#ImageTransferProcessorState]]. No output.


This no longer exists in [9.0.0+].
== RunTeraPluginProcessor==
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedTeraPluginProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.


{| class="wikitable" border="1"
== GetNpadIrCameraHandle ==
|-
Takes an input [[#NpadIdType]]. Returns an output [[#IrCameraHandle]].
! Cmd || Name
|-
| 0 || GetString
|-
| 1 || GetCodeBook
|-
| 2 || GetReport
|-
| 3 || SetReport
|-
| 4 || GetIdle
|-
| 5 || SetIdle
|-
| 6 || GetProtocol
|-
| 7 || SetProtocol
|-
| 8 || GetDescriptor
|-
| 9 || SetDescriptor
|-
| 10 || GetStateChangeEvent
|-
| 11 || SignalStateChangeEvent
|-
| 12 || [3.0.0+] Write
|}


All of these use USB [[USB_services|CtrlXfer]], except for GetStateChangeEvent and SignalStateChangeEvent, and GetCodeBook which copies 0x4000-bytes from state to output.
== RunPointingProcessor ==
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedPointingProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.


== IReadSession ==
== SuspendImageProcessor ==
This is "nn::ahid::IReadSession".
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.


This no longer exists in [9.0.0+].
sdknso uses this from the Run*Processor funcs to suspend the current Processor when the current [[#PackedFunctionLevel|FunctionLevel]] is >= 0x1, prior to starting another Processor if needed (depending on  what Processor was already active via a state field). Hence, this cmd is only used with [4.0.0+].


{| class="wikitable" border="1"
== CheckFirmwareVersion ==
|-
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedMcuVersion]], and an [[AM_services|AppletResourceUserId]]. No output.
! Cmd || Name
|-
| 0 || [[#Read]]
|}


=== Read ===
sdknso didn't actually use this until 4.x (the RequiredMcuVersion was also updated with that version).
Uses [[USB_services|PostBufferAsync]] etc with the INPUT endpoint. The size must be <=0x1000. The actual transfer size is returned in an output u64. The data is copied from the tmpbuf to the output buffer using the actual-transfer-size.


[3.0.0+] Now takes a total of 8-bytes of input.
== SetFunctionLevel ==
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedFunctionLevel]], and an [[AM_services|AppletResourceUserId]]. No output.


== IWriteSession ==
== RunImageTransferExProcessor ==
This is "nn::ahid::IWriteSession".
Takes a PID-descriptor, an [[#IrCameraHandle]], an [[AM_services|AppletResourceUserId]], a [[#PackedImageTransferProcessorExConfig]], an u64 for the TransferMemory's size, and a TransferMemory handle. No output.


This was removed with [3.0.0+].
The TransferMemory is created with an user specified buffer and permission none.


{| class="wikitable" border="1"
== RunIrLedProcessor ==
|-
Takes a PID-descriptor, an [[#IrCameraHandle]], a [[#PackedIrLedProcessorConfig]] (immediately after the previous word), and an [[AM_services|AppletResourceUserId]]. No output.
! Cmd || Name
|-
| 0 || [[#Write]]
|}


=== Write ===
== StopImageProcessorAsync ==
This is the inverse of [[#IReadSession]] cmd0. Uses the OUTPUT endpoint with an input buffer.
Takes a PID-descriptor, an [[#IrCameraHandle]], and an [[AM_services|AppletResourceUserId]]. No output.


= ahid:hdr =
== ActivateIrsensorWithFunctionLevel ==
This is "nn::ahid::hdr::ISession".
Takes a PID-descriptor, an [[#PackedFunctionLevel]], and an [[AM_services|AppletResourceUserId]]. No output.


Used internally for USB HID devices.
= irs:sys =
 
This is "nn::irsensor::IIrSensorSystemServer".
This service no longer exists in [9.0.0+].


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,541: Line 1,572:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || GetDeviceEntries
| 500 || [[#SetAppletResourceUserId]]
|-
|-
| 1 || GetDeviceList
| 501 || [[#RegisterAppletResourceUserId]]
|-
|-
| 2 || GetDeviceParameters
| 502 || [[#UnregisterAppletResourceUserId]]
|-
|-
| 3 || AttachDevice
| 503 || [[#EnableAppletToGetInput]]
|-
|}
| 4 || DetachDevice
 
|-
== SetAppletResourceUserId ==
| 5 || [6.0.0+] SetDeviceFilter
Takes an [[AM_services|AppletResourceUserId]]. No output.
|}
 
== RegisterAppletResourceUserId ==
Takes a bool and an [[AM_services|AppletResourceUserId]]. No output.
 
== UnregisterAppletResourceUserId ==
Takes an [[AM_services|AppletResourceUserId]]. No output.
 
== EnableAppletToGetInput ==
Takes a bool and an [[AM_services|AppletResourceUserId]]. No output.
 
= ahid:cd =
This is "nn::ahid::IServerSession".
 
Used for USB HID devices.


= xcd:sys =
This service no longer exists in [9.0.0+].
This is "nn::xcd::detail::ISystemServer".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,561: Line 1,604:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || GetDataFormat
| 0 || [[#AcquireDevice]]
|-
|-
| 1 || SetDataFormat
| 1 || [[#ReleaseDevice]]
|-
|-
| 2 || GetMcuState
| 2 || [[#GetCtrlSession]]
|-
|-
| 3 || SetMcuState
| 3 || [[#GetReadSession]]
|-
|-
| 4 || GetMcuVersionForNfc
| 4 || [1.0.0-2.3.0] [[#GetWriteSession]]
|}
 
== AcquireDevice ==
Takes an input s32, no output.
 
== ReleaseDevice ==
Takes an input s32, no output.
 
== GetCtrlSession ==
Takes an input u32, returns an [[#ICtrlSession]].
 
== GetReadSession ==
Takes an input u32, returns an [[#IReadSession]].
 
== GetWriteSession ==
Takes an input u32, returns an [[#IWriteSession]].
 
== ICtrlSession ==
This is "nn::ahid::ICtrlSession".
 
This no longer exists in [9.0.0+].
 
{| class="wikitable" border="1"
|-
|-
| 5 || CheckNfcDevicePower
! Cmd || Name
|-
|-
| 6 || [5.0.0+] SetMcuStateImmediate
| 0 || GetString
|-
|-
| 10 || SetNfcEvent
| 1 || GetCodeBook
|-
|-
| 11 || GetNfcInfo
| 2 || GetReport
|-
|-
| 12 || StartNfcDiscovery
| 3 || SetReport
|-
|-
| 13 || StopNfcDiscovery
| 4 || GetIdle
|-
|-
| 14 || StartNtagRead
| 5 || SetIdle
|-
|-
| 15 || StartNtagWrite
| 6 || GetProtocol
|-
|-
| 16 || SendNfcRawData
| 7 || SetProtocol
|-
|-
| 17 || RegisterMifareKey
| 8 || GetDescriptor
|-
|-
| 18 || ClearMifareKey
| 9 || SetDescriptor
|-
|-
| 19 || StartMifareRead
| 10 || GetStateChangeEvent
|-
|-
| 20 || StartMifareWrite
| 11 || SignalStateChangeEvent
|-
|-
| 101 || GetAwakeTriggerReasonForLeftRail
| 12 || [3.0.0+] Write
|}
 
All of these use USB [[USB_services|CtrlXfer]], except for GetStateChangeEvent and SignalStateChangeEvent, and GetCodeBook which copies 0x4000-bytes from state to output.
 
== IReadSession ==
This is "nn::ahid::IReadSession".
 
This no longer exists in [9.0.0+].
 
{| class="wikitable" border="1"
|-
! Cmd || Name
|-
|-
| 102 || GetAwakeTriggerReasonForRightRail
| 0 || [[#Read]]
|}
|}


[5.0.0+] SetDataFormat, SetMcuState, and ClearMifareKey: now takes a total of 0xC-bytes of input instead of 0x10.
=== Read ===
Uses [[USB_services|PostBufferAsync]] etc with the INPUT endpoint. The size must be <=0x1000. The actual transfer size is returned in an output u64. The data is copied from the tmpbuf to the output buffer using the actual-transfer-size.


[6.0.0+]: The buffer type used by GetNfcInfo is now 0x32 instead of 0x1A.
[3.0.0+] Now takes a total of 8-bytes of input.


= hidbus =
== IWriteSession ==
This is "nn::hidbus::IHidbusServer".
This is "nn::ahid::IWriteSession".


This was added with [5.0.0+].
This was removed with [3.0.0+].
 
Official sw opens a temporary service-session for each func using this, with it being closed once done: no global session is kept open.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,617: Line 1,694:
! Cmd || Name
! Cmd || Name
|-
|-
| 1 || [[#GetBusHandle]]
| 0 || [[#Write]]
|}
 
=== Write ===
This is the inverse of [[#IReadSession]] cmd0. Uses the OUTPUT endpoint with an input buffer.
 
= ahid:hdr =
This is "nn::ahid::hdr::ISession".
 
Used internally for USB HID devices.
 
This service no longer exists in [9.0.0+].
 
{| class="wikitable" border="1"
|-
|-
| 2 || [[#IsExternalDeviceConnected]]
! Cmd || Name
|-
|-
| 3 || [[#Initialize]]
| 0 || GetDeviceEntries
|-
|-
| 4 || [[#Finalize]]
| 1 || GetDeviceList
|-
|-
| 5 || [[#EnableExternalDevice]]
| 2 || GetDeviceParameters
|-
|-
| 6 || [[#GetExternalDeviceId]]
| 3 || AttachDevice
|-
|-
| 7 || [[#SendCommandAsync]]
| 4 || DetachDevice
|-
|-
| 8 || [[#GetSendCommandAsynceResult]]
| 5 || [6.0.0+] SetDeviceFilter
|-
|}
| 9 || [[#SetEventForSendCommandAsycResult]]
 
= xcd:sys =
This is "nn::xcd::detail::ISystemServer".
 
{| class="wikitable" border="1"
|-
! Cmd || Name
|-
| 0 || GetDataFormat
|-
| 1 || SetDataFormat
|-
| 2 || GetMcuState
|-
|-
| 10 || [[#GetSharedMemoryHandle]]
| 3 || SetMcuState
|-
|-
| 11 || [[#EnableJoyPollingReceiveMode]]
| 4 || GetMcuVersionForNfc
|-
|-
| 12 || [[#DisableJoyPollingReceiveMode]]
| 5 || CheckNfcDevicePower
|-
|-
| 13 || [5.0.0-6.2.0] GetPollingData
| 6 || [5.0.0+] SetMcuStateImmediate
|-
|-
| 14 || [6.0.0+] [[#SetStatusManagerType]]
| 10 || SetNfcEvent
|}
|-
 
| 11 || GetNfcInfo
sdknso doesn't use the GetPollingData cmd.
|-
 
| 12 || StartNfcDiscovery
== GetBusHandle ==
|-
Takes an input u32 [[#NpadIdType]], an u64 [[#BusType]], an u64 [[AM_services|AppletResourceUserId]], returns an output u8 bool and a [[#BusHandle]].
| 13 || StopNfcDiscovery
 
|-
The bool indicates whether the [[#BusHandle]] is valid.
| 14 || StartNtagRead
|-
| 15 || StartNtagWrite
|-
| 16 || SendNfcRawData
|-
| 17 || RegisterMifareKey
|-
| 18 || ClearMifareKey
|-
| 19 || StartMifareRead
|-
| 20 || StartMifareWrite
|-
| 101 || GetAwakeTriggerReasonForLeftRail
|-
| 102 || GetAwakeTriggerReasonForRightRail
|}


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.
[5.0.0+] SetDataFormat, SetMcuState, and ClearMifareKey: now takes a total of 0xC-bytes of input instead of 0x10.


This cmd will throw an error when [[#BusType]] is invalid.
[6.0.0+]: The buffer type used by GetNfcInfo is now 0x32 instead of 0x1A.


== IsExternalDeviceConnected ==
= hidbus =
Takes an input [[#BusHandle]], returns an output u8 bool.
This is "nn::hidbus::IHidbusServer".


This is not used by sdknso.
This was added with [5.0.0+].


== Initialize ==
Official sw opens a temporary service-session for each func using this, with it being closed once done: no global session is kept open.
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.


Prior to using this cmd, sdknso handles [[#GetSharedMemoryHandle|sharedmem]] mapping if not done previously.
{| class="wikitable" border="1"
 
|-
== Finalize ==
! Cmd || Name
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.
|-
 
| 1 || [[#GetBusHandle]]
== EnableExternalDevice ==
|-
Takes an input u8 bool, a [[#BusHandle]], an u64, an u64 [[AM_services|AppletResourceUserId]], no output.
| 2 || [[#IsExternalDeviceConnected]]
 
|-
sdknso passes value 0x38900050018 (0x3A600050018 with 7.x+) for the u64.
| 3 || [[#Initialize]]
|-
| 4 || [[#Finalize]]
|-
| 5 || [[#EnableExternalDevice]]
|-
| 6 || [[#GetExternalDeviceId]]
|-
| 7 || [[#SendCommandAsync]]
|-
| 8 || [[#GetSendCommandAsynceResult]]
|-
| 9 || [[#SetEventForSendCommandAsycResult]]
|-
| 10 || [[#GetSharedMemoryHandle]]
|-
| 11 || [[#EnableJoyPollingReceiveMode]]
|-
| 12 || [[#DisableJoyPollingReceiveMode]]
|-
| 13 || [5.0.0-6.2.0] GetPollingData
|-
| 14 || [6.0.0+] [[#SetStatusManagerType]]
|}


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


== GetExternalDeviceId ==
== GetBusHandle ==
Takes an input [[#BusHandle]], returns an output u32 ExternalDeviceId.
Takes an input u32 [[#NpadIdType]], an u64 [[#BusType]], an u64 [[AM_services|AppletResourceUserId]], returns an output u8 bool and a [[#BusHandle]].
 
The bool 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.
 
This cmd will throw an error when [[#BusType]] is invalid.
 
== IsExternalDeviceConnected ==
Takes an input [[#BusHandle]], returns an output u8 bool.
 
This is not used by sdknso.
 
== Initialize ==
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.
 
Prior to using this cmd, sdknso handles [[#GetSharedMemoryHandle|sharedmem]] mapping if not done previously.
 
== Finalize ==
Takes an input [[#BusHandle]], an u64 [[AM_services|AppletResourceUserId]], no output.
 
== EnableExternalDevice ==
Takes an input u8 bool, a [[#BusHandle]], an u64, an u64 [[AM_services|AppletResourceUserId]], no output.
 
sdknso passes value 0x38900050018 (0x3A600050018 with 7.x+) for the u64.
 
The bool flag indicates whether to enable the device (true = enable, false = disable).  When false, this will use [[#DisableJoyPollingReceiveMode]] if needed.
 
== GetExternalDeviceId ==
Takes an input [[#BusHandle]], returns an output u32 ExternalDeviceId.


== SendCommandAsync ==
== SendCommandAsync ==
Line 2,494: Line 2,664:


= IrCameraHandle =
= IrCameraHandle =
This is "nn::irsensor::IrCameraHandle". This is an u32.
This is "nn::irsensor::IrCameraHandle".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,508: Line 2,678:


= IrCameraStatus =
= IrCameraStatus =
This is "nn::irsensor::IrCameraStatus". This is an u32.
This is "nn::irsensor::IrCameraStatus".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,522: Line 2,692:


= IrCameraInternalStatus =
= IrCameraInternalStatus =
This is "nn::irsensor::IrCameraInternalStatus". This is an u32.
This is "nn::irsensor::IrCameraInternalStatus".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,548: Line 2,718:


= IrSensorMode =
= IrSensorMode =
This is "nn::irsensor::detail::StatusManager::IrSensorMode". This is an u32.
This is "nn::irsensor::detail::StatusManager::IrSensorMode".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,562: Line 2,732:
| 3 || [[#ImageTransferProcessorState|ImageTransferProcessor]]
| 3 || [[#ImageTransferProcessorState|ImageTransferProcessor]]
|-
|-
| 4 || [[#PointingProcessorState|PointingProcessor]]
| 4 || [[#PointingProcessorMarkerState|PointingProcessorMarker]]
|-
|-
| 5 || [[#TeraPluginProcessorState|TeraPluginProcessor]]
| 5 || [[#TeraPluginProcessorState|TeraPluginProcessor]]
Line 2,570: Line 2,740:


= ImageProcessorStatus =
= ImageProcessorStatus =
This is "nn::irsensor::ImageProcessorStatus". This is an u32.
This is "nn::irsensor::ImageProcessorStatus".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,582: Line 2,752:


= ImageTransferProcessorFormat =
= ImageTransferProcessorFormat =
This is "nn::irsensor::ImageTransferProcessorFormat". This is an u32.
This is "nn::irsensor::ImageTransferProcessorFormat".


This controls the IR Sensor image resolution.
This controls the IR Sensor image resolution.
Line 2,632: Line 2,802:


= PackedMomentProcessorConfig =
= PackedMomentProcessorConfig =
This is "nn::irsensor::PackedMomentProcessorConfig". This is a 0x20-byte struct.  
This is "nn::irsensor::PackedMomentProcessorConfig".


This is converted from [[#MomentProcessorConfig]].
This is converted from [[#MomentProcessorConfig]].
Line 2,702: Line 2,872:


= PackedClusteringProcessorConfig =
= PackedClusteringProcessorConfig =
This is "nn::irsensor::PackedClusteringProcessorConfig". This is a 0x28-byte struct.
This is "nn::irsensor::PackedClusteringProcessorConfig".


This is converted from [[#ClusteringProcessorConfig]].
This is converted from [[#ClusteringProcessorConfig]].
Line 2,762: Line 2,932:


= PackedImageTransferProcessorConfig =
= PackedImageTransferProcessorConfig =
This is "nn::irsensor::PackedImageTransferProcessorConfig". This is a 0x18-byte struct.
This is "nn::irsensor::PackedImageTransferProcessorConfig".


This is converted from [[#ImageTransferProcessorConfig]].
This is converted from [[#ImageTransferProcessorConfig]].
Line 2,788: Line 2,958:


= ImageTransferProcessorState =
= ImageTransferProcessorState =
This is "nn::irsensor::ImageTransferProcessorState". This is a 0x10-byte struct.
This is "nn::irsensor::ImageTransferProcessorState".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,796: Line 2,966:
| 0x0 || 0x8 || SamplingNumber
| 0x0 || 0x8 || SamplingNumber
|-
|-
| 0x8 || 0x1 || AmbientNoiseLevel
| 0x8 || 0x4 || AmbientNoiseLevel
|-
|-
| 0x9 || 0x7 || Reserved
| 0xC || 0x4 || Reserved
|}
|}


Line 2,818: Line 2,988:


= PackedTeraPluginProcessorConfig =
= PackedTeraPluginProcessorConfig =
This is "nn::irsensor::PackedTeraPluginProcessorConfig". This is a 0x8-byte struct.
This is "nn::irsensor::PackedTeraPluginProcessorConfig".


This is converted from [[#TeraPluginProcessorConfig]]. The data starting at offset 0x5 is only initialized by the user-process with [6.0.0+].
This is converted from [[#TeraPluginProcessorConfig]]. The data starting at offset 0x5 is only initialized by the user-process with [6.0.0+].
Line 2,837: Line 3,007:
|-
|-
| 0x7 || 0x1 ||  
| 0x7 || 0x1 ||  
|}
= PointingProcessorConfig =
This is "nn::irsensor::PointingProcessorConfig".
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x2 || WindowOfInterestX (default is 0)
|-
| 0x2 || 0x2 || WindowOfInterestY (default is 0)
|-
| 0x4 || 0x2 || WindowOfInterestWidth (default is 320)
|-
| 0x6 || 0x2 || WindowOfInterestHeight (default is 240)
|}
|}


= PackedPointingProcessorConfig =
= PackedPointingProcessorConfig =
This is "nn::irsensor::PackedPointingProcessorConfig". This is a 0xC-byte struct.
This is "nn::irsensor::PackedPointingProcessorConfig".
 
This is converted from [[#PointingProcessorConfig]].


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,846: Line 3,034:
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x2 || WindowOfInterestX? (default is 0)
| 0x0 || 0x2 || WindowOfInterestX (default is 0)
|-
|-
| 0x2 || 0x2 || WindowOfInterestY? (default is 0)
| 0x2 || 0x2 || WindowOfInterestY (default is 0)
|-
|-
| 0x4 || 0x2 || WindowOfInterestWidth? (default is 320)
| 0x4 || 0x2 || WindowOfInterestWidth (default is 320)
|-
|-
| 0x6 || 0x2 || WindowOfInterestHeight? (default is 240)
| 0x6 || 0x2 || WindowOfInterestHeight (default is 240)
|-
|-
| 0x8 || 0x4 || [[#PackedMcuVersion|RequiredMcuVersion]]
| 0x8 || 0x4 || [[#PackedMcuVersion|RequiredMcuVersion]]
Line 2,858: Line 3,046:


= PackedMcuVersion =
= PackedMcuVersion =
This is "nn::irsensor::PackedMcuVersion". This is an u32.
This is "nn::irsensor::PackedMcuVersion".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,886: Line 3,074:


= PackedFunctionLevel =
= PackedFunctionLevel =
This is nn::irsensor::PackedFunctionLevel. This is an u32.
This is nn::irsensor::PackedFunctionLevel.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,944: Line 3,132:


= PackedImageTransferProcessorExConfig =
= PackedImageTransferProcessorExConfig =
This is "nn::irsensor::PackedImageTransferProcessorExConfig". This is a 0x20-byte struct.
This is "nn::irsensor::PackedImageTransferProcessorExConfig".


This is converted from [[#ImageTransferProcessorExConfig]].
This is converted from [[#ImageTransferProcessorExConfig]].
Line 2,977: Line 3,165:
|}
|}


= PackedIrLedProcessorConfig =
= IrLedProcessorConfig =
This is "nn::irsensor::PackedIrLedProcessorConfig". This is a 0x8-byte struct.
This is "nn::irsensor::IrLedProcessorConfig".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,984: Line 3,172:
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x4 || [[#PackedMcuVersion|RequiredMcuVersion]]
| 0x0 || 0x4 || LightTarget
|-
| 0x4 || 0x4 ||
|}
|}


= BusHandle =
= PackedIrLedProcessorConfig =
This is "nn::hidbus::BusHandle". This is 0x8-bytes.
This is "nn::irsensor::PackedIrLedProcessorConfig".
 
This is converted from [[#IrLedProcessorConfig]].


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 2,996: Line 3,184:
! Offset || Size || Description
! Offset || Size || Description
|-
|-
| 0x0 || 0x4 || AbstractedPadId
| 0x0 || 0x4 || [[#PackedMcuVersion|RequiredMcuVersion]]
|-
|-
| 0x4 || 0x1 || InternalIndex
| 0x4 || 0x1 || LightTarget
|-
|-
| 0x5 || 0x1 || PlayerNumber
| 0x5 || 0x3 || Padding
|-
| 0x6 || 0x1 || BusTypeId
|-
| 0x7 || 0x1 || IsValid
|}
|}


= JoyPollingReceivedData =
= AdaptiveClusteringProcessorConfig =
This is "nn::hidbus::JoyPollingReceivedData". This is 0x40-bytes.
This is "nn::irsensor::AdaptiveClusteringProcessorConfig".
 
AdaptiveClusteringProcessor was added with [5.0.0+].


This is copied from the entries in [[#EnableJoyPollingReceiveMode|TransferMemory]] by GetJoyPollingReceivedData.
This is converted to [[#TeraPluginProcessorConfig]] by the user-process. [[#TeraPluginProcessorConfig]]+0x3 is zero.
 
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x4 || [[#AdaptiveClusteringMode]]
|-
| 0x4 || 0x4 || [6.0.0+] [[#AdaptiveClusteringTargetDistance]]
|}
 
== AdaptiveClusteringMode ==
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || StaticFov
|-
| 1 || DynamicFov
|}
 
Controls the mode for [[#TeraPluginProcessorConfig]] (DynamicFov -> 0x10; StaticFov -> 0x0F).
 
== AdaptiveClusteringTargetDistance ==
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || Near
|-
| 1 || Middle
|-
| 2 || Far
|}
 
Controls the second and third bytes for [[#TeraPluginProcessorConfig]] (Near-> 0x00, 0x00; Middle -> 0x01, 0x03; Far -> 0x01, 0x08).
 
= HandAnalysisConfig =
This is "nn::irsensor::HandAnalysisConfig".
 
This is converted to [[#TeraPluginProcessorConfig]] by the user-process, which is all-zero except the mode.
* pre-4.0.0: [[#TeraPluginProcessorConfig]] mode = [[#HandAnalysisMode]] - 1.
* [4.0.0+]: Silhouette = 0x5, Image = 0x6, SilhouetteAndImage = 0x7, SilhouetteOnly = 0xA.
 
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x4 || [[#HandAnalysisMode]]
|}
 
== HandAnalysisMode ==
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || None (invalid)
|-
| 1 || Silhouette
|-
| 2 || Image
|-
| 3 || SilhouetteAndImage
|-
| 4 || [4.0.0+] SilhouetteOnly
|}
 
= BusHandle =
This is "nn::hidbus::BusHandle".
 
{| class="wikitable" border="1"
|-
! Offset || Size || Description
|-
| 0x0 || 0x4 || AbstractedPadId
|-
| 0x4 || 0x1 || InternalIndex
|-
| 0x5 || 0x1 || PlayerNumber
|-
| 0x6 || 0x1 || BusTypeId
|-
| 0x7 || 0x1 || IsValid
|}
 
= JoyPollingReceivedData =
This is "nn::hidbus::JoyPollingReceivedData".
 
This is copied from the entries in [[#EnableJoyPollingReceiveMode|TransferMemory]] by GetJoyPollingReceivedData.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 3,017: Line 3,291:
|-
|-
| 0x0 || 0x30 || Data
| 0x0 || 0x30 || Data
|-
|-
| 0x30 || 0x8 || Size of data.
| 0x30 || 0x8 || Size of data.
|-
|-
| 0x38 || 0x8 || Timestamp
| 0x38 || 0x8 || Timestamp
|}
 
= BusType =
This is "nn::hidbus::BusType".
 
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || JoyLeftRail
|-
| 1 || JoyRightRail
|-
| 2 || [6.0.0+] LarkRightRail (for microphone)
|}
 
= JoyPollingMode =
This is "nn::hidbus::JoyPollingMode".
 
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || sdknso uses <code>GetJoyDisableSixAxisPollingDataAccessor</code> with this.
|-
| 1 || sdknso uses <code>GetJoyEnableSixAxisPollingDataAccessor</code> with this.
|-
| 2 || [6.0.0+] sdknso uses <code>GetJoyButtonOnlyPollingDataAccessor</code> with this.
|}
|}


= BusType =
Other values causes [[#EnableJoyPollingReceiveMode]] to assert.
This is "nn::hidbus::BusType". This is an u32.
 
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || JoyLeftRail
|-
| 1 || JoyRightRail
|-
| 2 || [6.0.0+] LarkRightRail (for microphone)
|}
 
= JoyPollingMode =
This is "nn::hidbus::JoyPollingMode". This is an u32. This must be one of the below values otherwise [[#EnableJoyPollingReceiveMode]] will assert.
 
{| class="wikitable" border="1"
!  Value
!  Description
|-
| 0 || sdknso uses <code>GetJoyDisableSixAxisPollingDataAccessor</code> with this.
|-
| 1 || sdknso uses <code>GetJoyEnableSixAxisPollingDataAccessor</code> with this.
|-
| 2 || [6.0.0+] sdknso uses <code>GetJoyButtonOnlyPollingDataAccessor</code> with this.
|}


= ExternalDevices =
= ExternalDevices =