From 2262259984ef39bd48f1e839fec3d25f509dca2f Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 13 Jul 2019 18:57:37 -0400 Subject: [PATCH] Added appletGetDisplayVersion. --- nx/include/switch/services/applet.h | 7 +++++ nx/source/services/applet.c | 43 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 0ff1b3b5..4165094a 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -208,6 +208,13 @@ Result appletGetDesiredLanguage(u64 *LanguageCode); /// Only available with AppletType_*Application. Result appletSetTerminateResult(Result res); +/** + * @brief Gets the DisplayVersion for the current host title control.nacp. + * @note Only available with AppletType_*Application. + * @param[out] displayVersion Output DisplayVersion string, must be at least 0x10-bytes. This is always NUL-terminated. + */ +Result appletGetDisplayVersion(char *displayVersion); + /// Set media playback state. /// If state is set to true, screen dimming and auto sleep is disabled. /// For *Application, this uses cmd SetMediaPlaybackStateForApplication, otherwise cmd SetMediaPlaybackState is used. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 4534cef4..5503d255 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -1319,6 +1319,49 @@ Result appletSetTerminateResult(Result res) { return rc; } +Result appletGetDisplayVersion(char *displayVersion) { + IpcCommand c; + ipcInitialize(&c); + + if (displayVersion) memset(displayVersion, 0, 0x10); + + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletIFunctions, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 23; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + char displayVersion[0x10]; + } *resp; + + serviceIpcParse(&g_appletIFunctions, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && displayVersion) { + strncpy(displayVersion, resp->displayVersion, 0x10); + displayVersion[0xf] = 0; + } + } + + return rc; +} + Result appletSetMediaPlaybackState(bool state) { if (!serviceIsActive(&g_appletSrv)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);