diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 13d38bd6..0fb52e1c 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -54,6 +54,15 @@ Result appletCreateManagedDisplayLayer(u64 *out); Result appletGetDesiredLanguage(u64 *LanguageCode); +/** + * @brief Blocks the usage of the home button. + * @param val Unknown nanoseconds. Value 0 can be used. + * @note Can only be used in regularapps. + */ +Result appletBeginBlockingHomeButton(s64 val); + +Result appletEndBlockingHomeButton(void); + /** * @brief Controls whether screenshot-capture is allowed. * @param val 0 = disable, 1 = enable. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index a1f9eaae..ec1f6747 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -569,6 +569,78 @@ Result appletGetDesiredLanguage(u64 *LanguageCode) { return rc; } +Result appletBeginBlockingHomeButton(s64 val) { + IpcCommand c; + ipcInitialize(&c); + + if (!serviceIsActive(&g_appletSrv) || (__nx_applet_type!=AppletType_Application + && __nx_applet_type!=AppletType_SystemApplication)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + struct { + u64 magic; + u64 cmd_id; + s64 val; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 32; + raw->val = val; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + +Result appletEndBlockingHomeButton(void) { + IpcCommand c; + ipcInitialize(&c); + + if (!serviceIsActive(&g_appletSrv) || (__nx_applet_type!=AppletType_Application + && __nx_applet_type!=AppletType_SystemApplication)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 33; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + void appletNotifyRunning(u8 *out) { IpcCommand c; ipcInitialize(&c);