diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index 14ecba84..23e6baea 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -115,6 +115,12 @@ typedef enum { WebArgType_PageScrollIndicator = 0x36, ///< [5.0.0+] u8 bool } WebArgType; +/// This controls the initial page for ShareApplet, used by \ref webShareCreate. +typedef enum { + WebShareStartPage_Default = 0, ///< The default "/" page. + WebShareStartPage_Settings = 1, ///< The "/settings/" page. +} WebShareStartPage; + /// 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. @@ -167,6 +173,16 @@ Result webNewsCreate(WebCommonConfig* config, const char* url); */ Result webYouTubeVideoCreate(WebCommonConfig* config, const char* url); +/** + * @brief Creates the config for ShareApplet. + * @note Only available on [2.0.0+]. + * @note If a non-zero userID isn't set with \ref webConfigSetUserID prior to using \ref webConfigShow, the applet will launch the profile-selector applet to select an account. + * @note Uses \ref webConfigSetLeftStickMode with mode=1, \ref webConfigSetUserID with userID=0, \ref webConfigSetDisplayUrlKind with kind=true, and sets WebArgType_Unknown14/WebArgType_Unknown15 to value 1. Uses \ref webConfigSetBootDisplayKind with WebBootDisplayKind_Unknown3. + * @param config WebCommonConfig object. + * @param page \ref WebShareStartPage + */ +Result webShareCreate(WebCommonConfig* config, WebShareStartPage page); + /** * @brief Creates the config for LobbyApplet. * @note Only available on [2.0.0+]. @@ -204,7 +220,7 @@ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist); /** * @brief Sets the account UserID. Controls which user-specific savedata to mount. * @note Only available with config created by \ref webPageCreate, \ref webLobbyCreate, or with Share-applet. - * @note Used automatically by \ref webLobbyCreate with userID=0. + * @note Used automatically by \ref webShareCreate and \ref webLobbyCreate with userID=0. * @param config WebCommonConfig object. * @param userID Account userID */ @@ -229,7 +245,8 @@ Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag); /** * @brief Sets the BootDisplayKind. - * @note Only available with config created by \ref webPageCreate, \ref webLobbyCreate, or with Offline-applet. + * @note Only available with config created by \ref webShareCreate, \ref webPageCreate, \ref webLobbyCreate, or with Offline-applet. + * @note Used automatically by \ref webShareCreate with kind=WebBootDisplayKind_Unknown3. * @note Used automatically by \ref webLobbyCreate with kind=WebBootDisplayKind_Unknown4. * @param config WebCommonConfig object. * @param kind Kind, different enums for Web (\ref WebBootDisplayKind) and Offline. @@ -264,8 +281,8 @@ Result webConfigSetPointer(WebCommonConfig* config, bool flag); /** * @brief Sets the LeftStickMode. - * @note Only available with config created by \ref webPageCreate, \ref webLobbyCreate, or with Offline-applet. - * @note Used automatically by \ref webLobbyCreate with mode=1. + * @note Only available with config created by \ref webShareCreate, \ref webPageCreate, \ref webLobbyCreate, or with Offline-applet. + * @note Used automatically by \ref webShareCreate and \ref webLobbyCreate with mode=1. * @param config WebCommonConfig object. * @param mode Mode, different enums for Web and Offline. */ @@ -282,7 +299,9 @@ Result webConfigSetKeyRepeatFrame(WebCommonConfig* config, s32 inval0, s32 inval /** * @brief Sets the DisplayUrlKind. + * @note Only available with config created by \ref webShareCreate or \ref webPageCreate. * @param config WebCommonConfig object. + * @note Used automatically by \ref webShareCreate with kind=true. * @param kind Kind */ Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind); diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index 218fc90a..aa5b6f16 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -261,6 +261,25 @@ Result webYouTubeVideoCreate(WebCommonConfig* config, const char* url) { return rc; } +Result webShareCreate(WebCommonConfig* config, WebShareStartPage page) { + Result rc=0; + if (hosversionBefore(2,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + _webArgInitialize(config, AppletId_loginShare, WebShimKind_Share); + + rc = webConfigSetLeftStickMode(config, 1); + if (R_SUCCEEDED(rc)) rc = webConfigSetUserID(config, 0); + if (R_SUCCEEDED(rc)) rc = webConfigSetDisplayUrlKind(config, true); + + if (R_SUCCEEDED(rc)) rc = _webConfigSetU8(config, WebArgType_Unknown14, 1); + if (R_SUCCEEDED(rc)) rc = _webConfigSetU8(config, WebArgType_Unknown15, 1); + if (R_SUCCEEDED(rc)) rc = webConfigSetBootDisplayKind(config, WebBootDisplayKind_Unknown3); + + if (R_SUCCEEDED(rc)) rc = _webConfigSetU32(config, WebArgType_ShareStartPage, page); + + return rc; +} + Result webLobbyCreate(WebCommonConfig* config) { Result rc=0; if (hosversionBefore(2,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -316,7 +335,7 @@ Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag) { Result webConfigSetBootDisplayKind(WebCommonConfig* config, u32 kind) { WebShimKind shim = _webGetShimKind(config); - if (shim != WebShimKind_Offline && shim != WebShimKind_Web && shim != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (shim != WebShimKind_Offline && shim != WebShimKind_Share && shim != WebShimKind_Web && shim != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return _webConfigSetU32(config, WebArgType_BootDisplayKind, kind); } @@ -340,7 +359,7 @@ Result webConfigSetPointer(WebCommonConfig* config, bool flag) { Result webConfigSetLeftStickMode(WebCommonConfig* config, u32 mode) { WebShimKind shim = _webGetShimKind(config); - if (shim != WebShimKind_Offline && shim != WebShimKind_Web && shim != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (shim != WebShimKind_Offline && shim != WebShimKind_Share && shim != WebShimKind_Web && shim != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return _webConfigSetU32(config, WebArgType_LeftStickMode, mode); } @@ -354,6 +373,8 @@ Result webConfigSetKeyRepeatFrame(WebCommonConfig* config, s32 inval0, s32 inval } Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Share && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return _webConfigSetFlag(config, WebArgType_DisplayUrlKind, kind); }