diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 865710b7..c9db8a11 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -14,6 +14,7 @@ #include "../services/pm.h" #include "../kernel/tmem.h" #include "../kernel/event.h" +#include "../nacp.h" /// AppletType typedef enum { @@ -1084,6 +1085,11 @@ Result appletRequestLaunchApplication(u64 titleID, AppletStorage* s); */ Result appletRequestLaunchApplicationForQuest(u64 titleID, AppletStorage* s, const AppletApplicationAttributeForQuest *attr); +/** + * @brief Gets the DesiredLanguage for the current host title control.nacp. + * @note Only available with AppletType_*Application. + * @param[out] LanguageCode Output LanguageCode, see set.h. + */ Result appletGetDesiredLanguage(u64 *LanguageCode); /// Only available with AppletType_*Application. @@ -1352,6 +1358,13 @@ Result appletGetLibraryAppletInfo(LibAppletInfo *info); */ Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info); +/** + * @brief CanUseApplicationCore + * @note Only available with AppletType_LibraryApplet. + * @param[out] out Output flag. + */ +Result appletCanUseApplicationCore(bool *out); + /** * @brief Gets the \ref AppletIdentityInfo for the CallerApplet. * @note Only available with AppletType_LibraryApplet. @@ -1359,6 +1372,13 @@ Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info); */ Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info); +/** + * @brief Gets the \ref NacpStruct for the MainApplet. + * @note Only available with AppletType_LibraryApplet on [2.0.0+]. + * @param[out] nacp \ref NacpStruct + */ +Result appletGetMainAppletApplicationControlProperty(NacpStruct *nacp); + /** * @brief Gets an array of \ref AppletIdentityInfo for the CallerStack. * @note Only available with AppletType_LibraryApplet on [3.0.0+]. @@ -1375,6 +1395,13 @@ Result appletGetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 cou */ Result appletGetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info); +/** + * @brief Gets the DesiredLanguage for the MainApplet. + * @note Only available with AppletType_LibraryApplet on [4.0.0+]. + * @param[out] LanguageCode Output LanguageCode, see set.h. + */ +Result appletGetMainAppletApplicationDesiredLanguage(u64 *LanguageCode); + // IFunctions for AppletType_OverlayApplet (IOverlayFunctions). /** diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index c2b04f87..41930139 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -14,6 +14,7 @@ #include "services/sm.h" #include "runtime/env.h" #include "runtime/hosversion.h" +#include "nacp.h" __attribute__((weak)) u32 __nx_applet_type = AppletType_Default; __attribute__((weak)) bool __nx_applet_auto_notifyrunning = true; @@ -4086,6 +4087,13 @@ Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info) { return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 12); } +Result appletCanUseApplicationCore(bool *out) { + if (__nx_applet_type != AppletType_LibraryApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoInOutBool(&g_appletILibraryAppletSelfAccessor, out, 13); +} + Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info) { if (__nx_applet_type != AppletType_LibraryApplet) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); @@ -4093,6 +4101,45 @@ Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info) { return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 14); } +Result appletGetMainAppletApplicationControlProperty(NacpStruct *nacp) { + if (__nx_applet_type != AppletType_LibraryApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(2,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + ipcAddRecvBuffer(&c, nacp, sizeof(*nacp), BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletILibraryAppletSelfAccessor, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 15; + + Result rc = serviceIpcDispatch(&g_appletILibraryAppletSelfAccessor); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + } *resp; + + serviceIpcParse(&g_appletILibraryAppletSelfAccessor, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + Result appletGetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 count, s32 *total_out) { if (__nx_applet_type != AppletType_LibraryApplet) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); @@ -4145,6 +4192,15 @@ Result appletGetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 18); } +Result appletGetMainAppletApplicationDesiredLanguage(u64 *LanguageCode) { + if (__nx_applet_type != AppletType_LibraryApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(4,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return _appletCmdNoInOut64(&g_appletILibraryAppletSelfAccessor, LanguageCode, 60); +} + // IOverlayFunctions Result appletBeginToWatchShortHomeButtonMessage(void) {