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