diff options
author | Subv <subv2112@gmail.com> | 2015-05-26 18:00:26 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2015-07-12 04:47:23 +0200 |
commit | 621ee10eae0546d4ec3f9e911e113aa9ee609c22 (patch) | |
tree | adfdc1cf9ae7e9ac9a5cf9950a91bbcfeb6cd552 /src/core/hle/applets/applet.cpp | |
parent | HLE/APT: Initial HLE support for applets. (diff) | |
download | yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar.gz yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar.bz2 yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar.lz yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar.xz yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.tar.zst yuzu-621ee10eae0546d4ec3f9e911e113aa9ee609c22.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/applets/applet.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 1f447e5fc..689f5adc8 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -5,15 +5,35 @@ #include "common/assert.h" #include "common/logging/log.h" +#include "core/core_timing.h" #include "core/hle/applets/applet.h" #include "core/hle/applets/swkbd.h" //////////////////////////////////////////////////////////////////////////////////////////////////// +// Specializes std::hash for AppletId, so that we can use it in std::unordered_map. +// Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970 +namespace std { + template <> + struct hash<Service::APT::AppletId> { + typedef Service::APT::AppletId argument_type; + typedef std::size_t result_type; + + result_type operator()(const argument_type& id_code) const { + typedef std::underlying_type<argument_type>::type Type; + return std::hash<Type>()(static_cast<Type>(id_code)); + } + }; +} + namespace HLE { namespace Applets { static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets; +static u32 applet_update_event = -1; ///< The CoreTiming event identifier for the Applet update callback. +/// The interval at which the Applet update callback will be called. +static const u64 applet_update_interval_microseconds = 16666; +std::shared_ptr<Applet> g_current_applet = nullptr; ///< The applet that is currently executing ResultCode Applet::Create(Service::APT::AppletId id) { switch (id) { @@ -36,5 +56,23 @@ std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) { return nullptr; } +/// Handles updating the current Applet every time it's called. +static void AppletUpdateEvent(u64, int cycles_late) { + if (g_current_applet && g_current_applet->IsRunning()) + g_current_applet->Update(); + + CoreTiming::ScheduleEvent(usToCycles(applet_update_interval) - cycles_late, + applet_update_event); +} + +void Init() { + applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); + CoreTiming::ScheduleEvent(usToCycles(applet_update_interval), applet_update_event); +} + +void Shutdown() { + CoreTiming::UnscheduleEvent(applet_update_event, 0); +} + } } // namespace |