Address first batch of review comments

This commit is contained in:
fearlessTobi 2019-02-15 19:20:06 +01:00
parent 041638ea4d
commit 781d4b787a
14 changed files with 91 additions and 131 deletions

View File

@ -11,66 +11,58 @@
#include "common/file_util.h" #include "common/file_util.h"
#include "core/file_sys/archive_extsavedata.h" #include "core/file_sys/archive_extsavedata.h"
#include "core/file_sys/file_backend.h" #include "core/file_sys/file_backend.h"
#include "core/hle/applets/buttons.h"
#include "core/hle/service/ptm/ptm.h" #include "core/hle/service/ptm/ptm.h"
QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_) QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_)
: QDialog(parent), mii_selector(mii_selector_) { : QDialog(parent), mii_selector(mii_selector_) {
Frontend::MiiSelectorConfig config = mii_selector->config; using namespace Frontend;
const auto config = mii_selector->config;
layout = new QVBoxLayout; layout = new QVBoxLayout;
combobox = new QComboBox; combobox = new QComboBox;
buttons = new QDialogButtonBox; buttons = new QDialogButtonBox;
// Initialize buttons // Initialize buttons
buttons->addButton(tr(AppletButton::Ok), QDialogButtonBox::ButtonRole::AcceptRole); buttons->addButton(tr(MII_BUTTON_OKAY), QDialogButtonBox::ButtonRole::AcceptRole);
if (config.enable_cancel_button) { if (config.enable_cancel_button) {
buttons->addButton(tr(AppletButton::Cancel), QDialogButtonBox::ButtonRole::RejectRole); buttons->addButton(tr(MII_BUTTON_CANCEL), QDialogButtonBox::ButtonRole::RejectRole);
} }
setWindowTitle(config.title.empty() ? tr("Mii Selector") setWindowTitle(config.title.empty() ? tr("Mii Selector")
: QString::fromStdU16String(config.title)); : QString::fromStdU16String(config.title));
miis.push_back(HLE::Applets::MiiSelector::GetStandardMiiResult().selected_mii_data);
combobox->addItem(tr("Standard Mii"));
std::string nand_directory{FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)}; std::string nand_directory{FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)};
FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true);
auto archive_result = extdata_archive_factory.Open(Service::PTM::ptm_shared_extdata_id); auto archive_result = extdata_archive_factory.Open(Service::PTM::ptm_shared_extdata_id);
if (!archive_result.Succeeded()) { if (archive_result.Succeeded()) {
ShowNoMiis(); auto archive = std::move(archive_result).Unwrap();
return;
}
auto archive = std::move(archive_result).Unwrap(); FileSys::Path file_path = "/CFL_DB.dat";
FileSys::Mode mode{};
mode.read_flag.Assign(1);
FileSys::Path file_path = "/CFL_DB.dat"; auto file_result = archive->OpenFile(file_path, mode);
FileSys::Mode mode{}; if (file_result.Succeeded()) {
mode.read_flag.Assign(1); auto file = std::move(file_result).Unwrap();
auto file_result = archive->OpenFile(file_path, mode); u32 saved_miis_offset = 0x8;
if (!file_result.Succeeded()) { // The Mii Maker has a 100 Mii limit on the 3ds
ShowNoMiis(); for (int i = 0; i < 100; ++i) {
return; HLE::Applets::MiiData mii;
} std::array<u8, sizeof(mii)> mii_raw;
file->Read(saved_miis_offset, sizeof(mii), mii_raw.data());
auto file = std::move(file_result).Unwrap(); std::memcpy(&mii, mii_raw.data(), sizeof(mii));
if (mii.mii_id != 0) {
u32 saved_miis_offset = 0x8; std::u16string name(sizeof(mii.mii_name), '\0');
// The Mii Maker has a 100 Mii limit on the 3ds std::memcpy(name.data(), mii.mii_name.data(), sizeof(mii.mii_name));
for (int i = 0; i < 100; ++i) { miis.push_back(mii);
HLE::Applets::MiiData mii; combobox->addItem(QString::fromStdU16String(name));
std::array<u8, sizeof(mii)> mii_raw; }
file->Read(saved_miis_offset, sizeof(mii), mii_raw.data()); saved_miis_offset += sizeof(mii);
std::memcpy(&mii, mii_raw.data(), sizeof(mii)); }
if (mii.mii_id != 0) {
std::u16string name(sizeof(mii.mii_name), '\0');
std::memcpy(&name[0], mii.mii_name.data(), sizeof(mii.mii_name));
miis.emplace(combobox->count(), mii);
combobox->addItem(QString::fromStdU16String(name));
} }
saved_miis_offset += sizeof(mii);
}
if (miis.empty()) {
ShowNoMiis();
return;
} }
if (combobox->count() > static_cast<int>(config.initially_selected_mii_index)) { if (combobox->count() > static_cast<int>(config.initially_selected_mii_index)) {
@ -87,22 +79,9 @@ QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_sel
setLayout(layout); setLayout(layout);
} }
void QtMiiSelectorDialog::ShowNoMiis() {
Frontend::MiiSelectorConfig config = mii_selector->config;
QMessageBox::StandardButton answer = QMessageBox::question(
nullptr,
config.title.empty() ? tr("Mii Selector") : QString::fromStdU16String(config.title),
tr("You don't have any Miis.\nUse standard Mii?"), QMessageBox::Yes | QMessageBox::No);
if (answer == QMessageBox::No)
return_code = 1;
QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
}
QtMiiSelector::QtMiiSelector(QWidget& parent_) : parent(parent_) {} QtMiiSelector::QtMiiSelector(QWidget& parent_) : parent(parent_) {}
void QtMiiSelector::Setup(const Frontend::MiiSelectorConfig* config) { void QtMiiSelector::Setup(const Frontend::MiiSelectorConfig& config) {
MiiSelector::Setup(config); MiiSelector::Setup(config);
QMetaObject::invokeMethod(this, "OpenDialog", Qt::BlockingQueuedConnection); QMetaObject::invokeMethod(this, "OpenDialog", Qt::BlockingQueuedConnection);
} }
@ -114,12 +93,11 @@ void QtMiiSelector::OpenDialog() {
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
dialog.exec(); dialog.exec();
int index = dialog.combobox->currentIndex(); const auto index = dialog.combobox->currentIndex();
LOG_INFO(Frontend, "Mii Selector dialog finished (return_code={}, index={})", LOG_INFO(Frontend, "Mii Selector dialog finished (return_code={}, index={})",
dialog.return_code, index); dialog.return_code, index);
HLE::Applets::MiiData mii_data = const auto mii_data = dialog.miis.at(index);
index == -1 ? HLE::Applets::MiiSelector::GetStandardMiiResult().selected_mii_data Finalize(dialog.return_code,
: dialog.miis.at(dialog.combobox->currentIndex()); dialog.return_code == 0 ? std::move(mii_data) : HLE::Applets::MiiData{});
Finalize(dialog.return_code, dialog.return_code == 0 ? mii_data : HLE::Applets::MiiData{});
} }

View File

@ -8,8 +8,8 @@
#include <QDialog> #include <QDialog>
#include "core/frontend/applets/mii_selector.h" #include "core/frontend/applets/mii_selector.h"
class QDialogButtonBox;
class QComboBox; class QComboBox;
class QDialogButtonBox;
class QVBoxLayout; class QVBoxLayout;
class QtMiiSelector; class QtMiiSelector;
@ -20,14 +20,12 @@ public:
QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_); QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_);
private: private:
void ShowNoMiis();
QDialogButtonBox* buttons; QDialogButtonBox* buttons;
QComboBox* combobox; QComboBox* combobox;
QVBoxLayout* layout; QVBoxLayout* layout;
QtMiiSelector* mii_selector; QtMiiSelector* mii_selector;
u32 return_code = 0; u32 return_code = 0;
std::unordered_map<int, HLE::Applets::MiiData> miis; std::vector<HLE::Applets::MiiData> miis;
friend class QtMiiSelector; friend class QtMiiSelector;
}; };
@ -37,7 +35,7 @@ class QtMiiSelector final : public QObject, public Frontend::MiiSelector {
public: public:
explicit QtMiiSelector(QWidget& parent); explicit QtMiiSelector(QWidget& parent);
void Setup(const Frontend::MiiSelectorConfig* config) override; void Setup(const Frontend::MiiSelectorConfig& config) override;
private: private:
Q_INVOKABLE void OpenDialog(); Q_INVOKABLE void OpenDialog();

View File

@ -25,7 +25,7 @@ QtKeyboardValidator::State QtKeyboardValidator::validate(QString& input, int& po
QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_) QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_)
: QDialog(parent), keyboard(keyboard_) { : QDialog(parent), keyboard(keyboard_) {
using namespace Frontend; using namespace Frontend;
KeyboardConfig config = keyboard->config; const auto config = keyboard->config;
layout = new QVBoxLayout; layout = new QVBoxLayout;
label = new QLabel(QString::fromStdString(config.hint_text)); label = new QLabel(QString::fromStdString(config.hint_text));
line_edit = new QLineEdit; line_edit = new QLineEdit;
@ -36,31 +36,31 @@ QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_)
case ButtonConfig::Triple: case ButtonConfig::Triple:
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[2]) ? QString::fromStdString(config.button_text[2])
: tr(BUTTON_OKAY), : tr(SWKBD_BUTTON_OKAY),
QDialogButtonBox::ButtonRole::AcceptRole); QDialogButtonBox::ButtonRole::AcceptRole);
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[1]) ? QString::fromStdString(config.button_text[1])
: tr(BUTTON_FORGOT), : tr(SWKBD_BUTTON_FORGOT),
QDialogButtonBox::ButtonRole::HelpRole); QDialogButtonBox::ButtonRole::HelpRole);
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[0]) ? QString::fromStdString(config.button_text[0])
: tr(BUTTON_CANCEL), : tr(SWKBD_BUTTON_CANCEL),
QDialogButtonBox::ButtonRole::RejectRole); QDialogButtonBox::ButtonRole::RejectRole);
break; break;
case ButtonConfig::Dual: case ButtonConfig::Dual:
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[1]) ? QString::fromStdString(config.button_text[1])
: tr(BUTTON_OKAY), : tr(SWKBD_BUTTON_OKAY),
QDialogButtonBox::ButtonRole::AcceptRole); QDialogButtonBox::ButtonRole::AcceptRole);
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[0]) ? QString::fromStdString(config.button_text[0])
: tr(BUTTON_CANCEL), : tr(SWKBD_BUTTON_CANCEL),
QDialogButtonBox::ButtonRole::RejectRole); QDialogButtonBox::ButtonRole::RejectRole);
break; break;
case ButtonConfig::Single: case ButtonConfig::Single:
buttons->addButton(config.has_custom_button_text buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[0]) ? QString::fromStdString(config.button_text[0])
: tr(BUTTON_OKAY), : tr(SWKBD_BUTTON_OKAY),
QDialogButtonBox::ButtonRole::AcceptRole); QDialogButtonBox::ButtonRole::AcceptRole);
break; break;
case ButtonConfig::None: case ButtonConfig::None:
@ -109,7 +109,7 @@ void QtKeyboardDialog::HandleValidationError(Frontend::ValidationError error) {
QtKeyboard::QtKeyboard(QWidget& parent_) : parent(parent_) {} QtKeyboard::QtKeyboard(QWidget& parent_) : parent(parent_) {}
void QtKeyboard::Setup(const Frontend::KeyboardConfig* config) { void QtKeyboard::Setup(const Frontend::KeyboardConfig& config) {
SoftwareKeyboard::Setup(config); SoftwareKeyboard::Setup(config);
if (this->config.button_config != Frontend::ButtonConfig::None) { if (this->config.button_config != Frontend::ButtonConfig::None) {
ok_id = static_cast<u8>(this->config.button_config); ok_id = static_cast<u8>(this->config.button_config);

View File

@ -48,7 +48,7 @@ class QtKeyboard final : public QObject, public Frontend::SoftwareKeyboard {
public: public:
explicit QtKeyboard(QWidget& parent); explicit QtKeyboard(QWidget& parent);
void Setup(const Frontend::KeyboardConfig* config) override; void Setup(const Frontend::KeyboardConfig& config) override;
private: private:
Q_INVOKABLE void OpenInputDialog(); Q_INVOKABLE void OpenInputDialog();

View File

@ -1897,8 +1897,8 @@ int main(int argc, char* argv[]) {
// Register frontend applets // Register frontend applets
Frontend::RegisterDefaultApplets(); Frontend::RegisterDefaultApplets();
Frontend::RegisterMiiSelector(std::make_shared<QtMiiSelector>(main_window)); Core::System::GetInstance().RegisterMiiSelector(std::make_shared<QtMiiSelector>(main_window));
Frontend::RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window)); Core::System::GetInstance().RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
main_window.show(); main_window.show();
int result = app.exec(); int result = app.exec();

View File

@ -40,6 +40,9 @@ public:
Path() : type(LowPathType::Invalid) {} Path() : type(LowPathType::Invalid) {}
Path(const char* path) : type(LowPathType::Char), string(path) {} Path(const char* path) : type(LowPathType::Char), string(path) {}
Path(std::vector<u8> binary_data) : type(LowPathType::Binary), binary(std::move(binary_data)) {} Path(std::vector<u8> binary_data) : type(LowPathType::Binary), binary(std::move(binary_data)) {}
template <std::size_t size>
Path(std::array<u8, size> binary_data)
: type(LowPathType::Binary), binary(binary_data.begin(), binary_data.end()) {}
Path(LowPathType type, const std::vector<u8>& data); Path(LowPathType type, const std::vector<u8>& data);
LowPathType GetType() const { LowPathType GetType() const {

View File

@ -2,13 +2,14 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/core.h"
#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/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>()); Core::System::GetInstance().RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
RegisterMiiSelector(std::make_shared<DefaultMiiSelector>()); Core::System::GetInstance().RegisterMiiSelector(std::make_shared<DefaultMiiSelector>());
} }
} // namespace Frontend } // namespace Frontend

View File

@ -2,7 +2,6 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/core.h"
#include "core/frontend/applets/mii_selector.h" #include "core/frontend/applets/mii_selector.h"
namespace Frontend { namespace Frontend {
@ -11,17 +10,9 @@ void MiiSelector::Finalize(u32 return_code, HLE::Applets::MiiData mii) {
data = {return_code, mii}; data = {return_code, mii};
} }
void DefaultMiiSelector::Setup(const Frontend::MiiSelectorConfig* config) { void DefaultMiiSelector::Setup(const Frontend::MiiSelectorConfig& config) {
MiiSelector::Setup(config); MiiSelector::Setup(config);
Finalize(0, HLE::Applets::MiiSelector::GetStandardMiiResult().selected_mii_data); 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 } // namespace Frontend

View File

@ -4,13 +4,16 @@
#pragma once #pragma once
#include <array>
#include <memory> #include <memory>
#include <string> #include <string>
#include "core/hle/applets/mii_selector.h" #include "core/hle/applets/mii_selector.h"
namespace Frontend { namespace Frontend {
/// Default English button text mappings. Frontends may need to copy this to internationalize it.
constexpr char MII_BUTTON_OKAY[] = "Ok";
constexpr char MII_BUTTON_CANCEL[] = "Cancel";
/// Configuration that's relevant to frontend implementation of applet. Anything missing that we /// 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 /// later learn is needed can be added here and filled in by the backend HLE applet
struct MiiSelectorConfig { struct MiiSelectorConfig {
@ -26,11 +29,12 @@ struct MiiSelectorData {
class MiiSelector { class MiiSelector {
public: public:
virtual void Setup(const MiiSelectorConfig* config) { virtual void Setup(const MiiSelectorConfig& config) {
this->config = MiiSelectorConfig(*config); this->config = MiiSelectorConfig(config);
} }
const MiiSelectorData* ReceiveData() {
return &data; const MiiSelectorData& ReceiveData() const {
return data;
} }
/** /**
@ -46,11 +50,7 @@ protected:
class DefaultMiiSelector final : public MiiSelector { class DefaultMiiSelector final : public MiiSelector {
public: public:
void Setup(const MiiSelectorConfig* config) override; void Setup(const MiiSelectorConfig& config) override;
}; };
void RegisterMiiSelector(std::shared_ptr<MiiSelector> applet);
std::shared_ptr<MiiSelector> GetRegisteredMiiSelector();
} // namespace Frontend } // namespace Frontend

View File

@ -135,7 +135,7 @@ ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) {
return ValidationError::None; return ValidationError::None;
} }
void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) { void DefaultKeyboard::Setup(const Frontend::KeyboardConfig& config) {
SoftwareKeyboard::Setup(config); SoftwareKeyboard::Setup(config);
auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); auto cfg = Service::CFG::GetModule(Core::System::GetInstance());
@ -157,12 +157,4 @@ void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) {
} }
} }
void RegisterSoftwareKeyboard(std::shared_ptr<SoftwareKeyboard> applet) {
Core::System::GetInstance().RegisterSoftwareKeyboard(applet);
}
std::shared_ptr<SoftwareKeyboard> GetRegisteredSoftwareKeyboard() {
return Core::System::GetInstance().GetSoftwareKeyboard();
}
} // namespace Frontend } // namespace Frontend

View File

@ -30,9 +30,9 @@ enum class ButtonConfig {
}; };
/// Default English button text mappings. Frontends may need to copy this to internationalize it. /// Default English button text mappings. Frontends may need to copy this to internationalize it.
constexpr char BUTTON_OKAY[] = "Ok"; constexpr char SWKBD_BUTTON_OKAY[] = "Ok";
constexpr char BUTTON_CANCEL[] = "Cancel"; constexpr char SWKBD_BUTTON_CANCEL[] = "Cancel";
constexpr char BUTTON_FORGOT[] = "I Forgot"; constexpr char SWKBD_BUTTON_FORGOT[] = "I Forgot";
/// Configuration thats relevent to frontend implementation of applets. Anything missing that we /// Configuration thats relevent to frontend implementation of applets. Anything missing that we
/// later learn is needed can be added here and filled in by the backend HLE applet /// later learn is needed can be added here and filled in by the backend HLE applet
@ -82,11 +82,12 @@ enum class ValidationError {
class SoftwareKeyboard { class SoftwareKeyboard {
public: public:
virtual void Setup(const KeyboardConfig* config) { virtual void Setup(const KeyboardConfig& config) {
this->config = KeyboardConfig(*config); this->config = KeyboardConfig(config);
} }
const KeyboardData* ReceiveData() {
return &data; const KeyboardData& ReceiveData() const {
return data;
} }
/** /**
@ -121,11 +122,7 @@ protected:
class DefaultKeyboard final : public SoftwareKeyboard { class DefaultKeyboard final : public SoftwareKeyboard {
public: public:
void Setup(const KeyboardConfig* config) override; void Setup(const KeyboardConfig& config) override;
}; };
void RegisterSoftwareKeyboard(std::shared_ptr<SoftwareKeyboard> applet);
std::shared_ptr<SoftwareKeyboard> GetRegisteredSoftwareKeyboard();
} // namespace Frontend } // namespace Frontend

View File

@ -60,11 +60,11 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
memcpy(&config, parameter.buffer.data(), parameter.buffer.size()); memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
using namespace Frontend; using namespace Frontend;
frontend_applet = GetRegisteredMiiSelector(); frontend_applet = Core::System::GetInstance().GetMiiSelector();
if (frontend_applet) { ASSERT(frontend_applet);
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
frontend_applet->Setup(&frontend_config); MiiSelectorConfig frontend_config = ToFrontendConfig(config);
} frontend_applet->Setup(frontend_config);
is_running = true; is_running = true;
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -72,9 +72,9 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
void MiiSelector::Update() { void MiiSelector::Update() {
using namespace Frontend; using namespace Frontend;
const MiiSelectorData* data = frontend_applet->ReceiveData(); const MiiSelectorData& data = frontend_applet->ReceiveData();
result.return_code = data->return_code; result.return_code = data.return_code;
result.selected_mii_data = data->mii; result.selected_mii_data = data.mii;
// Calculate the checksum of the selected Mii, see https://www.3dbrew.org/wiki/Mii#Checksum // Calculate the checksum of the selected Mii, see https://www.3dbrew.org/wiki/Mii#Checksum
result.mii_data_checksum = boost::crc<16, 0x1021, 0, 0, false, false>( result.mii_data_checksum = boost::crc<16, 0x1021, 0, 0, false, false>(
&result.selected_mii_data, sizeof(HLE::Applets::MiiData) + sizeof(result.unknown1)); &result.selected_mii_data, sizeof(HLE::Applets::MiiData) + sizeof(result.unknown1));

View File

@ -68,11 +68,11 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons
DrawScreenKeyboard(); DrawScreenKeyboard();
using namespace Frontend; using namespace Frontend;
frontend_applet = GetRegisteredSoftwareKeyboard(); frontend_applet = Core::System::GetInstance().GetSoftwareKeyboard();
if (frontend_applet) { ASSERT(frontend_applet);
KeyboardConfig frontend_config = ToFrontendConfig(config);
frontend_applet->Setup(&frontend_config); KeyboardConfig frontend_config = ToFrontendConfig(config);
} frontend_applet->Setup(frontend_config);
is_running = true; is_running = true;
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -80,7 +80,7 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons
void SoftwareKeyboard::Update() { void SoftwareKeyboard::Update() {
using namespace Frontend; using namespace Frontend;
KeyboardData data(*frontend_applet->ReceiveData()); KeyboardData data(frontend_applet->ReceiveData());
std::u16string text = Common::UTF8ToUTF16(data.text); std::u16string text = Common::UTF8ToUTF16(data.text);
memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t)); memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t));
switch (config.num_buttons_m1) { switch (config.num_buttons_m1) {

View File

@ -16,7 +16,7 @@ class System;
namespace Service::PTM { namespace Service::PTM {
/// Id of the SharedExtData archive used by the PTM process /// Id of the SharedExtData archive used by the PTM process
static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0}; constexpr std::array<u8, 12> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
/// Charge levels used by PTM functions /// Charge levels used by PTM functions
enum class ChargeLevels : u32 { enum class ChargeLevels : u32 {