From f1709b8b5986af28546877be4c162884118ca161 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 7 Dec 2016 17:11:39 -0500 Subject: [PATCH] applet: Move common IsRunning underlying variable to the Applet class Gets rid of basic duplication. --- src/core/hle/applets/applet.cpp | 4 ++++ src/core/hle/applets/applet.h | 5 ++++- src/core/hle/applets/erreula.cpp | 4 ++-- src/core/hle/applets/erreula.h | 8 +------- src/core/hle/applets/mii_selector.cpp | 4 ++-- src/core/hle/applets/mii_selector.h | 9 ++------- src/core/hle/applets/swkbd.cpp | 4 ++-- src/core/hle/applets/swkbd.h | 9 ++------- 8 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 4311d9897a..645b2d5fe6 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -101,6 +101,10 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter) return result; } +bool Applet::IsRunning() const { + return is_running; +} + bool IsLibraryAppletRunning() { // Check the applets map for instances of any applet for (auto itr = applets.begin(); itr != applets.end(); ++itr) diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index 583ddbe108..ebeed9813c 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h @@ -47,7 +47,7 @@ public: /** * Whether the applet is currently executing instead of the host application or not. */ - virtual bool IsRunning() const = 0; + bool IsRunning() const; /** * Handles an update tick for the Applet, lets it update the screen, send commands, etc. @@ -66,6 +66,9 @@ protected: Service::APT::AppletId id; ///< Id of this Applet std::shared_ptr> heap_memory; ///< Heap memory for this Applet + + /// Whether this applet is currently running instead of the host application or not. + bool is_running = false; }; /// Returns whether a library applet is currently running diff --git a/src/core/hle/applets/erreula.cpp b/src/core/hle/applets/erreula.cpp index e1379ac4d2..75d7fd9fc3 100644 --- a/src/core/hle/applets/erreula.cpp +++ b/src/core/hle/applets/erreula.cpp @@ -47,7 +47,7 @@ ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& param } ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) { - started = true; + is_running = true; // TODO(Subv): Set the expected fields in the response buffer before resending it to the // application. @@ -62,7 +62,7 @@ ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parame message.sender_id = static_cast(id); Service::APT::SendParameter(message); - started = false; + is_running = false; return RESULT_SUCCESS; } diff --git a/src/core/hle/applets/erreula.h b/src/core/hle/applets/erreula.h index a7ec7ec010..681bbea0c5 100644 --- a/src/core/hle/applets/erreula.h +++ b/src/core/hle/applets/erreula.h @@ -17,18 +17,12 @@ public: ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; void Update() override; - bool IsRunning() const override { - return started; - } +private: /// This SharedMemory will be created when we receive the LibAppJustStarted message. /// It holds the framebuffer info retrieved by the application with /// GSPGPU::ImportDisplayCaptureInfo Kernel::SharedPtr framebuffer_memory; - -private: - /// Whether this applet is currently running instead of the host application or not. - bool started = false; }; } // namespace Applets diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp index 3455b92016..07c7f5b99b 100644 --- a/src/core/hle/applets/mii_selector.cpp +++ b/src/core/hle/applets/mii_selector.cpp @@ -55,7 +55,7 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p } ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) { - started = true; + is_running = true; // TODO(Subv): Set the expected fields in the response buffer before resending it to the // application. @@ -78,7 +78,7 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa message.sender_id = static_cast(id); Service::APT::SendParameter(message); - started = false; + is_running = false; return RESULT_SUCCESS; } diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h index e3ab9f0cdd..ec00e29d23 100644 --- a/src/core/hle/applets/mii_selector.h +++ b/src/core/hle/applets/mii_selector.h @@ -65,23 +65,18 @@ ASSERT_REG_POSITION(unk_6C, 0x6C); class MiiSelector final : public Applet { public: - MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) {} + MiiSelector(Service::APT::AppletId id) : Applet(id) {} ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; void Update() override; - bool IsRunning() const override { - return started; - } +private: /// This SharedMemory will be created when we receive the LibAppJustStarted message. /// It holds the framebuffer info retrieved by the application with /// GSPGPU::ImportDisplayCaptureInfo Kernel::SharedPtr framebuffer_memory; - /// Whether this applet is currently running instead of the host application or not. - bool started; - MiiConfig config; }; } diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 1e21337f54..edd30d7ef0 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp @@ -70,7 +70,7 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons DrawScreenKeyboard(); - started = true; + is_running = true; return RESULT_SUCCESS; } @@ -113,7 +113,7 @@ void SoftwareKeyboard::Finalize() { message.sender_id = static_cast(id); Service::APT::SendParameter(message); - started = false; + is_running = false; } } } // namespace diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index ea0b1fba96..cc92a8f195 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h @@ -52,14 +52,11 @@ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config class SoftwareKeyboard final : public Applet { public: - SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) {} + SoftwareKeyboard(Service::APT::AppletId id) : Applet(id) {} ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; void Update() override; - bool IsRunning() const override { - return started; - } /** * Draws a keyboard to the current bottom screen framebuffer. @@ -72,6 +69,7 @@ public: */ void Finalize(); +private: /// This SharedMemory will be created when we receive the LibAppJustStarted message. /// It holds the framebuffer info retrieved by the application with /// GSPGPU::ImportDisplayCaptureInfo @@ -82,9 +80,6 @@ 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; }; } } // namespace