From 3bbc181531842f4e0a0fa182278fb612245043f3 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 7 Aug 2019 19:57:03 -0400 Subject: [PATCH] Added appletRequestToGetForeground, appletLockForeground, appletUnlockForeground, appletPopFromGeneralChannel, and appletGetPopFromGeneralChannelEvent. --- nx/include/switch/services/applet.h | 33 +++++++++++++++++++++++++++ nx/source/services/applet.c | 35 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index b5272d85..62a0a63c 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1221,6 +1221,39 @@ Result appletGetGpuErrorDetectedSystemEvent(Event *out_event); // IHomeMenuFunctions +/** + * @brief RequestToGetForeground + * @note Only available with AppletType_SystemApplet. + */ +Result appletRequestToGetForeground(void); + +/** + * @brief LockForeground + * @note Only available with AppletType_SystemApplet. + */ +Result appletLockForeground(void); + +/** + * @brief UnlockForeground + * @note Only available with AppletType_SystemApplet. + */ +Result appletUnlockForeground(void); + +/** + * @brief Pops a storage from the general channel. + * @note Only available with AppletType_SystemApplet. + * @param[out] s Storage object. + */ +Result appletPopFromGeneralChannel(AppletStorage *s); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletPopFromGeneralChannel. + * @note Only available with AppletType_SystemApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result appletGetPopFromGeneralChannelEvent(Event *out_event); + /** * @brief Gets a \ref AppletLockAccessor for HomeButtonWriter. * @note Only available with AppletType_SystemApplet. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 770c1e91..acae6fe3 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -3932,6 +3932,41 @@ Result appletGetGpuErrorDetectedSystemEvent(Event *out_event) { // IHomeMenuFunctions +Result appletRequestToGetForeground(void) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoIO(&g_appletIFunctions, 10); +} + +Result appletLockForeground(void) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoIO(&g_appletIFunctions, 11); +} + +Result appletUnlockForeground(void) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoIO(&g_appletIFunctions, 12); +} + +Result appletPopFromGeneralChannel(AppletStorage *s) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoInOutStorage(&g_appletIFunctions, s, 20); +} + +Result appletGetPopFromGeneralChannelEvent(Event *out_event) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletGetEvent(&g_appletIFunctions, out_event, 21, false); +} + Result appletGetHomeButtonWriterLockAccessor(AppletLockAccessor *a) { if (__nx_applet_type != AppletType_SystemApplet) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);