From 8be5cad7f839f26d16aa1dfd5a5031ca5e34f20e Mon Sep 17 00:00:00 2001 From: Cpasjuste Date: Fri, 21 Dec 2018 10:16:20 +0100 Subject: [PATCH] Added appletSetMediaPlaybackStateForApplication --- nx/include/switch/services/applet.h | 4 ++++ nx/source/services/applet.c | 37 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 6f1ec164..3af09e62 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -160,6 +160,10 @@ Result appletGetDesiredLanguage(u64 *LanguageCode); /// Only available with AppletType_*Application. Result appletSetTerminateResult(Result res); +/// Set media playback state. +/// If state is set to true, screen dimming and auto sleep is disabled. +Result appletSetMediaPlaybackStateForApplication(bool state); + /// Gets whether video recording is supported. /// See also \ref appletInitializeGamePlayRecording. Result appletIsGamePlayRecordingSupported(bool *flag); diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 6d42bee1..3cad068a 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -869,6 +869,43 @@ Result appletSetTerminateResult(Result res) { return rc; } +Result appletSetMediaPlaybackStateForApplication(bool state) { + IpcCommand c; + ipcInitialize(&c); + + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + struct { + u64 magic; + u64 cmd_id; + u8 state; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletIFunctions, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 60; + raw->state = state; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + } *resp; + + serviceIpcParse(&g_appletIFunctions, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + Result appletBeginBlockingHomeButton(s64 val) { IpcCommand c; ipcInitialize(&c);