From f23443b921132db0057284e40c0de8c9209405fc Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Wed, 20 Jun 2018 17:20:38 +0800 Subject: [PATCH] applets/swkbd: Implement DefaultCitraKeyboard --- src/citra/citra.cpp | 4 +++ src/citra_qt/main.cpp | 4 +++ src/core/CMakeLists.txt | 2 ++ src/core/frontend/applets/default_applets.cpp | 13 +++++++++ src/core/frontend/applets/default_applets.h | 13 +++++++++ src/core/frontend/applets/swkbd.h | 29 ++++++++++++++++--- src/core/hle/applets/swkbd.h | 2 -- 7 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 src/core/frontend/applets/default_applets.cpp create mode 100644 src/core/frontend/applets/default_applets.h diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 08a05c558..8ecc1b202 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -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 emu_window{std::make_unique(fullscreen)}; Core::System& system{Core::System::GetInstance()}; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index ff16a0006..b44410be6 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -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::QtMultimediaCameraHandler::Init(); + // Register frontend applets + Frontend::RegisterDefaultApplets(); + main_window.show(); return app.exec(); } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8e291294e..2bf9e7fd0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/frontend/applets/default_applets.cpp b/src/core/frontend/applets/default_applets.cpp new file mode 100644 index 000000000..4edde4d69 --- /dev/null +++ b/src/core/frontend/applets/default_applets.cpp @@ -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(), AppletType::SoftwareKeyboard); +} +} // namespace Frontend diff --git a/src/core/frontend/applets/default_applets.h b/src/core/frontend/applets/default_applets.h new file mode 100644 index 000000000..d537b7bf0 --- /dev/null +++ b/src/core/frontend/applets/default_applets.h @@ -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 diff --git a/src/core/frontend/applets/swkbd.h b/src/core/frontend/applets/swkbd.h index aef2d7c0c..d38adf43d 100644 --- a/src/core/frontend/applets/swkbd.h +++ b/src/core/frontend/applets/swkbd.h @@ -9,6 +9,7 @@ #include #include #include +#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(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 diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index 4ba0e36b4..4b9f21ce1 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h @@ -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 manager)