From e709c432715fe2dc110e2e4a5b594ab1e07ce79d Mon Sep 17 00:00:00 2001 From: Rasmus Moorats Date: Thu, 6 Sep 2018 21:20:16 +0300 Subject: [PATCH] Add appletBeginBlockingHomeButton() and appletEndBlockingHomeButton() --- nx/include/switch/services/applet.h | 4 ++ nx/source/services/applet.c | 70 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 74d32f85..ea5fd492 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -53,6 +53,10 @@ Result appletCreateManagedDisplayLayer(u64 *out); Result appletGetDesiredLanguage(u64 *LanguageCode); +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 f4733d9e..ec7adf59 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -565,6 +565,76 @@ Result appletGetDesiredLanguage(u64 *LanguageCode) { return rc; } +Result appletBeginBlockingHomeButton(s64 val) { + IpcCommand c; + ipcInitialize(&c); + + if (!serviceIsActive(&g_appletSrv) || __nx_applet_type!=AppletType_Application) + 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) + 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);