mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-27 04:40:05 +00:00
Implement Mii Selector
This commit is contained in:
parent
41eda5b019
commit
85be6f0c88
@ -10,6 +10,8 @@ add_executable(citra-qt
|
|||||||
Info.plist
|
Info.plist
|
||||||
aboutdialog.cpp
|
aboutdialog.cpp
|
||||||
aboutdialog.h
|
aboutdialog.h
|
||||||
|
applets/mii_selector.cpp
|
||||||
|
applets/mii_selector.h
|
||||||
applets/swkbd.cpp
|
applets/swkbd.cpp
|
||||||
applets/swkbd.h
|
applets/swkbd.h
|
||||||
bootmanager.cpp
|
bootmanager.cpp
|
||||||
|
117
src/citra_qt/applets/mii_selector.cpp
Normal file
117
src/citra_qt/applets/mii_selector.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "citra_qt/applets/mii_selector.h"
|
||||||
|
#include "common/file_util.h"
|
||||||
|
#include "core/file_sys/archive_extsavedata.h"
|
||||||
|
#include "core/file_sys/file_backend.h"
|
||||||
|
#include "core/hle/applets/buttons.h"
|
||||||
|
#include "core/hle/service/ptm/ptm.h"
|
||||||
|
|
||||||
|
QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_)
|
||||||
|
: QDialog(parent), mii_selector(mii_selector_) {
|
||||||
|
Frontend::MiiSelectorConfig config = mii_selector->config;
|
||||||
|
layout = new QVBoxLayout;
|
||||||
|
combobox = new QComboBox;
|
||||||
|
buttons = new QDialogButtonBox;
|
||||||
|
// Initialize buttons
|
||||||
|
buttons->addButton(tr(AppletButton::Ok), QDialogButtonBox::ButtonRole::AcceptRole);
|
||||||
|
if (config.enable_cancel_button) {
|
||||||
|
buttons->addButton(tr(AppletButton::Cancel), QDialogButtonBox::ButtonRole::RejectRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
setWindowTitle(config.title.empty() ? tr("Mii Selector")
|
||||||
|
: QString::fromStdU16String(config.title));
|
||||||
|
|
||||||
|
std::string nand_directory{FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)};
|
||||||
|
FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory{nand_directory, true};
|
||||||
|
|
||||||
|
auto archive_result{extdata_archive_factory.Open(Service::PTM::ptm_shared_extdata_id)};
|
||||||
|
if (!archive_result.Succeeded()) {
|
||||||
|
ShowNoMiis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto archive{std::move(archive_result).Unwrap()};
|
||||||
|
|
||||||
|
FileSys::Path file_path{"/CFL_DB.dat"};
|
||||||
|
FileSys::Mode mode{};
|
||||||
|
mode.read_flag.Assign(1);
|
||||||
|
|
||||||
|
auto file_result{archive->OpenFile(file_path, mode)};
|
||||||
|
if (!file_result.Succeeded()) {
|
||||||
|
ShowNoMiis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto file{std::move(file_result).Unwrap()};
|
||||||
|
|
||||||
|
u32 id;
|
||||||
|
u32 offset{0x8};
|
||||||
|
MiiData mii;
|
||||||
|
|
||||||
|
for (int i{}; i < 100; ++i) {
|
||||||
|
file->Read(offset, mii.size(), mii.data());
|
||||||
|
std::memcpy(&id, mii.data(), sizeof(u32));
|
||||||
|
if (id != 0) {
|
||||||
|
std::u16string name(10, '\0');
|
||||||
|
std::memcpy(&name[0], mii.data() + 0x1A, 0x14);
|
||||||
|
miis.emplace(combobox->count(), mii);
|
||||||
|
combobox->addItem(QString::fromStdU16String(name));
|
||||||
|
}
|
||||||
|
offset += mii.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (miis.empty()) {
|
||||||
|
ShowNoMiis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (combobox->count() >= static_cast<int>(config.initially_selected_mii_index)) {
|
||||||
|
combobox->setCurrentIndex(static_cast<int>(config.initially_selected_mii_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(buttons, &QDialogButtonBox::accepted, this, [=] { accept(); });
|
||||||
|
connect(buttons, &QDialogButtonBox::rejected, this, [=] {
|
||||||
|
return_code = 1;
|
||||||
|
accept();
|
||||||
|
});
|
||||||
|
layout->addWidget(combobox);
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMiiSelectorDialog::ShowNoMiis() {
|
||||||
|
Frontend::MiiSelectorConfig config = mii_selector->config;
|
||||||
|
QMessageBox::critical(nullptr,
|
||||||
|
config.title.empty() ? tr("Mii Selector")
|
||||||
|
: QString::fromStdU16String(config.title),
|
||||||
|
tr("You don't have Miis.\nCreate a Mii with Mii Maker."));
|
||||||
|
return_code = 1;
|
||||||
|
QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMiiSelector::QtMiiSelector(QWidget& parent_) : parent(parent_) {}
|
||||||
|
|
||||||
|
void QtMiiSelector::Setup(const Frontend::MiiSelectorConfig* config) {
|
||||||
|
MiiSelector::Setup(config);
|
||||||
|
QMetaObject::invokeMethod(this, "OpenDialog", Qt::BlockingQueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMiiSelector::OpenDialog() {
|
||||||
|
QtMiiSelectorDialog dialog(&parent, this);
|
||||||
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
|
dialog.exec();
|
||||||
|
LOG_INFO(Frontend, "Mii Selector dialog finished (return_code={}, index={})",
|
||||||
|
dialog.return_code, dialog.combobox->currentIndex());
|
||||||
|
Finalize(dialog.return_code,
|
||||||
|
dialog.return_code == 0 ? dialog.miis.at(dialog.combobox->currentIndex()) : MiiData{});
|
||||||
|
}
|
48
src/citra_qt/applets/mii_selector.h
Normal file
48
src/citra_qt/applets/mii_selector.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <QDialog>
|
||||||
|
#include "core/frontend/applets/mii_selector.h"
|
||||||
|
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QComboBox;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QtMiiSelector;
|
||||||
|
|
||||||
|
class QtMiiSelectorDialog final : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ShowNoMiis();
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons;
|
||||||
|
QComboBox* combobox;
|
||||||
|
QVBoxLayout* layout;
|
||||||
|
QtMiiSelector* mii_selector;
|
||||||
|
u32 return_code = 0;
|
||||||
|
std::unordered_map<int, MiiData> miis;
|
||||||
|
|
||||||
|
friend class QtMiiSelector;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtMiiSelector final : public QObject, public Frontend::MiiSelector {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QtMiiSelector(QWidget& parent);
|
||||||
|
void Setup(const Frontend::MiiSelectorConfig* config) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_INVOKABLE void OpenDialog();
|
||||||
|
|
||||||
|
QWidget& parent;
|
||||||
|
|
||||||
|
friend class QtMiiSelectorDialog;
|
||||||
|
};
|
@ -16,6 +16,7 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include "citra_qt/aboutdialog.h"
|
#include "citra_qt/aboutdialog.h"
|
||||||
|
#include "citra_qt/applets/mii_selector.h"
|
||||||
#include "citra_qt/applets/swkbd.h"
|
#include "citra_qt/applets/swkbd.h"
|
||||||
#include "citra_qt/bootmanager.h"
|
#include "citra_qt/bootmanager.h"
|
||||||
#include "citra_qt/camera/qt_multimedia_camera.h"
|
#include "citra_qt/camera/qt_multimedia_camera.h"
|
||||||
@ -1755,6 +1756,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// Register frontend applets
|
// Register frontend applets
|
||||||
Frontend::RegisterDefaultApplets();
|
Frontend::RegisterDefaultApplets();
|
||||||
|
Frontend::RegisterMiiSelector(std::make_shared<QtMiiSelector>(main_window));
|
||||||
Frontend::RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
|
Frontend::RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
|
||||||
|
|
||||||
main_window.show();
|
main_window.show();
|
||||||
|
@ -77,6 +77,8 @@ add_library(core STATIC
|
|||||||
file_sys/title_metadata.h
|
file_sys/title_metadata.h
|
||||||
frontend/applets/default_applets.cpp
|
frontend/applets/default_applets.cpp
|
||||||
frontend/applets/default_applets.h
|
frontend/applets/default_applets.h
|
||||||
|
frontend/applets/mii_selector.cpp
|
||||||
|
frontend/applets/mii_selector.h
|
||||||
frontend/applets/swkbd.cpp
|
frontend/applets/swkbd.cpp
|
||||||
frontend/applets/swkbd.h
|
frontend/applets/swkbd.h
|
||||||
frontend/camera/blank_camera.cpp
|
frontend/camera/blank_camera.cpp
|
||||||
|
@ -230,6 +230,10 @@ const Service::FS::ArchiveManager& System::ArchiveManager() const {
|
|||||||
return *archive_manager;
|
return *archive_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void System::RegisterMiiSelector(std::shared_ptr<Frontend::MiiSelector> mii_selector) {
|
||||||
|
registered_mii_selector = std::move(mii_selector);
|
||||||
|
}
|
||||||
|
|
||||||
void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd) {
|
void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd) {
|
||||||
registered_swkbd = std::move(swkbd);
|
registered_swkbd = std::move(swkbd);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/frontend/applets/mii_selector.h"
|
||||||
#include "core/frontend/applets/swkbd.h"
|
#include "core/frontend/applets/swkbd.h"
|
||||||
#include "core/hle/shared_page.h"
|
#include "core/hle/shared_page.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
@ -187,8 +188,13 @@ public:
|
|||||||
|
|
||||||
/// Frontend Applets
|
/// Frontend Applets
|
||||||
|
|
||||||
|
void RegisterMiiSelector(std::shared_ptr<Frontend::MiiSelector> mii_selector);
|
||||||
void RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd);
|
void RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd);
|
||||||
|
|
||||||
|
std::shared_ptr<Frontend::MiiSelector> GetMiiSelector() const {
|
||||||
|
return registered_mii_selector;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<Frontend::SoftwareKeyboard> GetSoftwareKeyboard() const {
|
std::shared_ptr<Frontend::SoftwareKeyboard> GetSoftwareKeyboard() const {
|
||||||
return registered_swkbd;
|
return registered_swkbd;
|
||||||
}
|
}
|
||||||
@ -229,6 +235,7 @@ private:
|
|||||||
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
||||||
|
|
||||||
/// Frontend applets
|
/// Frontend applets
|
||||||
|
std::shared_ptr<Frontend::MiiSelector> registered_mii_selector;
|
||||||
std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd;
|
std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd;
|
||||||
|
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/frontend/applets/default_applets.h"
|
#include "core/frontend/applets/default_applets.h"
|
||||||
|
#include "core/frontend/applets/mii_selector.h"
|
||||||
#include "core/frontend/applets/swkbd.h"
|
#include "core/frontend/applets/swkbd.h"
|
||||||
|
|
||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
void RegisterDefaultApplets() {
|
void RegisterDefaultApplets() {
|
||||||
RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
|
RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
|
||||||
|
RegisterMiiSelector(std::make_shared<DefaultMiiSelector>());
|
||||||
}
|
}
|
||||||
} // namespace Frontend
|
} // namespace Frontend
|
||||||
|
42
src/core/frontend/applets/mii_selector.cpp
Normal file
42
src/core/frontend/applets/mii_selector.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/frontend/applets/mii_selector.h"
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
|
||||||
|
// This data was obtained by writing the returned buffer in AppletManager::GlanceParameter of the
|
||||||
|
// LLEd Mii picker of version system version 11.8.0 to a file
|
||||||
|
static const std::array<u8, 132> mii = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x10,
|
||||||
|
0x30, 0xd2, 0x85, 0xb6, 0xb3, 0x00, 0xc8, 0x85, 0x0a, 0x98, 0x39, 0x1e, 0xe4, 0x40, 0xf4,
|
||||||
|
0x07, 0xb7, 0x37, 0x10, 0x00, 0x00, 0xa6, 0x00, 0x43, 0x00, 0x69, 0x00, 0x74, 0x00, 0x72,
|
||||||
|
0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40,
|
||||||
|
0x00, 0x00, 0x21, 0x01, 0x02, 0x68, 0x44, 0x18, 0x26, 0x34, 0x46, 0x14, 0x81, 0x12, 0x17,
|
||||||
|
0x68, 0x0d, 0x00, 0x00, 0x29, 0x00, 0x52, 0x48, 0x50, 0x66, 0x00, 0x6c, 0x00, 0x54, 0x00,
|
||||||
|
0x6f, 0x00, 0x62, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x05, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
void MiiSelector::Finalize(u32 return_code, MiiData mii) {
|
||||||
|
data = {return_code, mii};
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultMiiSelector::Setup(const Frontend::MiiSelectorConfig* config) {
|
||||||
|
MiiSelector::Setup(config);
|
||||||
|
HLE::Applets::MiiResult result;
|
||||||
|
std::memcpy(&result, mii.data(), mii.size());
|
||||||
|
Finalize(0, result.selected_mii_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterMiiSelector(std::shared_ptr<MiiSelector> applet) {
|
||||||
|
Core::System::GetInstance().RegisterMiiSelector(applet);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<MiiSelector> GetRegisteredMiiSelector() {
|
||||||
|
return Core::System::GetInstance().GetMiiSelector();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Frontend
|
56
src/core/frontend/applets/mii_selector.h
Normal file
56
src/core/frontend/applets/mii_selector.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright 2018 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include "core/hle/applets/mii_selector.h"
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
|
||||||
|
/// Configuration that's relevant to frontend implementation of applet. Anything missing that we
|
||||||
|
/// later learn is needed can be added here and filled in by the backend HLE applet
|
||||||
|
struct MiiSelectorConfig {
|
||||||
|
bool enable_cancel_button;
|
||||||
|
std::u16string title;
|
||||||
|
u32 initially_selected_mii_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MiiSelectorData {
|
||||||
|
u32 return_code;
|
||||||
|
MiiData mii;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MiiSelector {
|
||||||
|
public:
|
||||||
|
virtual void Setup(const MiiSelectorConfig* config) {
|
||||||
|
this->config = MiiSelectorConfig(*config);
|
||||||
|
}
|
||||||
|
const MiiSelectorData* ReceiveData() {
|
||||||
|
return &data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the data so that the HLE applet in core can
|
||||||
|
* send this to the calling application
|
||||||
|
*/
|
||||||
|
void Finalize(u32 return_code, MiiData mii);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MiiSelectorConfig config;
|
||||||
|
MiiSelectorData data;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DefaultMiiSelector final : public MiiSelector {
|
||||||
|
public:
|
||||||
|
void Setup(const MiiSelectorConfig* config) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RegisterMiiSelector(std::shared_ptr<MiiSelector> applet);
|
||||||
|
|
||||||
|
std::shared_ptr<MiiSelector> GetRegisteredMiiSelector();
|
||||||
|
|
||||||
|
} // namespace Frontend
|
@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <boost/crc.hpp>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
#include "core/frontend/applets/mii_selector.h"
|
||||||
#include "core/hle/applets/mii_selector.h"
|
#include "core/hle/applets/mii_selector.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/shared_memory.h"
|
#include "core/hle/kernel/shared_memory.h"
|
||||||
@ -54,19 +56,36 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
||||||
is_running = true;
|
|
||||||
|
|
||||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
|
||||||
// application.
|
|
||||||
// TODO(Subv): Reverse the parameter format for the Mii Selector
|
|
||||||
|
|
||||||
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
|
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
|
||||||
|
|
||||||
// TODO(Subv): Find more about this structure, result code 0 is enough to let most games
|
if (config.magic_value == MiiSelectorMagic) {
|
||||||
// continue.
|
using namespace Frontend;
|
||||||
MiiResult result;
|
frontend_applet = GetRegisteredMiiSelector();
|
||||||
memset(&result, 0, sizeof(result));
|
if (frontend_applet) {
|
||||||
result.return_code = 0;
|
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
|
||||||
|
frontend_applet->Setup(&frontend_config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Finalize();
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MiiSelector::Update() {}
|
||||||
|
|
||||||
|
void MiiSelector::Finalize() {
|
||||||
|
using namespace Frontend;
|
||||||
|
MiiResult result{};
|
||||||
|
if (config.magic_value != MiiSelectorMagic) {
|
||||||
|
result.return_code = 1;
|
||||||
|
} else {
|
||||||
|
const MiiSelectorData* data = frontend_applet->ReceiveData();
|
||||||
|
result.return_code = data->return_code;
|
||||||
|
std::memcpy(result.selected_mii_data.data(), data->mii.data(), data->mii.size());
|
||||||
|
result.mii_data_checksum = boost::crc<16, 0x1021, 0, 0, false, false>(
|
||||||
|
result.selected_mii_data.data(),
|
||||||
|
result.selected_mii_data.size() + sizeof(result.pad57));
|
||||||
|
result.selected_guest_mii_index = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
// Let the application know that we're closing
|
// Let the application know that we're closing
|
||||||
Service::APT::MessageParameter message;
|
Service::APT::MessageParameter message;
|
||||||
@ -78,9 +97,15 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
|
|||||||
SendParameter(message);
|
SendParameter(message);
|
||||||
|
|
||||||
is_running = false;
|
is_running = false;
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiiSelector::Update() {}
|
Frontend::MiiSelectorConfig MiiSelector::ToFrontendConfig(const MiiConfig& config) const {
|
||||||
|
Frontend::MiiSelectorConfig frontend_config;
|
||||||
|
frontend_config.enable_cancel_button = config.enable_cancel_button == 1;
|
||||||
|
std::u16string title{reinterpret_cast<const char16_t*>(config.title.data())};
|
||||||
|
frontend_config.title = title;
|
||||||
|
frontend_config.initially_selected_mii_index = config.initially_selected_mii_index;
|
||||||
|
return frontend_config;
|
||||||
|
}
|
||||||
} // namespace Applets
|
} // namespace Applets
|
||||||
} // namespace HLE
|
} // namespace HLE
|
||||||
|
@ -12,23 +12,32 @@
|
|||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/apt/apt.h"
|
#include "core/hle/service/apt/apt.h"
|
||||||
|
|
||||||
|
using MiiData = std::array<u8, 0x5C>;
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
class MiiSelector;
|
||||||
|
struct MiiSelectorConfig;
|
||||||
|
} // namespace Frontend
|
||||||
|
|
||||||
namespace HLE {
|
namespace HLE {
|
||||||
namespace Applets {
|
namespace Applets {
|
||||||
|
|
||||||
|
constexpr u32_le MiiSelectorMagic{0x13DE28CF};
|
||||||
|
|
||||||
struct MiiConfig {
|
struct MiiConfig {
|
||||||
u8 enable_cancel_button;
|
u8 enable_cancel_button;
|
||||||
u8 enable_guest_mii;
|
u8 enable_guest_mii;
|
||||||
u8 show_on_top_screen;
|
u8 show_on_top_screen;
|
||||||
INSERT_PADDING_BYTES(5);
|
INSERT_PADDING_BYTES(5);
|
||||||
u16 title[0x40];
|
std::array<u16_le, 0x40> title;
|
||||||
INSERT_PADDING_BYTES(4);
|
INSERT_PADDING_BYTES(4);
|
||||||
u8 show_guest_miis;
|
u8 show_guest_miis;
|
||||||
INSERT_PADDING_BYTES(3);
|
INSERT_PADDING_BYTES(3);
|
||||||
u32 initially_selected_mii_index;
|
u32_le initially_selected_mii_index;
|
||||||
u8 guest_mii_whitelist[6];
|
std::array<u8, 6> guest_mii_whitelist;
|
||||||
u8 user_mii_whitelist[0x64];
|
std::array<u8, 0x64> user_mii_whitelist;
|
||||||
INSERT_PADDING_BYTES(2);
|
INSERT_PADDING_BYTES(2);
|
||||||
u32 magic_value;
|
u32_le magic_value;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(MiiConfig) == 0x104, "MiiConfig structure has incorrect size");
|
static_assert(sizeof(MiiConfig) == 0x104, "MiiConfig structure has incorrect size");
|
||||||
#define ASSERT_REG_POSITION(field_name, position) \
|
#define ASSERT_REG_POSITION(field_name, position) \
|
||||||
@ -41,14 +50,13 @@ ASSERT_REG_POSITION(guest_mii_whitelist, 0x94);
|
|||||||
#undef ASSERT_REG_POSITION
|
#undef ASSERT_REG_POSITION
|
||||||
|
|
||||||
struct MiiResult {
|
struct MiiResult {
|
||||||
u32 return_code;
|
u32_le return_code;
|
||||||
u32 is_guest_mii_selected;
|
u32_le is_guest_mii_selected;
|
||||||
u32 selected_guest_mii_index;
|
u32_le selected_guest_mii_index;
|
||||||
// TODO(mailwl): expand to Mii Format structure: https://www.3dbrew.org/wiki/Mii
|
MiiData selected_mii_data;
|
||||||
u8 selected_mii_data[0x5C];
|
|
||||||
INSERT_PADDING_BYTES(2);
|
INSERT_PADDING_BYTES(2);
|
||||||
u16 mii_data_checksum;
|
u16_be mii_data_checksum;
|
||||||
u16 guest_mii_name[0xC];
|
std::array<u16_le, 0xC> guest_mii_name;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size");
|
static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size");
|
||||||
#define ASSERT_REG_POSITION(field_name, position) \
|
#define ASSERT_REG_POSITION(field_name, position) \
|
||||||
@ -67,13 +75,23 @@ public:
|
|||||||
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the LibAppletClosing signal to the application,
|
||||||
|
* along with the relevant data buffers.
|
||||||
|
*/
|
||||||
|
void Finalize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Frontend::MiiSelectorConfig ToFrontendConfig(const MiiConfig& config) const;
|
||||||
|
|
||||||
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
||||||
/// It holds the framebuffer info retrieved by the application with
|
/// It holds the framebuffer info retrieved by the application with
|
||||||
/// GSPGPU::ImportDisplayCaptureInfo
|
/// GSPGPU::ImportDisplayCaptureInfo
|
||||||
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
||||||
|
|
||||||
MiiConfig config;
|
MiiConfig config;
|
||||||
|
|
||||||
|
std::shared_ptr<Frontend::MiiSelector> frontend_applet;
|
||||||
};
|
};
|
||||||
} // namespace Applets
|
} // namespace Applets
|
||||||
} // namespace HLE
|
} // namespace HLE
|
||||||
|
Loading…
Reference in New Issue
Block a user