diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index d3038892..bcb68f1c 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -588,6 +588,29 @@ Result appletGetProgramTotalActiveTime(u64 *activeTime); */ Result appletSetApplicationAlbumUserData(const void* buffer, size_t size); +// IWindowController + +/** + * @brief Gets the AppletResourceUserId of the CallerApplet. + * @note Only available with [6.0.0+]. + * @param[out] out AppletResourceUserId + */ +Result appletGetAppletResourceUserIdOfCallerApplet(u64 *out); + +/** + * @brief Sets the current applet WindowVisibility. + * @note Only available with [7.0.0+]. + * @param[in] flag Flag + */ +Result appletSetAppletWindowVisibility(bool flag); + +/** + * @brief Sets the AppletGpuTimeSlice. + * @note Only available with [7.0.0+]. + * @param[in] val Input value, must not be negative. + */ +Result appletSetAppletGpuTimeSlice(s64 val); + // ILibraryAppletCreator /** diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index d1e044f1..90e771c8 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -1895,10 +1895,6 @@ static Result _appletGetAppletResourceUserId(u64 *out) { return _appletCmdNoInOut64(&g_appletIWindowController, out, 1); } -static Result _appletAcquireForegroundRights(void) { - return _appletCmdNoIO(&g_appletIWindowController, 10); -} - Result appletGetAppletResourceUserId(u64 *out) { if (!serviceIsActive(&g_appletSrv)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); @@ -1907,6 +1903,33 @@ Result appletGetAppletResourceUserId(u64 *out) { return 0; } +Result appletGetAppletResourceUserIdOfCallerApplet(u64 *out) { + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + if (!serviceIsActive(&g_appletSrv)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + return _appletCmdNoInOut64(&g_appletIWindowController, out, 2); +} + +static Result _appletAcquireForegroundRights(void) { + return _appletCmdNoIO(&g_appletIWindowController, 10); +} + +Result appletSetAppletWindowVisibility(bool flag) { + if (hosversionBefore(7,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return _appletCmdInBool(&g_appletIWindowController, flag, 20); +} + +Result appletSetAppletGpuTimeSlice(s64 val) { + if (hosversionBefore(7,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return _appletCmdInU64(&g_appletIWindowController, val, 21); +} + // ILibraryAppletCreator static Result _appletCreateLibraryApplet(Service* srv_out, AppletId id, LibAppletMode mode) {