From e05e6853faf8563702963f384fb1486cda77c841 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 17 Mar 2022 03:01:03 -0400 Subject: applets: Rename Mii to MiiEdit --- src/core/hle/service/am/applets/applet_mii.cpp | 100 -------------------- src/core/hle/service/am/applets/applet_mii.h | 90 ------------------ .../hle/service/am/applets/applet_mii_edit.cpp | 101 +++++++++++++++++++++ src/core/hle/service/am/applets/applet_mii_edit.h | 90 ++++++++++++++++++ src/core/hle/service/am/applets/applets.cpp | 28 +++--- src/core/hle/service/am/applets/applets.h | 8 +- 6 files changed, 209 insertions(+), 208 deletions(-) delete mode 100644 src/core/hle/service/am/applets/applet_mii.cpp delete mode 100644 src/core/hle/service/am/applets/applet_mii.h create mode 100644 src/core/hle/service/am/applets/applet_mii_edit.cpp create mode 100644 src/core/hle/service/am/applets/applet_mii_edit.h (limited to 'src/core/hle/service/am/applets') diff --git a/src/core/hle/service/am/applets/applet_mii.cpp b/src/core/hle/service/am/applets/applet_mii.cpp deleted file mode 100644 index facede97e..000000000 --- a/src/core/hle/service/am/applets/applet_mii.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2022 yuzu Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "common/assert.h" -#include "common/logging/log.h" -#include "core/core.h" -#include "core/frontend/applets/mii.h" -#include "core/hle/service/am/am.h" -#include "core/hle/service/am/applets/applet_mii.h" - -namespace Service::AM::Applets { - -Mii::Mii(Core::System& system_, LibraryAppletMode applet_mode_, - const Core::Frontend::MiiApplet& frontend_) - : Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {} - -Mii::~Mii() = default; - -void Mii::Initialize() { - is_complete = false; - - const auto storage = broker.PopNormalDataToApplet(); - ASSERT(storage != nullptr); - - const auto data = storage->GetData(); - ASSERT(data.size() == sizeof(MiiAppletInput)); - - std::memcpy(&input_data, data.data(), sizeof(MiiAppletInput)); -} - -bool Mii::TransactionComplete() const { - return is_complete; -} - -ResultCode Mii::GetStatus() const { - return ResultSuccess; -} - -void Mii::ExecuteInteractive() { - UNREACHABLE_MSG("Unexpected interactive applet data!"); -} - -void Mii::Execute() { - if (is_complete) { - return; - } - - const auto callback = [this](const Core::Frontend::MiiParameters& parameters) { - DisplayCompleted(parameters); - }; - - switch (input_data.applet_mode) { - case MiiAppletMode::ShowMiiEdit: { - Service::Mii::MiiManager manager; - Core::Frontend::MiiParameters params{ - .is_editable = false, - .mii_data = input_data.mii_char_info.mii_data, - }; - frontend.ShowMii(params, callback); - break; - } - case MiiAppletMode::EditMii: { - Service::Mii::MiiManager manager; - Core::Frontend::MiiParameters params{ - .is_editable = true, - .mii_data = input_data.mii_char_info.mii_data, - }; - frontend.ShowMii(params, callback); - break; - } - case MiiAppletMode::CreateMii: { - Service::Mii::MiiManager manager; - Core::Frontend::MiiParameters params{ - .is_editable = true, - .mii_data = manager.BuildDefault(0), - }; - frontend.ShowMii(params, callback); - break; - } - default: - UNIMPLEMENTED_MSG("Unimplemented LibAppletMiiEdit mode={:02X}!", input_data.applet_mode); - } -} - -void Mii::DisplayCompleted(const Core::Frontend::MiiParameters& parameters) { - is_complete = true; - - std::vector reply(sizeof(AppletOutputForCharInfoEditing)); - output_data = { - .result = ResultSuccess, - .mii_data = parameters.mii_data, - }; - - std::memcpy(reply.data(), &output_data, sizeof(AppletOutputForCharInfoEditing)); - broker.PushNormalDataFromApplet(std::make_shared(system, std::move(reply))); - broker.SignalStateChanged(); -} - -} // namespace Service::AM::Applets diff --git a/src/core/hle/service/am/applets/applet_mii.h b/src/core/hle/service/am/applets/applet_mii.h deleted file mode 100644 index 42326bfc2..000000000 --- a/src/core/hle/service/am/applets/applet_mii.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2022 yuzu Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include - -#include "core/hle/result.h" -#include "core/hle/service/am/applets/applets.h" -#include "core/hle/service/mii/mii_manager.h" - -namespace Core { -class System; -} - -namespace Service::AM::Applets { - -// This is nn::mii::AppletMode -enum class MiiAppletMode : u32 { - ShowMiiEdit = 0, - AppendMii = 1, - AppendMiiImage = 2, - UpdateMiiImage = 3, - CreateMii = 4, - EditMii = 5, -}; - -struct MiiCharInfo { - Service::Mii::MiiInfo mii_data{}; - INSERT_PADDING_BYTES(0x28); -}; -static_assert(sizeof(MiiCharInfo) == 0x80, "MiiCharInfo has incorrect size."); - -// This is nn::mii::AppletInput -struct MiiAppletInput { - s32 version{}; - MiiAppletMode applet_mode{}; - u32 special_mii_key_code{}; - union { - std::array valid_uuid; - MiiCharInfo mii_char_info; - }; - Common::UUID used_uuid; - INSERT_PADDING_BYTES(0x64); -}; -static_assert(sizeof(MiiAppletInput) == 0x100, "MiiAppletInput has incorrect size."); - -// This is nn::mii::AppletOutput -struct MiiAppletOutput { - ResultCode result{ResultSuccess}; - s32 index{}; - INSERT_PADDING_BYTES(0x18); -}; -static_assert(sizeof(MiiAppletOutput) == 0x20, "MiiAppletOutput has incorrect size."); - -// This is nn::mii::AppletOutputForCharInfoEditing -struct AppletOutputForCharInfoEditing { - ResultCode result{ResultSuccess}; - Service::Mii::MiiInfo mii_data{}; - INSERT_PADDING_BYTES(0x24); -}; -static_assert(sizeof(AppletOutputForCharInfoEditing) == 0x80, - "AppletOutputForCharInfoEditing has incorrect size."); - -class Mii final : public Applet { -public: - explicit Mii(Core::System& system_, LibraryAppletMode applet_mode_, - const Core::Frontend::MiiApplet& frontend_); - ~Mii() override; - - void Initialize() override; - - bool TransactionComplete() const override; - ResultCode GetStatus() const override; - void ExecuteInteractive() override; - void Execute() override; - - void DisplayCompleted(const Core::Frontend::MiiParameters& parameters); - -private: - const Core::Frontend::MiiApplet& frontend; - MiiAppletInput input_data{}; - AppletOutputForCharInfoEditing output_data{}; - - bool is_complete = false; - Core::System& system; -}; - -} // namespace Service::AM::Applets diff --git a/src/core/hle/service/am/applets/applet_mii_edit.cpp b/src/core/hle/service/am/applets/applet_mii_edit.cpp new file mode 100644 index 000000000..ec57d98bd --- /dev/null +++ b/src/core/hle/service/am/applets/applet_mii_edit.cpp @@ -0,0 +1,101 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/assert.h" +#include "common/logging/log.h" +#include "core/core.h" +#include "core/frontend/applets/mii_edit.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/am/applets/applet_mii_edit.h" +#include "core/reporter.h" + +namespace Service::AM::Applets { + +MiiEdit::MiiEdit(Core::System& system_, LibraryAppletMode applet_mode_, + const Core::Frontend::MiiEditApplet& frontend_) + : Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {} + +MiiEdit::~MiiEdit() = default; + +void MiiEdit::Initialize() { + is_complete = false; + + const auto storage = broker.PopNormalDataToApplet(); + ASSERT(storage != nullptr); + + const auto data = storage->GetData(); + ASSERT(data.size() == sizeof(MiiAppletInput)); + + std::memcpy(&input_data, data.data(), sizeof(MiiAppletInput)); +} + +bool MiiEdit::TransactionComplete() const { + return is_complete; +} + +ResultCode MiiEdit::GetStatus() const { + return ResultSuccess; +} + +void MiiEdit::ExecuteInteractive() { + UNREACHABLE_MSG("Unexpected interactive applet data!"); +} + +void MiiEdit::Execute() { + if (is_complete) { + return; + } + + const auto callback = [this](const Core::Frontend::MiiParameters& parameters) { + DisplayCompleted(parameters); + }; + + switch (input_data.applet_mode) { + case MiiAppletMode::ShowMiiEdit: { + Service::Mii::MiiManager manager; + Core::Frontend::MiiParameters params{ + .is_editable = false, + .mii_data = input_data.mii_char_info.mii_data, + }; + frontend.ShowMii(params, callback); + break; + } + case MiiAppletMode::EditMii: { + Service::Mii::MiiManager manager; + Core::Frontend::MiiParameters params{ + .is_editable = true, + .mii_data = input_data.mii_char_info.mii_data, + }; + frontend.ShowMii(params, callback); + break; + } + case MiiAppletMode::CreateMii: { + Service::Mii::MiiManager manager; + Core::Frontend::MiiParameters params{ + .is_editable = true, + .mii_data = manager.BuildDefault(0), + }; + frontend.ShowMii(params, callback); + break; + } + default: + UNIMPLEMENTED_MSG("Unimplemented LibAppletMiiEdit mode={:02X}!", input_data.applet_mode); + } +} + +void MiiEdit::DisplayCompleted(const Core::Frontend::MiiParameters& parameters) { + is_complete = true; + + std::vector reply(sizeof(AppletOutputForCharInfoEditing)); + output_data = { + .result = ResultSuccess, + .mii_data = parameters.mii_data, + }; + + std::memcpy(reply.data(), &output_data, sizeof(AppletOutputForCharInfoEditing)); + broker.PushNormalDataFromApplet(std::make_shared(system, std::move(reply))); + broker.SignalStateChanged(); +} + +} // namespace Service::AM::Applets diff --git a/src/core/hle/service/am/applets/applet_mii_edit.h b/src/core/hle/service/am/applets/applet_mii_edit.h new file mode 100644 index 000000000..828f28da4 --- /dev/null +++ b/src/core/hle/service/am/applets/applet_mii_edit.h @@ -0,0 +1,90 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "core/hle/result.h" +#include "core/hle/service/am/applets/applets.h" +#include "core/hle/service/mii/mii_manager.h" + +namespace Core { +class System; +} + +namespace Service::AM::Applets { + +// This is nn::mii::AppletMode +enum class MiiAppletMode : u32 { + ShowMiiEdit = 0, + AppendMii = 1, + AppendMiiImage = 2, + UpdateMiiImage = 3, + CreateMii = 4, + EditMii = 5, +}; + +struct MiiCharInfo { + Service::Mii::MiiInfo mii_data{}; + INSERT_PADDING_BYTES(0x28); +}; +static_assert(sizeof(MiiCharInfo) == 0x80, "MiiCharInfo has incorrect size."); + +// This is nn::mii::AppletInput +struct MiiAppletInput { + s32 version{}; + MiiAppletMode applet_mode{}; + u32 special_mii_key_code{}; + union { + std::array valid_uuid; + MiiCharInfo mii_char_info; + }; + Common::UUID used_uuid; + INSERT_PADDING_BYTES(0x64); +}; +static_assert(sizeof(MiiAppletInput) == 0x100, "MiiAppletInput has incorrect size."); + +// This is nn::mii::AppletOutput +struct MiiAppletOutput { + ResultCode result{ResultSuccess}; + s32 index{}; + INSERT_PADDING_BYTES(0x18); +}; +static_assert(sizeof(MiiAppletOutput) == 0x20, "MiiAppletOutput has incorrect size."); + +// This is nn::mii::AppletOutputForCharInfoEditing +struct AppletOutputForCharInfoEditing { + ResultCode result{ResultSuccess}; + Service::Mii::MiiInfo mii_data{}; + INSERT_PADDING_BYTES(0x24); +}; +static_assert(sizeof(AppletOutputForCharInfoEditing) == 0x80, + "AppletOutputForCharInfoEditing has incorrect size."); + +class MiiEdit final : public Applet { +public: + explicit MiiEdit(Core::System& system_, LibraryAppletMode applet_mode_, + const Core::Frontend::MiiEditApplet& frontend_); + ~MiiEdit() override; + + void Initialize() override; + + bool TransactionComplete() const override; + ResultCode GetStatus() const override; + void ExecuteInteractive() override; + void Execute() override; + + void DisplayCompleted(const Core::Frontend::MiiParameters& parameters); + +private: + const Core::Frontend::MiiEditApplet& frontend; + MiiAppletInput input_data{}; + AppletOutputForCharInfoEditing output_data{}; + + bool is_complete = false; + Core::System& system; +}; + +} // namespace Service::AM::Applets diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 79e62679d..1f4c9786a 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -9,7 +9,7 @@ #include "core/frontend/applets/controller.h" #include "core/frontend/applets/error.h" #include "core/frontend/applets/general_frontend.h" -#include "core/frontend/applets/mii.h" +#include "core/frontend/applets/mii_edit.h" #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" @@ -20,7 +20,7 @@ #include "core/hle/service/am/applets/applet_controller.h" #include "core/hle/service/am/applets/applet_error.h" #include "core/hle/service/am/applets/applet_general_backend.h" -#include "core/hle/service/am/applets/applet_mii.h" +#include "core/hle/service/am/applets/applet_mii_edit.h" #include "core/hle/service/am/applets/applet_profile_select.h" #include "core/hle/service/am/applets/applet_software_keyboard.h" #include "core/hle/service/am/applets/applet_web_browser.h" @@ -173,12 +173,12 @@ void Applet::Initialize() { AppletFrontendSet::AppletFrontendSet() = default; AppletFrontendSet::AppletFrontendSet(ControllerApplet controller_applet, ErrorApplet error_applet, + MiiEdit mii_edit_, ParentalControlsApplet parental_controls_applet, - MiiApplet mii_applet, PhotoViewer photo_viewer_, - ProfileSelect profile_select_, + PhotoViewer photo_viewer_, ProfileSelect profile_select_, SoftwareKeyboard software_keyboard_, WebBrowser web_browser_) : controller{std::move(controller_applet)}, error{std::move(error_applet)}, - parental_controls{std::move(parental_controls_applet)}, mii{std::move(mii_applet)}, + mii_edit{std::move(mii_edit_)}, parental_controls{std::move(parental_controls_applet)}, photo_viewer{std::move(photo_viewer_)}, profile_select{std::move(profile_select_)}, software_keyboard{std::move(software_keyboard_)}, web_browser{std::move(web_browser_)} {} @@ -205,12 +205,12 @@ void AppletManager::SetAppletFrontendSet(AppletFrontendSet set) { frontend.error = std::move(set.error); } - if (set.parental_controls != nullptr) { - frontend.parental_controls = std::move(set.parental_controls); + if (set.mii_edit != nullptr) { + frontend.mii_edit = std::move(set.mii_edit); } - if (set.mii != nullptr) { - frontend.mii = std::move(set.mii); + if (set.parental_controls != nullptr) { + frontend.parental_controls = std::move(set.parental_controls); } if (set.photo_viewer != nullptr) { @@ -245,15 +245,15 @@ void AppletManager::SetDefaultAppletsIfMissing() { frontend.error = std::make_unique(); } + if (frontend.mii_edit == nullptr) { + frontend.mii_edit = std::make_unique(); + } + if (frontend.parental_controls == nullptr) { frontend.parental_controls = std::make_unique(); } - if (frontend.mii == nullptr) { - frontend.mii = std::make_unique(); - } - if (frontend.photo_viewer == nullptr) { frontend.photo_viewer = std::make_unique(); } @@ -289,7 +289,7 @@ std::shared_ptr AppletManager::GetApplet(AppletId id, LibraryAppletMode case AppletId::SoftwareKeyboard: return std::make_shared(system, mode, *frontend.software_keyboard); case AppletId::MiiEdit: - return std::make_shared(system, mode, *frontend.mii); + return std::make_shared(system, mode, *frontend.mii_edit); case AppletId::Web: case AppletId::Shop: case AppletId::OfflineWeb: diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 0c44aec79..50a7bdceb 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -20,8 +20,8 @@ namespace Core::Frontend { class ControllerApplet; class ECommerceApplet; class ErrorApplet; +class MiiEditApplet; class ParentalControlsApplet; -class MiiApplet; class PhotoViewerApplet; class ProfileSelectApplet; class SoftwareKeyboardApplet; @@ -179,8 +179,8 @@ protected: struct AppletFrontendSet { using ControllerApplet = std::unique_ptr; using ErrorApplet = std::unique_ptr; + using MiiEdit = std::unique_ptr; using ParentalControlsApplet = std::unique_ptr; - using MiiApplet = std::unique_ptr; using PhotoViewer = std::unique_ptr; using ProfileSelect = std::unique_ptr; using SoftwareKeyboard = std::unique_ptr; @@ -188,7 +188,7 @@ struct AppletFrontendSet { AppletFrontendSet(); AppletFrontendSet(ControllerApplet controller_applet, ErrorApplet error_applet, - ParentalControlsApplet parental_controls_applet, MiiApplet mii_applet, + MiiEdit mii_edit_, ParentalControlsApplet parental_controls_applet, PhotoViewer photo_viewer_, ProfileSelect profile_select_, SoftwareKeyboard software_keyboard_, WebBrowser web_browser_); ~AppletFrontendSet(); @@ -201,8 +201,8 @@ struct AppletFrontendSet { ControllerApplet controller; ErrorApplet error; + MiiEdit mii_edit; ParentalControlsApplet parental_controls; - MiiApplet mii; PhotoViewer photo_viewer; ProfileSelect profile_select; SoftwareKeyboard software_keyboard; -- cgit v1.2.3