Add error/EULA applet

This commit is contained in:
wheremyfoodat 2024-01-25 17:31:17 +02:00
parent 6e6c84eebb
commit f0c20d70bc
7 changed files with 58 additions and 7 deletions

View file

@ -188,7 +188,9 @@ set(FS_SOURCE_FILES src/core/fs/archive_self_ncch.cpp src/core/fs/archive_save_d
src/core/fs/ivfc.cpp src/core/fs/archive_user_save_data.cpp src/core/fs/archive_system_save_data.cpp src/core/fs/ivfc.cpp src/core/fs/archive_user_save_data.cpp src/core/fs/archive_system_save_data.cpp
) )
set(APPLET_SOURCE_FILES src/core/applets/applet.cpp src/core/applets/mii_selector.cpp src/core/applets/software_keyboard.cpp src/core/applets/applet_manager.cpp) set(APPLET_SOURCE_FILES src/core/applets/applet.cpp src/core/applets/mii_selector.cpp src/core/applets/software_keyboard.cpp src/core/applets/applet_manager.cpp
src/core/applets/error_applet.cpp
)
set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp) set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp)
# Frontend source files # Frontend source files
@ -244,7 +246,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
include/services/news_u.hpp include/applets/software_keyboard.hpp include/applets/applet_manager.hpp include/fs/archive_user_save_data.hpp include/services/news_u.hpp include/applets/software_keyboard.hpp include/applets/applet_manager.hpp include/fs/archive_user_save_data.hpp
include/services/amiibo_device.hpp include/services/nfc_types.hpp include/swap.hpp include/services/csnd.hpp include/services/nwm_uds.hpp include/services/amiibo_device.hpp include/services/nfc_types.hpp include/swap.hpp include/services/csnd.hpp include/services/nwm_uds.hpp
include/fs/archive_system_save_data.hpp include/lua_manager.hpp include/memory_mapped_file.hpp include/hydra_icon.hpp include/fs/archive_system_save_data.hpp include/lua_manager.hpp include/memory_mapped_file.hpp include/hydra_icon.hpp
include/PICA/dynapica/shader_rec_emitter_arm64.hpp include/scheduler.hpp include/PICA/dynapica/shader_rec_emitter_arm64.hpp include/scheduler.hpp include/applets/error_applet.hpp
) )
cmrc_add_resource_library( cmrc_add_resource_library(

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include "applets/error_applet.hpp"
#include "applets/mii_selector.hpp" #include "applets/mii_selector.hpp"
#include "applets/software_keyboard.hpp" #include "applets/software_keyboard.hpp"
#include "helpers.hpp" #include "helpers.hpp"
@ -11,6 +12,7 @@ namespace Applets {
class AppletManager { class AppletManager {
MiiSelectorApplet miiSelector; MiiSelectorApplet miiSelector;
SoftwareKeyboardApplet swkbd; SoftwareKeyboardApplet swkbd;
ErrorApplet error;
std::optional<Applets::Parameter> nextParameter = std::nullopt; std::optional<Applets::Parameter> nextParameter = std::nullopt;
public: public:

View file

@ -0,0 +1,15 @@
#include <string>
#include "applets/applet.hpp"
namespace Applets {
class ErrorApplet final : public AppletBase {
public:
virtual const char* name() override { return "Error/EULA Agreement"; }
virtual Result::HorizonResult start(const MemoryBlock* sharedMem, const std::vector<u8>& parameters, u32 appID) override;
virtual Result::HorizonResult receiveParameter(const Applets::Parameter& parameter) override;
virtual void reset() override;
ErrorApplet(Memory& memory, std::optional<Parameter>& nextParam) : AppletBase(memory, nextParam) {}
};
} // namespace Applets

View file

@ -4,13 +4,14 @@
using namespace Applets; using namespace Applets;
AppletManager::AppletManager(Memory& mem) : miiSelector(mem, nextParameter), swkbd(mem, nextParameter) {} AppletManager::AppletManager(Memory& mem) : miiSelector(mem, nextParameter), swkbd(mem, nextParameter), error(mem, nextParameter) {}
void AppletManager::reset() { void AppletManager::reset() {
nextParameter = std::nullopt; nextParameter = std::nullopt;
miiSelector.reset(); miiSelector.reset();
swkbd.reset(); swkbd.reset();
error.reset();
} }
AppletBase* AppletManager::getApplet(u32 id) { AppletBase* AppletManager::getApplet(u32 id) {
@ -21,6 +22,9 @@ AppletBase* AppletManager::getApplet(u32 id) {
case AppletIDs::SoftwareKeyboard: case AppletIDs::SoftwareKeyboard:
case AppletIDs::SoftwareKeyboard2: return &swkbd; case AppletIDs::SoftwareKeyboard2: return &swkbd;
case AppletIDs::ErrDisp:
case AppletIDs::ErrDisp2: return &error;
default: return nullptr; default: return nullptr;
} }
} }

View file

@ -0,0 +1,32 @@
#include "applets/error_applet.hpp"
#include "kernel/handles.hpp"
using namespace Applets;
void ErrorApplet::reset() {}
Result::HorizonResult ErrorApplet::start(const MemoryBlock* sharedMem, const std::vector<u8>& parameters, u32 appID) {
Applets::Parameter param = Applets::Parameter{
.senderID = appID,
.destID = AppletIDs::Application,
.signal = static_cast<u32>(APTSignal::WakeupByExit),
.object = 0,
.data = parameters, // TODO: Figure out how the data format for this applet
};
nextParameter = param;
return Result::Success;
}
Result::HorizonResult ErrorApplet::receiveParameter(const Applets::Parameter& parameter) {
Applets::Parameter param = Applets::Parameter{
.senderID = parameter.destID,
.destID = AppletIDs::Application,
.signal = static_cast<u32>(APTSignal::Response),
.object = KernelHandles::APTCaptureSharedMemHandle,
.data = {},
};
nextParameter = param;
return Result::Success;
}

View file

@ -35,8 +35,6 @@ Result::HorizonResult MiiSelectorApplet::start(const MemoryBlock* sharedMem, con
} }
Result::HorizonResult MiiSelectorApplet::receiveParameter(const Applets::Parameter& parameter) { Result::HorizonResult MiiSelectorApplet::receiveParameter(const Applets::Parameter& parameter) {
Helpers::warn("Mii Selector: Unimplemented ReceiveParameter");
Applets::Parameter param = Applets::Parameter{ Applets::Parameter param = Applets::Parameter{
.senderID = parameter.destID, .senderID = parameter.destID,
.destID = AppletIDs::Application, .destID = AppletIDs::Application,

View file

@ -10,8 +10,6 @@ using namespace Applets;
void SoftwareKeyboardApplet::reset() {} void SoftwareKeyboardApplet::reset() {}
Result::HorizonResult SoftwareKeyboardApplet::receiveParameter(const Applets::Parameter& parameter) { Result::HorizonResult SoftwareKeyboardApplet::receiveParameter(const Applets::Parameter& parameter) {
Helpers::warn("Software keyboard: Unimplemented ReceiveParameter");
switch (parameter.signal) { switch (parameter.signal) {
// Signal == request -> Applet is asking swkbd for a shared memory handle for backing up the framebuffer before opening the applet // Signal == request -> Applet is asking swkbd for a shared memory handle for backing up the framebuffer before opening the applet
case u32(APTSignal::Request): { case u32(APTSignal::Request): {