diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 517a8d73..7aba4ea0 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -311,6 +311,14 @@ Result appletGetHdcpAuthenticationStateChangeEvent(Event *out_event); */ Result appletSetTvPowerStateMatchingMode(AppletTvPowerStateMatchingMode mode); +/** + * @brief Gets the application titleID for the specified ContentActionName string. + * @note Only available when the current applet is ::AppletId_starter on [5.1.0+]. + * @param[out] titleID Application titleID. + * @param[in] name ContentActionName string. + */ +Result appletGetApplicationIdByContentActionName(u64 *titleID, const char *name); + /** * @brief Sets the \ref ApmCpuBoostMode. * @note Only available with [7.0.0+] (not fully usable system-side with 6.x). diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 0c1b07b9..3d15b0b1 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -1275,6 +1275,46 @@ Result appletSetTvPowerStateMatchingMode(AppletTvPowerStateMatchingMode mode) { return _appletCmdInU32(&g_appletICommonStateGetter, mode, 64); } +Result appletGetApplicationIdByContentActionName(u64 *titleID, const char *name) { + if (hosversionBefore(5,1,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + ipcAddSendBuffer(&c, name, strlen(name)+1, BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletICommonStateGetter, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 65; + + Result rc = serviceIpcDispatch(&g_appletICommonStateGetter); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u64 titleID; + } *resp; + + serviceIpcParse(&g_appletICommonStateGetter, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && titleID) *titleID = resp->titleID; + } + + return rc; +} + Result appletSetCpuBoostMode(ApmCpuBoostMode mode) { Result rc=0; if (hosversionBefore(7,0,0))