summaryrefslogtreecommitdiff
path: root/src/core/hle/applets/applet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/applets/applet.cpp')
-rw-r--r--src/core/hle/applets/applet.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index ccf35fa07..2b4bd939d 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -23,23 +23,24 @@
23// Specializes std::hash for AppletId, so that we can use it in std::unordered_map. 23// Specializes std::hash for AppletId, so that we can use it in std::unordered_map.
24// Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970 24// Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970
25namespace std { 25namespace std {
26 template <> 26template <>
27 struct hash<Service::APT::AppletId> { 27struct hash<Service::APT::AppletId> {
28 typedef Service::APT::AppletId argument_type; 28 typedef Service::APT::AppletId argument_type;
29 typedef std::size_t result_type; 29 typedef std::size_t result_type;
30 30
31 result_type operator()(const argument_type& id_code) const { 31 result_type operator()(const argument_type& id_code) const {
32 typedef std::underlying_type<argument_type>::type Type; 32 typedef std::underlying_type<argument_type>::type Type;
33 return std::hash<Type>()(static_cast<Type>(id_code)); 33 return std::hash<Type>()(static_cast<Type>(id_code));
34 } 34 }
35 }; 35};
36} 36}
37 37
38namespace HLE { 38namespace HLE {
39namespace Applets { 39namespace Applets {
40 40
41static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets; 41static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets;
42static u32 applet_update_event = -1; ///< The CoreTiming event identifier for the Applet update callback. 42static u32 applet_update_event =
43 -1; ///< The CoreTiming event identifier for the Applet update callback.
43/// The interval at which the Applet update callback will be called, 16.6ms 44/// The interval at which the Applet update callback will be called, 16.6ms
44static const u64 applet_update_interval_us = 16666; 45static const u64 applet_update_interval_us = 16666;
45 46
@@ -60,7 +61,8 @@ ResultCode Applet::Create(Service::APT::AppletId id) {
60 default: 61 default:
61 LOG_ERROR(Service_APT, "Could not create applet %u", id); 62 LOG_ERROR(Service_APT, "Could not create applet %u", id);
62 // TODO(Subv): Find the right error code 63 // TODO(Subv): Find the right error code
63 return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, ErrorLevel::Permanent); 64 return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
65 ErrorSummary::NotSupported, ErrorLevel::Permanent);
64 } 66 }
65 67
66 return RESULT_SUCCESS; 68 return RESULT_SUCCESS;
@@ -84,7 +86,7 @@ static void AppletUpdateEvent(u64 applet_id, int cycles_late) {
84 // If the applet is still running after the last update, reschedule the event 86 // If the applet is still running after the last update, reschedule the event
85 if (applet->IsRunning()) { 87 if (applet->IsRunning()) {
86 CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us) - cycles_late, 88 CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us) - cycles_late,
87 applet_update_event, applet_id); 89 applet_update_event, applet_id);
88 } else { 90 } else {
89 // Otherwise the applet has terminated, in which case we should clean it up 91 // Otherwise the applet has terminated, in which case we should clean it up
90 applets[id] = nullptr; 92 applets[id] = nullptr;
@@ -96,7 +98,8 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
96 if (result.IsError()) 98 if (result.IsError())
97 return result; 99 return result;
98 // Schedule the update event 100 // Schedule the update event
99 CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id)); 101 CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event,
102 static_cast<u64>(id));
100 return result; 103 return result;
101} 104}
102 105
@@ -116,6 +119,5 @@ void Init() {
116void Shutdown() { 119void Shutdown() {
117 CoreTiming::RemoveEvent(applet_update_event); 120 CoreTiming::RemoveEvent(applet_update_event);
118} 121}
119
120} 122}
121} // namespace 123} // namespace