Changes

3,004 bytes removed ,  21:08, 22 September 2022
no edit summary
Line 1,893: Line 1,893:  
The specified controller must have a HOME button.
 
The specified controller must have a HOME button.
   −
This sends subcommand 0x38 to the specified controller, for setting the pattern for the HOME button notification LED. The input structure is converted to the format used by this [https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x38-set-home-light subcommand].
+
This sends [https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x38-set-home-light subcommand 0x38] to the specified controller, for setting the pattern for the HOME button notification LED. The input structure is converted to the format as follows: <code>((u8*)cmd_argdata)[pos] = u8_in[pos2] | u8_in[pos3]<<4;</code> Hence, 4bits from pairs of 2-bytes of the input struct are combined to write to the subcommand. Only the low 4bits of each used byte in the struct is used. This is written to stack initially, then copied to the actual cmd_argdata (the data immediately following the subcommandID byte). There's a total of 0x1C-bytes of cmd_argdata initialized from this.
 +
 
 +
The layout of cmd_argdata is as follows:
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x1 || <nowiki>((TimeUnit & 0xF) | ((FrameCount & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x1 || 0x1 || <nowiki>((CycleCount & 0xF) | ((InitialBrightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x2 || 0x1 || <nowiki>((Frame2Brightness & 0xF) | ((Frame1Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x3 || 0x1 || <nowiki>((Frame1TimeToHold & 0xF) | ((Frame1TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x4 || 0x1 || <nowiki>((Frame2TimeToHold & 0xF) | ((Frame2TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x5 || 0x1 || <nowiki>((Frame4Brightness & 0xF) | ((Frame3Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x6 || 0x1 || <nowiki>((Frame3TimeToHold & 0xF) | ((Frame3TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x7 || 0x1 || <nowiki>((Frame4TimeToHold & 0xF) | ((Frame4TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x8 || 0x1 || <nowiki>((Frame6Brightness & 0xF) | ((Frame5Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x9 || 0x1 || <nowiki>((Frame5TimeToHold & 0xF) | ((Frame5TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xA || 0x1 || <nowiki>((Frame6TimeToHold & 0xF) | ((Frame6TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xB || 0x1 || <nowiki>((Frame8Brightness & 0xF) | ((Frame7Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xC || 0x1 || <nowiki>((Frame7TimeToHold & 0xF) | ((Frame7TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xD || 0x1 || <nowiki>((Frame8TimeToHold & 0xF) | ((Frame8TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xE || 0x1 || <nowiki>((Frame10Brightness & 0xF) | ((Frame9Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0xF || 0x1 || <nowiki>((Frame9TimeToHold & 0xF) | ((Frame9TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x10 || 0x1 || <nowiki>((Frame10TimeToHold & 0xF) | ((Frame10TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x11 || 0x1 || <nowiki>((Frame12Brightness & 0xF) | ((Frame11Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x12 || 0x1 || <nowiki>((Frame11TimeToHold & 0xF) | ((Frame11TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x13 || 0x1 || <nowiki>((Frame12TimeToHold & 0xF) | ((Frame12TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x14 || 0x1 || <nowiki>((Frame14Brightness & 0xF) | ((Frame13Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x15 || 0x1 || <nowiki>((Frame13TimeToHold & 0xF) | ((Frame13TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x16 || 0x1 || <nowiki>((Frame14TimeToHold & 0xF) | ((Frame14TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x17 || 0x1 || <nowiki>((Reserved & 0xF) | ((Frame15Brightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x18 || 0x1 || <nowiki>((Frame15TimeToHold & 0xF) | ((Frame15TimeTowards & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x19 || 0x1 || <nowiki>((Reserved & 0xF) | ((Reserved & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x1A || 0x1 || <nowiki>((TimeTowardsFinalBrightness & 0xF) | ((FinalBrightness & 0xF) << 4))</nowiki>
 +
|-
 +
| 0x1B || 0x1 || <nowiki>(Timeout & 0xFF)</nowiki>
 +
|-
 +
| 0x1C || 0x1 || <nowiki>((Timeout >> 8) & 0xFF)</nowiki>
 +
|}
    
[9.0.0+] This runs code similar to [[#SetNotificationLedPatternWithTimeout]], except it passes the following param values to an internal func: flag=1 and TimeSpan=0 (with [[#SetNotificationLedPatternWithTimeout]] these are flag=0 and TimeSpan={input value}).
 
[9.0.0+] This runs code similar to [[#SetNotificationLedPatternWithTimeout]], except it passes the following param values to an internal func: flag=1 and TimeSpan=0 (with [[#SetNotificationLedPatternWithTimeout]] these are flag=0 and TimeSpan={input value}).
Line 8,343: Line 8,407:  
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset || Size || Subcommand argdata bytepos || Subcommand argdata nibble || Description
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0x0 || 0x1 || 0x0 || Low || Mini Cycle Base Duration. Value 0x1-0xF: 12.5ms - 187.5ms. Value 0x0 = 0ms/OFF.
+
| 0x0
 +
| 0x1
 +
| TimeUnit
 
|-
 
|-
| 0x1 || 0x1 || 0x0 || High || Number of Mini Cycles + 1. Value 0x0-0xF: 1 - 16 mini cycles.
+
| 0x1
 +
| 0x1
 +
| FrameCount
 
|-
 
|-
| 0x2 || 0x1 || 0x1 || Low || Number of Full Cycles. Value 0x1-0xF: 1 - 15 full cycles. Value 0x0 is repeat forever, but if Mini Cycle Base Duration is set to 0x0, it does the 1st Mini Cycle with a 12.5ms base duration and then the LED stays on with LED Start Intensity.
+
| 0x2
 +
| 0x1
 +
| CycleCount
 
|-
 
|-
| 0x3 || 0x1 || 0x1 || High || LED Start Intensity. Value 0x0-0xF: 0% - 100%. (In HW, 1 - 241 duty)
+
| 0x3
 +
| 0x1
 +
| InitialBrightness
 
|-
 
|-
| 0x4 || 0x1 || 0x2 || High || Mini Cycle 1 LED Intensity. Value 0x0-0xF: 0% - 100%. (In HW, 1 - 241 duty)
+
| 0x4
 +
| 0x4 * 15
 +
| [[#Frame|Frames]]
 
|-
 
|-
| 0x5 || 0x1 || 0x3 || High || Fading Transition Steps to Mini Cycle 1 (Uses PWM). Value 0x0: Instant. Each step duration is based on Mini Cycle Step Duration Multiplier.
+
| 0x40
 +
| 0x1
 +
| FinalBrightness
 
|-
 
|-
| 0x6 || 0x1 || 0x3 || Low || Final Step Duration Multiplier of Mini Cycle 1. Value is a Multiplier of Mini Cycle Base Duration. Value 0x0: 12.5ms, 0x1 - xF: 1x - 15x.
+
| 0x41
|-
+
| 0x1
| 0x7 || 0x1 || || || Unused
+
| TimeTowardsFinalBrightness
|-
  −
| 0x8 || 0x1 || 0x2 || Low || Mini Cycle 2 LED Intensity.
  −
|-
  −
| 0x9 || 0x1 || 0x4 || High || Fading Transition Steps to Mini Cycle 2 (see above).
  −
|-
  −
| 0xA || 0x1 || 0x4 || Low || Final Step Duration Multiplier of Mini Cycle 2 (see above).
  −
|-
  −
| 0xB || 0x1 || || || Unused
  −
|-
  −
| 0xC || 0x1 || 0x5 || High || Mini Cycle 3 LED Intensity.
  −
|-
  −
| 0xD || 0x1 || 0x6 || High || Fading Transition Steps to Mini Cycle 3 (see above).
  −
|-
  −
| 0xE || 0x1 || 0x6 || Low || Final Step Duration Multiplier of Mini Cycle 3 (see above).
  −
|-
  −
| 0xF || 0x1 || || || Unused
  −
|-
  −
| 0x10 || 0x1 || 0x5 || Low || Mini Cycle 4 LED Intensity.
  −
|-
  −
| 0x11 || 0x1 || 0x7 || High || Fading Transition Duration to Mini Cycle 4 (see above).
  −
|-
  −
| 0x12 || 0x1 || 0x7 || Low || Final Step Duration Multiplier of Mini Cycle 4 (see above).
  −
|-
  −
| 0x13 || 0x1 || || || Unused
  −
|-
  −
| 0x14 || 0x1 || 0x8 || High || Mini Cycle 5 LED Intensity.
  −
|-
  −
| 0x15 || 0x1 || 0x9 || High || Fading Transition Steps to Mini Cycle 5 (see above).
  −
|-
  −
| 0x16 || 0x1 || 0x9 || Low || Final Step Duration Multiplier of Mini Cycle 5 (see above).
  −
|-
  −
| 0x17 || 0x1 || || || Unused
  −
|-
  −
| 0x18 || 0x1 || 0x8 || Low || Mini Cycle 6 LED Intensity.
  −
|-
  −
| 0x19 || 0x1 || 0xA || High || Fading Transition Steps to Mini Cycle 6 (see above).
  −
|-
  −
| 0x1A || 0x1 || 0xA || Low || Final Step Duration Multiplier of Mini Cycle 6 (see above).
  −
|-
  −
| 0x1B || 0x1 || || || Unused
  −
|-
  −
| 0x1C || 0x1 || 0xB || High || Mini Cycle 7 LED Intensity.
  −
|-
  −
| 0x1D || 0x1 || 0xC || High || Fading Transition Steps  to Mini Cycle 7 (see above).
  −
|-
  −
| 0x1E || 0x1 || 0xC || Low || Final Step Duration Multiplier of Mini Cycle 7 (see above).
  −
|-
  −
| 0x1F || 0x1 || || || Unused
  −
|-
  −
| 0x20 || 0x1 || 0xB || Low || Mini Cycle 8 LED Intensity.
  −
|-
  −
| 0x21 || 0x1 || 0xD || Low || Fading Transition Steps to Mini Cycle 8 (see above).
  −
|-
  −
| 0x22 || 0x1 || 0xD || High || Final Step Duration Multiplier of Mini Cycle 8 (see above).
  −
|-
  −
| 0x23 || 0x1 || || || Unused
  −
|-
  −
| 0x24 || 0x1 || 0xE || High || Mini Cycle 9 LED Intensity.
  −
|-
  −
| 0x25 || 0x1 || 0xF || High || Fading Transition Steps to Mini Cycle 9 (see above).
  −
|-
  −
| 0x26 || 0x1 || 0xF || Low || Final Step Duration Multiplier of Mini Cycle 9 (see above).
  −
|-
  −
| 0x27 || 0x1 || || || Unused
  −
|-
  −
| 0x28 || 0x1 || 0xE || Low || Mini Cycle 10 LED Intensity.
  −
|-
  −
| 0x29 || 0x1 || 0x10 || High || Fading Transition Steps to Mini Cycle 10 (see above).
  −
|-
  −
| 0x2A || 0x1 || 0x10 || Low || Final Step Duration Multiplier of Mini Cycle 10 (see above).
  −
|-
  −
| 0x2B || 0x1 || || || Unused
  −
|-
  −
| 0x2C || 0x1 || 0x11 || High || Mini Cycle 11 LED Intensity.
  −
|-
  −
| 0x2D || 0x1 || 0x12 || High || Fading Transition Steps to Mini Cycle 11 (see above).
  −
|-
  −
| 0x2E || 0x1 || 0x12 || Low || Final Step Duration Multiplier of Mini Cycle 11 (see above).
  −
|-
  −
| 0x2F || 0x1 || || || Unused
  −
|-
  −
| 0x30 || 0x1 || 0x11 || Low || Mini Cycle 12 LED Intensity.
  −
|-
  −
| 0x31 || 0x1 || 0x13 || High || Fading Transition Steps to Mini Cycle 12 (see above).
  −
|-
  −
| 0x32 || 0x1 || 0x13 || Low || Final Step Duration Multiplier of Mini Cycle 12 (see above).
  −
|-
  −
| 0x33 || 0x1 || || || Unused
  −
|-
  −
| 0x34 || 0x1 || 0x14 || High || Mini Cycle 13 LED Intensity.
  −
|-
  −
| 0x35 || 0x1 || 0x15 || High || Fading Transition Steps to Mini Cycle 13 (see above).
  −
|-
  −
| 0x36 || 0x1 || 0x15 || Low || Final Step Duration Multiplier of Mini Cycle 13 (see above).
  −
|-
  −
| 0x37 || 0x1 || || || Unused
  −
|-
  −
| 0x38 || 0x1 || 0x14 || Low || Mini Cycle 14 LED Intensity.
  −
|-
  −
| 0x39 || 0x1 || 0x16 || High || Fading Transition Steps to Mini Cycle 14 (see above).
  −
|-
  −
| 0x3A || 0x1 || 0x16 || Low || Final Step Duration Multiplier of Mini Cycle 14 (see above).
  −
|-
  −
| 0x3B || 0x1 || || || Unused
  −
|-
  −
| 0x3C || 0x1 || 0x17 || High || Mini Cycle 15 LED Intensity.
  −
|-
  −
| 0x3D || 0x1 || 0x18 || High || Fading Transition Steps to Mini Cycle 15 (see above).
  −
|-
  −
| 0x3E || 0x1 || 0x18 || Low || Final Step Duration Multiplier of Mini Cycle 15 (see above).
  −
|-
  −
| 0x3F || 0x1 || || || Unused
  −
|-
  −
| 0x40 || 0x1 || 0x17 || Low || Mini Cycle 16 LED Intensity.
  −
|-
  −
| 0x41 || 0x1 || 0x19 || High || Fading Transition Steps to Mini Cycle 16 (see above). (Unused in older Joy-Con / Pro-Con FW. Unknown for new.)
  −
|-
  −
| 0x42 || 0x1 || 0x19 || Low || Final Step Duration Multiplier of Mini Cycle 16 (see above). (Unused in older Joy-Con / Pro-Con FW. Unknown for new.)
  −
|-
  −
| 0x43 || 0x1 || || || Unused
  −
|-
  −
| 0x44 || 0x1 || 0x1A || High || Unknown (Unused in older Joy-Con / Pro-Con FW. Unknown for new.)
  −
|-
  −
| 0x45 || 0x1 || 0x1A || Low || Unknown (Unused in older Joy-Con / Pro-Con FW. Unknown for new.)
  −
|-
  −
| 0x46 || 0x1 || || || Padding
  −
|-
  −
| 0x47 || 0x1 || || || Padding
   
|-
 
|-
 +
| 0x42
 +
| 0x6
 +
| Reserved
 
|}
 
|}
   −
The above descriptions in the table are based on the info from [https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md here].
+
== Frame ==
 
  −
argdata in the subcommand is initialized as follows: <code>((u8*)cmd_argdata)[pos] = u8_in[pos2] | u8_in[pos3]<<4;</code> Hence, 4bits from pairs of 2-bytes of the input struct are combined to write to the subcommand. Only the low 4bits of each used byte in the struct is used. This is written to stack initially, then copied to the actual cmd_argdata (the data immediately following the subcommandID byte). There's a total of 0x1B-bytes of cmd_argdata initialized from this.
  −
 
  −
The layout of cmd_argdata is as follows:
   
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset || Size || Description
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0x0 || 0x1B || See above.
+
| 0x0
 +
| 0x1
 +
| Brightness
 
|-
 
|-
| 0x1B || 0xB || Cleared to zero.
+
| 0x1
 +
| 0x1
 +
| TimeTowards
 
|-
 
|-
| 0x26 || 0x5 || Unused
+
| 0x2
 +
| 0x1
 +
| TimeToHold
 
|-
 
|-
| 0x2B || 0x8 || Set to an input value, which is hard-coded 0.
+
| 0x3
|-
+
| 0x1
| 0x33 || 0x2 || Set to value 0.
+
| Reserved
|-
  −
| 0x35 || 0x1 || Set to value 1.
   
|}
 
|}