Controller Applet

Revision as of 00:40, 27 November 2019 by Yellows8 (talk | contribs) (Created page with "This is the controller applet which can be launched by Home Menu. Official sw uses this under <code>nn::hid</code>, and <code>nn::hid::system</code> with the "ForSystem" funcs...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the controller applet which can be launched by Home Menu. Official sw uses this under nn::hid, and nn::hid::system with the "ForSystem" funcs. See AM_services#Library_Applets.

Library Applet Versions

System Version Value
[1.0.0+] 0x3
[3.0.0+] 0x4
[6.0.0+] 0x5
[8.0.0+] 0x7

ControllerSupportArgPrivate

This is "nn::hid::system::ControllerSupportArgPrivate". This is a 0x14-byte struct pushed for input storage. The data here is setup by sdknso internally without exposing it to the user.

PlayStartupSound is set to (Flag1 != 0) & (Flag0 != 0).

Offset Size Description
0x0 0x4 Size of this ControllerSupportArgPrivate struct.
0x4 0x4 Size of the storage following this one (#ControllerSupportArg or #ControllerFirmwareUpdateArg).
0x8 0x1 Flag0
0x9 0x1 Flag1
0xA 0x1 #Type
0xB 0x1 nn::hid::system::ControllerSupportCaller, the default is value 0.
0xC 0x4 Output from GetSupportedNpadStyleSet.
0x10 0x4 Output from GetNpadJoyHoldType.

ControllerSupportArg

This is "nn::hid::ControllerSupportArg". This is a 0x21C-byte (0x430-byte with version 0x7) struct pushed for input storage.

Layout with the original version:

Offset Size Description
0x0 0x18 ?

Layout starting with version 0x7:

Offset Size Description
0x0 0x28 ?

With both versions, the rest of the struct is an array containing 0x81-byte entries. With the original version there's 4 entries allocated, starting with version 0x7 there's 8 entries allocated. This contains the ExplainText string which includes the NUL-terminator. Each entry corresponds to a controller NpadId, starting with NpadId/controller 0.

Regardless of version, the default data for this struct is setup by setting u32 +0 to 0x01010400, u8 +4 to 0x1, with the rest being cleared as needed. sdknso itself only calls the func for this from ShowControllerStrapGuide, since that's the only time sdknso itself writes to ControllerSupportArg besides ExplainText (and is also the only case where the ControllerSupportArg is not user-specified).

ControllerFirmwareUpdateArg

This is "nn::hid::ControllerFirmwareUpdateArg". This is a 4-byte struct pushed for the input storage. The default value is 0.

Type

Name Type value Description

ControllerSupportResultInfo

This is "nn::hid::ControllerSupportResultInfo". This is a 8-byte struct.

Usage

User-processes should push a common arguments struct, an #ControllerSupportArgPrivate, then #ControllerSupportArg or #ControllerFirmwareUpdateArg.

On success, an output storage should be popped, with size 0xC being used to read from there (sdknso ignores the actual storage size). When #ControllerSupportArg was previously used, the first 8-bytes are copied to the output #ControllerSupportResultInfo (which the user can ignore), otherwise it's ignored. The remaining u32 determines the Result: