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/applet.h | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/core/hle/applets/applet.h (limited to 'src/core/hle/applets/applet.h') diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h new file mode 100644 index 000000000..221348d9c --- /dev/null +++ b/src/core/hle/applets/applet.h @@ -0,0 +1,53 @@ +// 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/kernel/kernel.h" +#include "core/hle/kernel/shared_memory.h" +#include "core/hle/service/apt/apt.h" + +namespace HLE { +namespace Applets { + +class Applet { +public: + virtual ~Applet() {}; + Applet(Service::APT::AppletId id) : id(id) {}; + + /** + * Creates an instance of the Applet subclass identified by the parameter + * and stores it in a global map. + * @param id Id of the applet to create + * @returns ResultCode Whether the operation was successful or not + */ + static ResultCode Create(Service::APT::AppletId id); + + /** + * Retrieves the Applet instance identified by the specified id + * @param id Id of the Applet to retrieve + * @returns Requested Applet or nullptr if not found + */ + static std::shared_ptr Get(Service::APT::AppletId id); + + /** + * Handles a parameter from the application + * @param parameter Parameter data to handle + * @returns ResultCode Whether the operation was successful or not + */ + virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0; + + /** + * Handles the Applet start event, triggered from the application + * @param parameter Parameter data to handle + * @returns ResultCode Whether the operation was successful or not + */ + virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0; + + Service::APT::AppletId id; ///< Id of this Applet +}; + +} +} // 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/applet.h | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'src/core/hle/applets/applet.h') diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index 221348d9c..f50f7d604 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h @@ -12,42 +12,59 @@ namespace HLE { namespace Applets { -class Applet { +class Applet : public std::enable_shared_from_this { public: virtual ~Applet() {}; Applet(Service::APT::AppletId id) : id(id) {}; /** - * Creates an instance of the Applet subclass identified by the parameter + * Creates an instance of the Applet subclass identified by the parameter. * and stores it in a global map. - * @param id Id of the applet to create - * @returns ResultCode Whether the operation was successful or not + * @param id Id of the applet to create. + * @returns ResultCode Whether the operation was successful or not. */ static ResultCode Create(Service::APT::AppletId id); /** - * Retrieves the Applet instance identified by the specified id - * @param id Id of the Applet to retrieve - * @returns Requested Applet or nullptr if not found + * Retrieves the Applet instance identified by the specified id. + * @param id Id of the Applet to retrieve. + * @returns Requested Applet or nullptr if not found. */ static std::shared_ptr Get(Service::APT::AppletId id); /** - * Handles a parameter from the application - * @param parameter Parameter data to handle - * @returns ResultCode Whether the operation was successful or not + * Handles a parameter from the application. + * @param parameter Parameter data to handle. + * @returns ResultCode Whether the operation was successful or not. */ virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0; /** - * Handles the Applet start event, triggered from the application - * @param parameter Parameter data to handle - * @returns ResultCode Whether the operation was successful or not + * Handles the Applet start event, triggered from the application. + * @param parameter Parameter data to handle. + * @returns ResultCode Whether the operation was successful or not. */ virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0; + /** + * Whether the applet is currently executing instead of the host application or not. + */ + virtual bool IsRunning() = 0; + + /** + * Handles an update tick for the Applet, lets it update the screen, send commands, etc. + */ + virtual void Update() = 0; + Service::APT::AppletId id; ///< Id of this Applet }; +/// Initializes the HLE applets +void Init(); + +/// Shuts down the HLE applets +void Shutdown(); + +extern std::shared_ptr g_current_applet; ///< Applet that is currently executing } } // namespace -- 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/applet.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/core/hle/applets/applet.h') diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index f50f7d604..fe537e70d 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h @@ -12,10 +12,10 @@ namespace HLE { namespace Applets { -class Applet : public std::enable_shared_from_this { +class Applet { public: - virtual ~Applet() {}; - Applet(Service::APT::AppletId id) : id(id) {}; + virtual ~Applet() { } + Applet(Service::APT::AppletId id) : id(id) { } /** * Creates an instance of the Applet subclass identified by the parameter. @@ -37,25 +37,33 @@ public: * @param parameter Parameter data to handle. * @returns ResultCode Whether the operation was successful or not. */ - virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0; + virtual ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) = 0; /** * Handles the Applet start event, triggered from the application. * @param parameter Parameter data to handle. * @returns ResultCode Whether the operation was successful or not. */ - virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0; + ResultCode Start(const Service::APT::AppletStartupParameter& parameter); /** * Whether the applet is currently executing instead of the host application or not. */ - virtual bool IsRunning() = 0; + virtual bool IsRunning() const = 0; /** * Handles an update tick for the Applet, lets it update the screen, send commands, etc. */ virtual void Update() = 0; +protected: + /** + * Handles the Applet start event, triggered from the application. + * @param parameter Parameter data to handle. + * @returns ResultCode Whether the operation was successful or not. + */ + virtual ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) = 0; + Service::APT::AppletId id; ///< Id of this Applet }; @@ -65,6 +73,5 @@ void Init(); /// Shuts down the HLE applets void Shutdown(); -extern std::shared_ptr g_current_applet; ///< Applet that is currently executing } } // namespace -- cgit v1.2.3