Difference between revisions of "Controller Applet"
(→Type) |
|||
Line 37: | Line 37: | ||
| 0x9 || 0x1 || Flag1 | | 0x9 || 0x1 || Flag1 | ||
|- | |- | ||
− | | 0xA || 0x1 || [[# | + | | 0xA || 0x1 || [[#ControllerSupportMode]] |
|- | |- | ||
− | | 0xB || 0x1 || | + | | 0xB || 0x1 || [[#ControllerSupportCaller]]. Always zero except with ShowControllerFirmwareUpdateForSystem, which sets this to the input param. |
|- | |- | ||
| 0xC || 0x4 || Output from [[HID_services#GetSupportedNpadStyleSet|GetSupportedNpadStyleSet]]. With ShowControllerSupportForSystem on pre-3.0.0 this is value 0. | | 0xC || 0x4 || Output from [[HID_services#GetSupportedNpadStyleSet|GetSupportedNpadStyleSet]]. With ShowControllerSupportForSystem on pre-3.0.0 this is value 0. | ||
Line 94: | Line 94: | ||
|} | |} | ||
− | == | + | == ControllerSupportMode == |
+ | This is "nn::hid::system::ControllerSupportMode". | ||
+ | |||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
|- | |- | ||
Line 111: | Line 113: | ||
ShowControllerFirmwareUpdateForSystem is the same as ShowControllerFirmwareUpdate, except [[#ControllerSupportArgPrivate|Flag1]] is set to 1 and [[#ControllerSupportArgPrivate|ControllerSupportCaller]] is set to the input param. | ShowControllerFirmwareUpdateForSystem is the same as ShowControllerFirmwareUpdate, except [[#ControllerSupportArgPrivate|Flag1]] is set to 1 and [[#ControllerSupportArgPrivate|ControllerSupportCaller]] is set to the input param. | ||
+ | |||
+ | == ControllerSupportCaller == | ||
+ | This is "nn::hid::system::ControllerSupportCaller". | ||
+ | |||
+ | {| class="wikitable" border="1" | ||
+ | |- | ||
+ | ! Value || Description | ||
+ | |- | ||
+ | | 0 || Application | ||
+ | |} | ||
== ControllerSupportResultInfo == | == ControllerSupportResultInfo == |
Revision as of 19:23, 27 November 2019
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 |
---|---|
pre-1.0.0 | <=0x2 |
[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)
. Flag0/Flag1 are always 0 except with *ForSystem funcs in sdknso.
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 | #ControllerSupportMode |
0xB | 0x1 | #ControllerSupportCaller. Always zero except with ShowControllerFirmwareUpdateForSystem, which sets this to the input param. |
0xC | 0x4 | Output from GetSupportedNpadStyleSet. With ShowControllerSupportForSystem on pre-3.0.0 this is value 0. |
0x10 | 0x4 | Output from GetNpadJoyHoldType. With ShowControllerSupportForSystem on pre-3.0.0 this is value 1. |
ControllerSupportArg
This is "nn::hid::ControllerSupportArg". This is a 0x21C-byte (0x9C-byte with version <=0x2, 0x430-byte with version 0x7) struct pushed for input storage.
Layout with the original version:
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | s8 playerCountMin (must be >=0 and <=max_controllers). Older versions assert when invalid, newer versions clamp the used value to a valid range. |
0x1 | 0x1 | s8 playerCountMax (must be >=1 and <=max_controllers). Older versions assert when invalid, newer versions clamp the used value to a valid range. |
0x2 | 0x1 | u8 enableTakeOverConnection. |
0x3 | 0x1 | u8 enableLeftJustify. |
0x4 | 0x1 | u8 enablePermitJoyDual. |
0x5 | 0x1 | u8 enableSingleMode. |
0x6 | 0x1 | u8 enableIdentificationColor. Enables using the array at offset 0x7 when non-zero. |
0x7 | 4*max_controllers | u8 identificationColor[4]. Array of 4-byte entries for each controller, see below for total entries (max controllers). This entry contains individual u8s. |
0x7 + 4*max_controllers | 0x1 | u8 enableExplainText. Enables using the ExplainText data when non-zero. |
With both versions, the rest of the struct is an array containing 0x81-byte (0x21-byte with version <=0x2) entries. With version pre-0x7 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 of this entire struct is 0.
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | u8 enableForceUpdate. |
0x1 | 0x3 | u8 padding[3]. |
ControllerSupportMode
This is "nn::hid::system::ControllerSupportMode".
Value | Description |
---|---|
0 | ShowControllerSupport |
1 | [3.0.0+] ShowControllerStrapGuide |
2 | [3.0.0+] ShowControllerFirmwareUpdate |
In sdknso there's two funcs which expose ShowControllerSupport: one which has a param for the output #ControllerSupportResultInfo, and one that saves that to stack and ignores it.
ShowControllerSupportForSystem has equivalent funcs for the above two funcs, which are the same except Flag1 is set to 1 and Flag0 is set to the input bool.
ShowControllerFirmwareUpdateForSystem is the same as ShowControllerFirmwareUpdate, except Flag1 is set to 1 and ControllerSupportCaller is set to the input param.
ControllerSupportCaller
This is "nn::hid::system::ControllerSupportCaller".
Value | Description |
---|---|
0 | Application |
ControllerSupportResultInfo
This is "nn::hid::ControllerSupportResultInfo". This is a 8-byte struct.
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | s8 playerCount. |
0x1 | 0x3 | u8 padding[3]. |
0x4 | 0x4 | u32 selectedId. |
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:
- When #ControllerSupportArg was previously used:
- 0: Result = 0.
- 2: Result = 0x183CCA.
- Other values: Result = 0x183ACA.
- When #ControllerFirmwareUpdateArg was previously used:
- 0 is success, everything else is handled by returning 0x1902CA.