From a48f7c3502946ee135af0a151eb31e44ccff3235 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 26 Feb 2019 19:40:20 -0500 Subject: [PATCH] Added webConfigSetBootDisplayKind and enum WebBootDisplayKind. Added enum WebShimKind_Offline. Minor other web adjustments. --- nx/include/switch/applets/web.h | 29 ++++++++++++++++++++++------- nx/source/applets/web.c | 12 +++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index 0bf0c819..9942d1a2 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -10,11 +10,12 @@ /// This indicates the type of web-applet. typedef enum { - WebShimKind_Login = 2, - WebShimKind_Share = 4, - WebShimKind_Web = 5, - WebShimKind_Wifi = 6, - WebShimKind_Lobby = 7, + WebShimKind_Login = 2, + WebShimKind_Offline = 3, + WebShimKind_Share = 4, + WebShimKind_Web = 5, + WebShimKind_Wifi = 6, + WebShimKind_Lobby = 7, } WebShimKind; typedef struct { @@ -82,8 +83,8 @@ typedef enum { WebArgType_PlayReportEnabled = 0x13, ///< [1.0.0+] u8 bool WebArgType_Unknown14 = 0x14, ///< [1.0.0+] u8 WebArgType_Unknown15 = 0x15, ///< [1.0.0+] u8 - WebArgType_BootDisplayKind = 0x17, ///< [1.0.0+] u32 enum enum WebBootDisplayKind - WebArgType_BackgroundKind = 0x18, ///< [1.0.0+] u32 enum u32 enum *BackgroundKind + WebArgType_BootDisplayKind = 0x17, ///< [1.0.0+] u32 enum *BootDisplayKind + WebArgType_BackgroundKind = 0x18, ///< [1.0.0+] u32 enum *BackgroundKind WebArgType_FooterEnabled = 0x19, ///< [1.0.0+] u8 bool WebArgType_PointerEnabled = 0x1A, ///< [1.0.0+] u8 bool WebArgType_LeftStickMode = 0x1B, ///< [1.0.0+] u32 enum *LeftStickMode @@ -113,6 +114,12 @@ typedef enum { WebArgType_PageScrollIndicatorEnabled = 0x36, ///< [5.0.0+] u8 bool } WebArgType; +/// Kind values for \ref webConfigSetBootDisplayKind with Web applet. Controls the background color while displaying the loading screen during applet boot. +typedef enum { + WebBootDisplayKind_White = 0, ///< Default white background. Value 1 seems to have same affect. + WebBootDisplayKind_Black = 2, ///< Black background, likewise with values >2 it seems. +} WebBootDisplayKind; + /** * @brief Creates the config for WifiWebAuthApplet. * @param config WebWifiConfig object. @@ -162,6 +169,14 @@ Result webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url); */ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist); +/** + * @brief Sets the BootDisplayKind. + * @note Only available with config created by \ref webPageCreate or with Offline-applet. + * @param config WebCommonConfig object. + * @param kind Kind, different enums for Web (\ref WebBootDisplayKind) and Offline. + */ +Result webConfigSetBootDisplayKind(WebCommonConfig* config, u32 kind); + /** * @brief Sets the DisplayUrlKind. * @param config WebCommonConfig object. diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index d8ee3fd0..0a84ba6e 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -153,9 +153,9 @@ static Result _webConfigSetFlag(WebCommonConfig* config, u16 type, bool arg) { return _webConfigSetU8(config, type, arg!=0); } -/*static Result _webConfigSetU32(WebCommonConfig* config, u16 type, u32 arg) { +static Result _webConfigSetU32(WebCommonConfig* config, u16 type, u32 arg) { return _webTLVSet(&config->arg, type, &arg, sizeof(arg)); -}*/ +} static Result _webConfigSetString(WebCommonConfig* config, u16 type, const char* str, u16 argdata_size_total) { u16 arglen = strlen(str); @@ -182,7 +182,7 @@ Result webPageCreate(WebCommonConfig* config, const char* url) { Result webConfigSetCallbackUrl(WebCommonConfig* config, const char* url) { WebShimKind shim = _webGetShimKind(config); - if (shim != WebShimKind_Web && shim != WebShimKind_Share) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (shim != WebShimKind_Share && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return _webConfigSetString(config, WebArgType_CallbackUrl, url, 0x400); } @@ -196,6 +196,12 @@ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) { return _webConfigSetString(config, WebArgType_Whitelist, whitelist, 0x1000); } +Result webConfigSetBootDisplayKind(WebCommonConfig* config, u32 kind) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Web && shim != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + return _webConfigSetU32(config, WebArgType_BootDisplayKind, kind); +} + Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind) { return _webConfigSetFlag(config, WebArgType_DisplayUrlKind, kind); }