Changes

no edit summary
Line 500: Line 500:  
| 0x2
 
| 0x2
 
| 0x8
 
| 0x8
| MotorData
+
| [[#HidMotorData|MotorData]]
 
|-
 
|-
 
| 0xA
 
| 0xA
Line 530: Line 530:  
| 0x2
 
| 0x2
 
| 0x8
 
| 0x8
| MotorData
+
| [[#HidMotorData|MotorData]]
 
|-
 
|-
 
| 0xA
 
| 0xA
Line 556: Line 556:  
| 0x2
 
| 0x2
 
| 0x8
 
| 0x8
| MotorData
+
| [[#HidMotorData|MotorData]]
 
|}
 
|}
   Line 578: Line 578:  
| 0x2
 
| 0x2
 
| 0x8
 
| 0x8
| MotorData
+
| [[#HidMotorData|MotorData]]
 
|-
 
|-
 
| 0xA
 
| 0xA
Line 604: Line 604:  
| 0x2
 
| 0x2
 
| 0x8
 
| 0x8
| MotorData
+
| [[#HidMotorData|MotorData]]
 
|-
 
|-
 
| 0xA
 
| 0xA
Line 657: Line 657:  
|-
 
|-
 
| 0x82 ||  
 
| 0x82 ||  
 +
|}
 +
 +
== HidMotorData ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || [[#VibrationAmFmPackTag|JoyLeftVibrationAmFmPackTag]]
 +
|-
 +
| 0x4 || 0x8 || [[#VibrationAmFmPackTag|JoyRightVibrationAmFmPackTag]]
 +
|}
 +
 +
== VibrationAmFmPackTag ==
 +
This is "nn::xcd::VibrationAmFmPackTag". This is a BitPack object.
 +
 +
=== VibrationAmFmPackFormatZero ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0-29 || Reserved
 +
|-
 +
| 30-31 || PackFormat (must be 0)
 +
|}
 +
 +
=== VibrationAmFmPackFormatOne ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0-19 || Reserved
 +
|-
 +
| 20-24 || ChannelCodesHigh
 +
|-
 +
| 25-29 || ChannelCodesLow
 +
|-
 +
| 30-31 || PackFormat (must be 1)
 +
|}
 +
 +
=== VibrationAmFmPackFormatOne28bit ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0-1 || Reserved
 +
|-
 +
| 2-8 || ChannelFrequencyHigh
 +
|-
 +
| 9-15 || ChannelAmplitudeHigh
 +
|-
 +
| 16-22 || ChannelFrequencyLow
 +
|-
 +
| 23-29 || ChannelAmplitudeLow
 +
|-
 +
| 30-31 || PackFormat (must be 1)
 +
|}
 +
 +
=== VibrationAmFmPackFormatTwo ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0-9 || Reserved
 +
|-
 +
| 10-14 || VibrationCodesHigh
 +
|-
 +
| 15-19 || VibrationCodesLow
 +
|-
 +
| 20-24 || ChannelCodesHigh
 +
|-
 +
| 25-29 || ChannelCodesLow
 +
|-
 +
| 30-31 || PackFormat (must be 2)
 +
|}
 +
 +
=== VibrationAmFmPackFormatTwo14bitLow ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0 || IsChannelHigh (must be 0)
 +
|-
 +
| 1-7 || ChannelFrequency
 +
|-
 +
| 8-12 || VibrationCodesHigh1
 +
|-
 +
| 13-17 || VibrationCodesLow1
 +
|-
 +
| 18-22 || VibrationCodesHigh0
 +
|-
 +
| 23-29 || ChannelAmplitude
 +
|-
 +
| 30-31 || PackFormat (must be 2)
 +
|}
 +
 +
=== VibrationAmFmPackFormatTwo14bitHigh ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0 || IsChannelHigh (must be 1)
 +
|-
 +
| 1-7 || ChannelFrequency
 +
|-
 +
| 8-12 || VibrationCodesHigh1
 +
|-
 +
| 13-17 || VibrationCodesLow1
 +
|-
 +
| 18-22 || VibrationCodesLow0
 +
|-
 +
| 23-29 || ChannelAmplitude
 +
|-
 +
| 30-31 || PackFormat (must be 2)
 +
|}
 +
 +
=== VibrationAmFmPackFormatThree ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0-4 || VibrationCodesHigh1
 +
|-
 +
| 5-9 || VibrationCodesLow1
 +
|-
 +
| 10-14 || VibrationCodesHigh0
 +
|-
 +
| 15-19 || VibrationCodesLow0
 +
|-
 +
| 20-24 || ChannelCodesHigh
 +
|-
 +
| 25-29 || ChannelCodesLow
 +
|-
 +
| 30-31 || PackFormat (must be 3)
 +
|}
 +
 +
=== VibrationAmFmPackFormatThree7bit ===
 +
{| class="wikitable" border="1"
 +
! Bits
 +
! Description
 +
|-
 +
| 0 || IsChannelHigh
 +
|-
 +
| 1 || IsThree7bit (must be 1)
 +
|-
 +
| 2 || IsFm
 +
|-
 +
| 3-7 || VibrationCodesHigh1
 +
|-
 +
| 8-12 || VibrationCodesLow1
 +
|-
 +
| 13-17 || VibrationCodesHigh0
 +
|-
 +
| 18-22 || VibrationCodesLow0
 +
|-
 +
| 23-29 || ChannelAmFm
 +
|-
 +
| 30-31 || PackFormat (must be 1, instead of 3)
 +
|}
 +
 +
== AmFmCodes ==
 +
These are 32-bit values used by the Joy-Con firmware to represent combinations of amplitude/frequency pairs for vibration.
 +
 +
=== Unpacking ===
 +
The Joy-Con firmware receives vibration data packed as [[#VibrationAmFmPackTag|VibrationAmFmPackTag]] from output reports. Depending on the packing format, these tags are then converted to an array of AmFmCodes as follows.
 +
 +
==== AmFm5BitCodes ====
 +
Converted from [[#VibrationAmFmPackFormatOne|VibrationAmFmPackFormatOne]], [[#VibrationAmFmPackFormatTwo|VibrationAmFmPackFormatTwo]] or [[#VibrationAmFmPackFormatThree|VibrationAmFmPackFormatThree]].
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || <nowiki>(ChannelCodesLow & 0x1F)</nowiki>
 +
|-
 +
| 0x4 || 0x4 || <nowiki>(ChannelCodesHigh & 0x1F)</nowiki>
 +
|-
 +
| 0x8 || 0x4 || <nowiki>(VibrationCodesLow0 & 0x1F)</nowiki>
 +
|-
 +
| 0xC || 0x4 || <nowiki>(VibrationCodesHigh0 & 0x1F)</nowiki>
 +
|-
 +
| 0x10 || 0x4 || <nowiki>(VibrationCodesLow1 & 0x1F)</nowiki>
 +
|-
 +
| 0x14 || 0x4 || <nowiki>(VibrationCodesHigh1 & 0x1F)</nowiki>
 +
|}
 +
 +
==== AmFm7BitOneCodes ====
 +
Converted from [[#VibrationAmFmPackFormatOne28bit|VibrationAmFmPackFormatOne28bit]].
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || <nowiki>(((ChannelFrequencyLow & 0x7F) << 8) | (ChannelAmplitudeLow & 0x7F) | 0x8080)</nowiki>
 +
|-
 +
| 0x4 || 0x4 || <nowiki>(((ChannelFrequencyHigh & 0x7F) << 8) | (ChannelAmplitudeHigh & 0x7F) | 0x8080)</nowiki>
 +
|}
 +
 +
==== AmFm7BitTwoCodes ====
 +
Converted from [[#VibrationAmFmPackFormatTwo14bitLow|VibrationAmFmPackFormatTwo14bitLow]] or [[#VibrationAmFmPackFormatTwo14bitHigh|VibrationAmFmPackFormatTwo14bitHigh]].
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || <nowiki>IsChannelHigh ? (VibrationCodesLow0 & 0x1F) : (((ChannelFrequency & 0x7F) << 8) | (ChannelAmplitude & 0x7F) | 0x8080)</nowiki>
 +
|-
 +
| 0x4 || 0x4 || <nowiki>IsChannelHigh ? (((ChannelFrequency & 0x7F) << 8) | (ChannelAmplitude & 0x7F) | 0x8080) : (VibrationCodesHigh0 & 0x1F)</nowiki>
 +
|-
 +
| 0x8 || 0x4 || <nowiki>(VibrationCodesLow1 & 0x1F)</nowiki>
 +
|-
 +
| 0xC || 0x4 || <nowiki>(VibrationCodesHigh1 & 0x1F)</nowiki>
 +
|-
 +
| 0x10 || 0x4 || <nowiki>Always 0x18</nowiki>
 +
|-
 +
| 0x14 || 0x4 || <nowiki>Always 0x18</nowiki>
 +
|}
 +
 +
==== AmFm7BitThreeCodes ====
 +
Converted from [[#VibrationAmFmPackFormatThree7bit|VibrationAmFmPackFormatThree7bit]].
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || <nowiki>IsChannelHigh ? 0x18 : (IsFm ? (((ChannelAmFm & 0x7F) << 8) | 0x8000) : ((ChannelAmFm & 0x7F) | 0x80))</nowiki>
 +
|-
 +
| 0x4 || 0x4 || <nowiki>IsChannelHigh ? (IsFm ? (((ChannelAmFm & 0x7F) << 8) | 0x8000) : ((ChannelAmFm & 0x7F) | 0x80)) : 0x18</nowiki>
 +
|-
 +
| 0x8 || 0x4 || <nowiki>(VibrationCodesLow0 & 0x1F)</nowiki>
 +
|-
 +
| 0xC || 0x4 || <nowiki>(VibrationCodesHigh0 & 0x1F)</nowiki>
 +
|-
 +
| 0x10 || 0x4 || <nowiki>(VibrationCodesLow1 & 0x1F)</nowiki>
 +
|-
 +
| 0x14 || 0x4 || <nowiki>(VibrationCodesHigh1 & 0x1F)</nowiki>
 
|}
 
|}