From 2257e3ccf4a77cc3653f4d71ffb357cf7d29a6f6 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 30 Jul 2019 17:34:05 -0400 Subject: [PATCH] Updated LibAppletMode enum and added appletHolderSetOutOfFocusApplicationSuspendingEnabled. --- nx/include/switch/services/applet.h | 19 ++++++++++++++----- nx/source/applets/swkbd.c | 2 +- nx/source/services/applet.c | 11 +++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index ca76b18c..265baa10 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -109,10 +109,11 @@ typedef enum { /// LibraryAppletMode typedef enum { - LibAppletMode_AllForeground = 0, ///< Foreground - LibAppletMode_Background = 1, ///< Background - LibAppletMode_Unknown2 = 2, ///< Unknown - LibAppletMode_Unknown3 = 3, ///< Unknown + LibAppletMode_AllForeground = 0, ///< Foreground. + LibAppletMode_Background = 1, ///< Background. + LibAppletMode_NoUi = 2, ///< No UI. + LibAppletMode_BackgroundIndirect = 3, ///< Background with indirect display, see \ref appletHolderGetIndirectLayerConsumerHandle. + LibAppletMode_AllForegroundInitiallyHidden = 4, ///< Foreground except initially hidden. } LibAppletMode; /// LibraryAppletExitReason @@ -669,7 +670,7 @@ bool appletHolderActive(AppletHolder *h); /** * @brief Gets the IndirectLayerConsumerHandle loaded during \ref appletCreateLibraryApplet, on 2.0.0+. - * @note Only available when \ref LibAppletMode is ::LibAppletMode_Unknown3. + * @note Only available when \ref LibAppletMode is ::LibAppletMode_BackgroundIndirect. * @param h AppletHolder object. * @param out Output IndirectLayerConsumerHandle. */ @@ -705,6 +706,14 @@ bool appletHolderCheckFinished(AppletHolder *h); */ LibAppletExitReason appletHolderGetExitReason(AppletHolder *h); +/** + * @brief Sets OutOfFocusApplicationSuspendingEnabled. + * @note Only available with AppletType_*Application. + * @param h AppletHolder object. + * @param[in] flag Flag + */ +Result appletHolderSetOutOfFocusApplicationSuspendingEnabled(AppletHolder *h, bool flag); + /** * @brief Waits for the PopInteractiveOutDataEvent and StateChangedEvent. * @return false for error / when StateChangedEvent was signaled, and true when PopInteractiveOutDataEvent was signaled. diff --git a/nx/source/applets/swkbd.c b/nx/source/applets/swkbd.c index d7676a4d..bbcf1118 100644 --- a/nx/source/applets/swkbd.c +++ b/nx/source/applets/swkbd.c @@ -493,7 +493,7 @@ static Result _swkbdInlineLaunch(SwkbdInline* s, SwkbdInitializeArg *initArg) { memcpy(&s->calcArg.initArg, initArg, sizeof(*initArg)); s->calcArg.flags |= 0x1; - rc = appletCreateLibraryApplet(&s->holder, AppletId_swkbd, s->calcArg.initArg.mode!=SwkbdInlineMode_UserDisplay ? LibAppletMode_Background : LibAppletMode_Unknown3); + rc = appletCreateLibraryApplet(&s->holder, AppletId_swkbd, s->calcArg.initArg.mode!=SwkbdInlineMode_UserDisplay ? LibAppletMode_Background : LibAppletMode_BackgroundIndirect); if (R_FAILED(rc)) return rc; LibAppletArgs commonargs; diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index fe635864..b332ec2c 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -2147,7 +2147,7 @@ static Result _appletHolderCreate(AppletHolder *h, AppletId id, LibAppletMode mo if (R_SUCCEEDED(rc)) rc = _appletGetEvent(&h->s, &h->StateChangedEvent, 0, false);//GetAppletStateChangedEvent - if (R_SUCCEEDED(rc) && hosversionAtLeast(2,0,0) && h->mode == LibAppletMode_Unknown3) rc = _appletGetIndirectLayerConsumerHandle(&h->s, &h->layer_handle); + if (R_SUCCEEDED(rc) && hosversionAtLeast(2,0,0) && h->mode == LibAppletMode_BackgroundIndirect) rc = _appletGetIndirectLayerConsumerHandle(&h->s, &h->layer_handle); return rc; } @@ -2175,7 +2175,7 @@ bool appletHolderActive(AppletHolder *h) { Result appletHolderGetIndirectLayerConsumerHandle(AppletHolder *h, u64 *out) { if (!serviceIsActive(&h->s)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); - if (h->mode!=LibAppletMode_Unknown3) + if (h->mode!=LibAppletMode_BackgroundIndirect) return MAKERESULT(Module_Libnx, LibnxError_BadInput); if (hosversionBefore(2,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -2239,6 +2239,13 @@ u32 appletHolderGetExitReason(AppletHolder *h) { return h->exitreason; } +Result appletHolderSetOutOfFocusApplicationSuspendingEnabled(AppletHolder *h, bool flag) { + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdInBool(&h->s, flag, 50); +} + static Result _appletHolderGetPopInteractiveOutDataEvent(AppletHolder *h) { Result rc=0;