diff --git a/nx/include/switch/result.h b/nx/include/switch/result.h index 3660bc3e..01fcbee7 100644 --- a/nx/include/switch/result.h +++ b/nx/include/switch/result.h @@ -60,6 +60,7 @@ enum { LibnxError_BadGetInfo_Rng, LibnxError_JitUnavailable, LibnxError_WeirdKernel, + LibnxError_IncompatSysVer, }; enum { diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index dcd5d1df..4a076337 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -45,6 +45,14 @@ Result appletGetAppletResourceUserId(u64 *out); void appletNotifyRunning(u8 *out); Result appletCreateManagedDisplayLayer(u64 *out); +/** + * @brief Controls whether screenshot-capture is allowed. + * @param val 0 = disable, 1 = enable. + */ +Result appletSetScreenShotPermission(s32 val); + +Result appletSetScreenShotImageOrientation(s32 val); + /** * @brief Processes the current applet status. Generally used within a main loop. * @return Whether the application should continue running. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 92c0ef42..77c43003 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -658,6 +658,39 @@ static Result _appletGetCurrentFocusState(u8 *out) { return rc; } +Result appletSetScreenShotPermission(s32 val) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + s32 val; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 10; + raw->val = val; + + Result rc = serviceIpcDispatch(&g_appletISelfController); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + static Result _appletSetOperationModeChangedNotification(u8 flag) { IpcCommand c; ipcInitialize(&c); @@ -794,6 +827,42 @@ static Result _appletSetOutOfFocusSuspendingEnabled(u8 inval) { return rc; } +Result appletSetScreenShotImageOrientation(s32 val) { + if (!kernelAbove300()) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + s32 val; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 19; + raw->val = val; + + Result rc = serviceIpcDispatch(&g_appletISelfController); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + Result appletCreateManagedDisplayLayer(u64 *out) { IpcCommand c; ipcInitialize(&c);