diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 523b7d3d..6de98f9b 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1437,6 +1437,16 @@ Result appletGetCurrentApplicationId(u64 *titleID); */ Result appletRequestExitToSelf(void); +/** + * @brief Gets an array of userIDs for the MainApplet AvailableUsers. + * @note Only available with AppletType_LibraryApplet on [6.0.0+]. + * @param[out] userIDs Output array of userIDs. + * @param[in] count Size of the userID array, must be at least ACC_USER_LIST_SIZE. + * @param[out] flag When true, this indicates that no users are available. + * @param[out] total_out Total output entries. This is -1 when flag is true. + */ +Result appletGetMainAppletAvailableUsers(u128 *userIDs, s32 count, bool *flag, s32 *total_out); + // IFunctions for AppletType_OverlayApplet (IOverlayFunctions). /** diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 850d7a0e..b1f7d416 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -4252,6 +4252,50 @@ Result appletRequestExitToSelf(void) { return _appletCmdNoIO(&g_appletILibraryAppletSelfAccessor, 80); } +Result appletGetMainAppletAvailableUsers(u128 *userIDs, s32 count, bool *flag, s32 *total_out) { + if (__nx_applet_type != AppletType_LibraryApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + ipcAddRecvBuffer(&c, userIDs, count*sizeof(u128), BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletILibraryAppletSelfAccessor, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 110; + + Result rc = serviceIpcDispatch(&g_appletILibraryAppletSelfAccessor); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u8 flag; + s32 total_out; + } *resp; + + serviceIpcParse(&g_appletILibraryAppletSelfAccessor, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && flag) *flag = resp->flag!=0; + if (R_SUCCEEDED(rc) && total_out) *total_out = resp->total_out; + } + + return rc; +} + // IOverlayFunctions Result appletBeginToWatchShortHomeButtonMessage(void) {