applets/swkbd: Implement DefaultCitraKeyboard

This commit is contained in:
zhupengfei 2018-06-20 17:20:38 +08:00
parent 18664c719e
commit f23443b921
No known key found for this signature in database
GPG Key ID: 85B82A3E62174206
7 changed files with 61 additions and 6 deletions

View File

@ -35,6 +35,7 @@
#include "common/string_util.h"
#include "core/core.h"
#include "core/file_sys/cia_container.h"
#include "core/frontend/applets/default_applets.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/service/am/am.h"
#include "core/loader/loader.h"
@ -271,6 +272,9 @@ int main(int argc, char** argv) {
Settings::values.movie_record = std::move(movie_record);
Settings::Apply();
// Register frontend applets
Frontend::RegisterDefaultApplets();
std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)};
Core::System& system{Core::System::GetInstance()};

View File

@ -50,6 +50,7 @@
#include "common/string_util.h"
#include "core/core.h"
#include "core/file_sys/archive_source_sd_savedata.h"
#include "core/frontend/applets/default_applets.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/service/fs/archive.h"
#include "core/loader/loader.h"
@ -1467,6 +1468,9 @@ int main(int argc, char* argv[]) {
Camera::RegisterFactory("qt", std::make_unique<Camera::QtMultimediaCameraFactory>());
Camera::QtMultimediaCameraHandler::Init();
// Register frontend applets
Frontend::RegisterDefaultApplets();
main_window.show();
return app.exec();
}

View File

@ -68,6 +68,8 @@ add_library(core STATIC
file_sys/savedata_archive.h
file_sys/title_metadata.cpp
file_sys/title_metadata.h
frontend/applets/default_applets.cpp
frontend/applets/default_applets.h
frontend/applets/interface.cpp
frontend/applets/interface.h
frontend/applets/swkbd.cpp

View File

@ -0,0 +1,13 @@
// Copyright 2018 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/frontend/applets/default_applets.h"
#include "core/frontend/applets/interface.h"
#include "core/frontend/applets/swkbd.h"
namespace Frontend {
void RegisterDefaultApplets() {
RegisterFrontendApplet(std::make_shared<DefaultCitraKeyboard>(), AppletType::SoftwareKeyboard);
}
} // namespace Frontend

View File

@ -0,0 +1,13 @@
// Copyright 2018 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
namespace Frontend {
/**
* Registers default, frontend-independent applet implementations.
* Will be replaced later if any frontend-specific implementation is available.
*/
void RegisterDefaultApplets();
} // namespace Frontend

View File

@ -9,6 +9,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include "common/assert.h"
#include "core/frontend/applets/interface.h"
namespace Frontend {
@ -93,12 +94,12 @@ enum class ValidationError {
class SoftwareKeyboard : public AppletInterface {
public:
explicit SoftwareKeyboard() : AppletInterface() {}
const AppletData* ReceiveData() override {
return &data;
}
void Setup(const AppletConfig* config) override {
this->config = KeyboardConfig(*static_cast<const KeyboardConfig*>(config));
}
const AppletData* ReceiveData() override {
return &data;
}
protected:
/**
@ -126,9 +127,29 @@ protected:
*/
ValidationError Finalize(const std::string& text, u8 button);
private:
KeyboardConfig config;
KeyboardData data;
};
class DefaultCitraKeyboard final : public SoftwareKeyboard {
public:
void Setup(const AppletConfig* config) override {
SoftwareKeyboard::Setup(config);
switch (this->config.button_config) {
case ButtonConfig::None:
case ButtonConfig::Single:
Finalize("Citra", 0);
break;
case ButtonConfig::Dual:
Finalize("Citra", 1);
break;
case ButtonConfig::Triple:
Finalize("Citra", 2);
break;
default:
UNREACHABLE();
}
}
};
} // namespace Frontend

View File

@ -174,8 +174,6 @@ struct SoftwareKeyboardConfig {
*/
static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config size is wrong");
class DefaultCitraKeyboard : Frontend::AppletInterface {};
class SoftwareKeyboard final : public Applet {
public:
SoftwareKeyboard(Service::APT::AppletId id, std::weak_ptr<Service::APT::AppletManager> manager)