applets: implement HLE mii selector applet

This commit is contained in:
fearlessTobi 2019-02-09 17:00:57 +01:00
parent f903d3161d
commit 041638ea4d
12 changed files with 350 additions and 18 deletions

View file

@ -3,10 +3,12 @@
// Refer to the license.txt file included.
#include "core/frontend/applets/default_applets.h"
#include "core/frontend/applets/mii_selector.h"
#include "core/frontend/applets/swkbd.h"
namespace Frontend {
void RegisterDefaultApplets() {
RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
RegisterMiiSelector(std::make_shared<DefaultMiiSelector>());
}
} // namespace Frontend

View file

@ -0,0 +1,27 @@
// 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 {
void MiiSelector::Finalize(u32 return_code, HLE::Applets::MiiData mii) {
data = {return_code, mii};
}
void DefaultMiiSelector::Setup(const Frontend::MiiSelectorConfig* config) {
MiiSelector::Setup(config);
Finalize(0, HLE::Applets::MiiSelector::GetStandardMiiResult().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

View 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;
HLE::Applets::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, HLE::Applets::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