Stub the web applet

This commit is contained in:
Billy Laws 2022-10-30 16:10:05 +00:00
parent 021f82ef08
commit 1fc2641746
4 changed files with 126 additions and 0 deletions

View File

@ -292,6 +292,7 @@ add_library(skyline SHARED
${source_DIR}/skyline/applet/controller_applet.cpp
${source_DIR}/skyline/applet/error_applet.cpp
${source_DIR}/skyline/applet/player_select_applet.cpp
${source_DIR}/skyline/applet/web_applet.cpp
${source_DIR}/skyline/applet/swkbd/software_keyboard_applet.cpp
${source_DIR}/skyline/applet/swkbd/software_keyboard_config.cpp
${source_DIR}/skyline/services/codec/IHardwareOpusDecoder.cpp

View File

@ -5,6 +5,7 @@
#include "controller_applet.h"
#include "error_applet.h"
#include "player_select_applet.h"
#include "web_applet.h"
#include "swkbd/software_keyboard_applet.h"
namespace skyline::applet {
@ -23,6 +24,8 @@ namespace skyline::applet {
return std::make_shared<swkbd::SoftwareKeyboardApplet>(state, manager, std::move(onAppletStateChanged), std::move(onNormalDataPushFromApplet), std::move(onInteractiveDataPushFromApplet), appletMode);
case AppletId::LibraryAppletError:
return std::make_shared<ErrorApplet>(state, manager, std::move(onAppletStateChanged), std::move(onNormalDataPushFromApplet), std::move(onInteractiveDataPushFromApplet), appletMode);
case AppletId::LibraryAppletOfflineWeb:
return std::make_shared<WebApplet>(state, manager, std::move(onAppletStateChanged), std::move(onNormalDataPushFromApplet), std::move(onInteractiveDataPushFromApplet), appletMode);
default:
throw exception{"Unimplemented Applet: 0x{:X} ({})", static_cast<u32>(appletId), ToString(appletId)};
}

View File

@ -0,0 +1,47 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
// Copyright © 2020 yuzu Emulator Project (https://github.com/yuzu-emu/)
#include <input.h>
#include <input/npad.h>
#include <services/applet/common_arguments.h>
#include <services/am/storage/ObjIStorage.h>
#include "web_applet.h"
namespace skyline::applet {
WebApplet::WebApplet(const DeviceState &state,
service::ServiceManager &manager,
std::shared_ptr<kernel::type::KEvent> onAppletStateChanged,
std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet,
std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet,
service::applet::LibraryAppletMode appletMode)
: IApplet{state, manager, std::move(onAppletStateChanged), std::move(onNormalDataPushFromApplet), std::move(onInteractiveDataPushFromApplet), appletMode} {}
Result WebApplet::Start() {
auto commonArg{PopNormalInput<service::applet::CommonArguments>()};
auto argHeader{PopNormalInput<WebArgHeader>()};
if ((commonArg.apiVersion >= 0x80000 && argHeader.shimKind == ShimKind::Web) || (commonArg.apiVersion >= 0x30000 && argHeader.shimKind == ShimKind::Share))
Logger::Error("OfflineWeb TLV output is unsupported!");
PushNormalDataAndSignal(std::make_shared<service::am::ObjIStorage<WebCommonReturnValue>>(state, manager, WebCommonReturnValue{
.exitReason = WebExitReason::WindowClosed,
.lastUrl = {'h', 't', 't', 'p', ':', '/', '/', 'l', 'o', 'c', 'a', 'l', 'h', 'o', 's', 't', '/'},
.lastUrlSize = 17
}));
// Notify the guest that we've finished running
onAppletStateChanged->Signal();
return {};
}
Result WebApplet::GetResult() {
return {};
}
void WebApplet::PushNormalDataToApplet(std::shared_ptr<service::am::IStorage> data) {
PushNormalInput(data);
}
void WebApplet::PushInteractiveDataToApplet(std::shared_ptr<service::am::IStorage> data) {}
}

View File

@ -0,0 +1,75 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
// Copyright © 2020 Ryujinx Team and Contributors (https://github.com/ryujinx/)
#pragma once
#include <services/am/applet/IApplet.h>
namespace skyline::applet {
/**
* @brief The Web applet is utilized by the guest to display web pages using the built-in web browser
*/
class WebApplet : public service::am::IApplet, service::am::EnableNormalQueue {
private:
#pragma pack(push, 1)
/**
* @brief Type of web-applet to launch
* @url https://switchbrew.org/wiki/Internet_Browser#ShimKind
*/
enum class ShimKind : u32 {
Shop = 1,
Login = 2,
Offline = 3,
Share = 4,
Web = 5,
Wifi = 6,
Lobby = 7,
Lhub = 8,
};
enum class WebExitReason : u32 {
EndButtonPressed = 0,
BackButtonPressed = 1,
ExitRequested = 2,
CallbackURL = 3,
WindowClosed = 4,
ErrorDialog = 7,
};
/**
* @brief Common return value struct for all web-applet commands
*/
struct WebCommonReturnValue {
WebExitReason exitReason;
u32 _pad_;
std::array<char, 0x1000> lastUrl;
u64 lastUrlSize;
};
static_assert(sizeof(WebCommonReturnValue) == 0x1010);
/**
* @brief The input data for the web-applet
*/
struct WebArgHeader {
u16 count;
u16 _pad_;
ShimKind shimKind;
};
#pragma pack(pop)
public:
WebApplet(const DeviceState &state, service::ServiceManager &manager, std::shared_ptr<kernel::type::KEvent> onAppletStateChanged, std::shared_ptr<kernel::type::KEvent> onNormalDataPushFromApplet, std::shared_ptr<kernel::type::KEvent> onInteractiveDataPushFromApplet, service::applet::LibraryAppletMode appletMode);
Result Start() override;
Result GetResult() override;
void PushNormalDataToApplet(std::shared_ptr<service::am::IStorage> data) override;
void PushInteractiveDataToApplet(std::shared_ptr<service::am::IStorage> data) override;
};
}