From 04a2cb01cfb8a209b69f7501f7aeb4d47f3f3f3d Mon Sep 17 00:00:00 2001 From: JamePeng Date: Thu, 14 Apr 2016 23:52:03 +0800 Subject: [PATCH] Append a function Applet::GetRegisteredAppletCount()! --- src/core/hle/applets/applet.cpp | 13 ++++++++++++- src/core/hle/applets/applet.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index ccf35fa07..b9c75f6d6 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -58,7 +58,7 @@ ResultCode Applet::Create(Service::APT::AppletId id) { applets[id] = std::make_shared(id); break; default: - LOG_ERROR(Service_APT, "Could not create applet %u", id); + LOG_ERROR(Service_APT, "Could not create applet 0x%08X", id); // TODO(Subv): Find the right error code return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, ErrorLevel::Permanent); } @@ -73,6 +73,17 @@ std::shared_ptr Applet::Get(Service::APT::AppletId id) { return nullptr; } +u32 GetRegisteredAppletCount() { + u32 registered_count = 0; + + for (auto itr = applets.begin(); itr != applets.end(); ++itr) { + if (itr->second != nullptr) { + ++registered_count; + } + } + return registered_count; +} + /// Handles updating the current Applet every time it's called. static void AppletUpdateEvent(u64 applet_id, int cycles_late) { Service::APT::AppletId id = static_cast(applet_id); diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index 754c6f7db..8d44067ef 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h @@ -68,6 +68,9 @@ protected: std::shared_ptr> heap_memory; ///< Heap memory for this Applet }; +//Return the registered applet count +u32 GetRegisteredAppletCount(); + /// Returns whether a library applet is currently running bool IsLibraryAppletRunning();