From 2a6ebadf66051362cdcf07d722f7e2d3cee14c82 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 25 May 2015 23:30:20 -0500 Subject: HLE/APT: Initial HLE support for applets. Currently only the SWKBD is emulated, and there's currently no way to ask the user for input, so it always returns "Subv" as the text. --- src/core/hle/applets/swkbd.h | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/core/hle/applets/swkbd.h (limited to 'src/core/hle/applets/swkbd.h') diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h new file mode 100644 index 000000000..d7199690c --- /dev/null +++ b/src/core/hle/applets/swkbd.h @@ -0,0 +1,67 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" +#include "core/hle/applets/applet.h" +#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/shared_memory.h" +#include "core/hle/service/apt/apt.h" + +namespace HLE { +namespace Applets { + +struct SoftwareKeyboardConfig { + INSERT_PADDING_WORDS(0x8); + + u16 max_text_length; ///< Maximum length of the input text + + INSERT_PADDING_BYTES(0x6E); + + char16_t display_text[65]; ///< Text to display when asking the user for input + + INSERT_PADDING_BYTES(0xE); + + u32 default_text_offset; ///< Offset of the default text in the output SharedMemory + + INSERT_PADDING_WORDS(0x3); + + u32 shared_memory_size; ///< Size of the SharedMemory + + INSERT_PADDING_WORDS(0x1); + + u32 return_code; ///< Return code of the SoftwareKeyboard, usually 2, other values are unknown + + INSERT_PADDING_WORDS(0x2); + + u32 text_offset; ///< Offset in the SharedMemory where the output text starts + u16 text_length; ///< Length in characters of the output text + + INSERT_PADDING_BYTES(0x2B6); +}; + +static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config size is wrong"); + +class SoftwareKeyboard : public Applet { +public: + SoftwareKeyboard(Service::APT::AppletId id); + ~SoftwareKeyboard() {} + + ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) override; + ResultCode Start(Service::APT::AppletStartupParameter const& parameter) override; + + /// TODO(Subv): Find out what this is actually used for. + // It is believed that the application stores the current screen image here. + Kernel::SharedPtr framebuffer_memory; + + /// SharedMemory where the output text will be stored + Kernel::SharedPtr text_memory; + + /// Configuration of this instance of the SoftwareKeyboard, as received from the application + SoftwareKeyboardConfig config; +}; + +} +} // namespace -- cgit v1.2.3 From 621ee10eae0546d4ec3f9e911e113aa9ee609c22 Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 26 May 2015 11:00:26 -0500 Subject: Applets: Add infrastructure to allow custom drawing and input handling in Applets. --- src/core/hle/applets/swkbd.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/hle/applets/swkbd.h') diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index d7199690c..5970390c6 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h @@ -51,6 +51,19 @@ public: ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) override; ResultCode Start(Service::APT::AppletStartupParameter const& parameter) override; + void Update() override; + bool IsRunning() override { return started; } + + /** + * Draws a keyboard to the current bottom screen framebuffer. + */ + void DrawScreenKeyboard(); + + /** + * Sends the LibAppletClosing signal to the application, + * along with the relevant data buffers. + */ + void Finalize(); /// TODO(Subv): Find out what this is actually used for. // It is believed that the application stores the current screen image here. @@ -61,6 +74,9 @@ public: /// Configuration of this instance of the SoftwareKeyboard, as received from the application SoftwareKeyboardConfig config; + + /// Whether this applet is currently running instead of the host application or not. + bool started; }; } -- cgit v1.2.3 From 725d5eea7879fa152c51f15fd76003d3c6bc44ed Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 27 May 2015 15:21:06 -0500 Subject: Applets: Reworked how the Applet update event is handled. Applets are now cleaned up in AppletUpdateEvent after calling their respective Update method. --- src/core/hle/applets/swkbd.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/core/hle/applets/swkbd.h') diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index 5970390c6..98e81c48a 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h @@ -42,17 +42,21 @@ struct SoftwareKeyboardConfig { INSERT_PADDING_BYTES(0x2B6); }; +/** + * The size of this structure (0x400) has been verified via reverse engineering of multiple games + * that use the software keyboard. + */ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config size is wrong"); -class SoftwareKeyboard : public Applet { +class SoftwareKeyboard final : public Applet { public: SoftwareKeyboard(Service::APT::AppletId id); ~SoftwareKeyboard() {} - ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) override; - ResultCode Start(Service::APT::AppletStartupParameter const& parameter) override; + ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; + ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; void Update() override; - bool IsRunning() override { return started; } + bool IsRunning() const override { return started; } /** * Draws a keyboard to the current bottom screen framebuffer. @@ -65,13 +69,13 @@ public: */ void Finalize(); - /// TODO(Subv): Find out what this is actually used for. - // It is believed that the application stores the current screen image here. + /// TODO(Subv): Find out what this is actually used for. + /// It is believed that the application stores the current screen image here. Kernel::SharedPtr framebuffer_memory; /// SharedMemory where the output text will be stored Kernel::SharedPtr text_memory; - + /// Configuration of this instance of the SoftwareKeyboard, as received from the application SoftwareKeyboardConfig config; -- cgit v1.2.3