diff options
| author | 2017-10-10 17:32:14 -0400 | |
|---|---|---|
| committer | 2017-10-10 17:32:14 -0400 | |
| commit | 0906de9a14b735d1d409290ca050eb7d2c2d3d84 (patch) | |
| tree | 79bb57d3a4dc4ca377e7a62744c3941de29e785b /src/core/hle/applets/applet.cpp | |
| parent | Merge remote-tracking branch 'upstream/master' into nx (diff) | |
| download | yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.gz yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.xz yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.zip | |
hle: Remove a large amount of 3ds-specific service code.
Diffstat (limited to 'src/core/hle/applets/applet.cpp')
| -rw-r--r-- | src/core/hle/applets/applet.cpp | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp deleted file mode 100644 index 9c43ed2fd..000000000 --- a/src/core/hle/applets/applet.cpp +++ /dev/null | |||
| @@ -1,130 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstddef> | ||
| 6 | #include <memory> | ||
| 7 | #include <type_traits> | ||
| 8 | #include <unordered_map> | ||
| 9 | #include "common/assert.h" | ||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "core/core_timing.h" | ||
| 12 | #include "core/hle/applets/applet.h" | ||
| 13 | #include "core/hle/applets/erreula.h" | ||
| 14 | #include "core/hle/applets/mii_selector.h" | ||
| 15 | #include "core/hle/applets/mint.h" | ||
| 16 | #include "core/hle/applets/swkbd.h" | ||
| 17 | #include "core/hle/result.h" | ||
| 18 | #include "core/hle/service/apt/apt.h" | ||
| 19 | |||
| 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 21 | |||
| 22 | // Specializes std::hash for AppletId, so that we can use it in std::unordered_map. | ||
| 23 | // Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970 | ||
| 24 | namespace std { | ||
| 25 | template <> | ||
| 26 | struct hash<Service::APT::AppletId> { | ||
| 27 | typedef Service::APT::AppletId argument_type; | ||
| 28 | typedef std::size_t result_type; | ||
| 29 | |||
| 30 | result_type operator()(const argument_type& id_code) const { | ||
| 31 | typedef std::underlying_type<argument_type>::type Type; | ||
| 32 | return std::hash<Type>()(static_cast<Type>(id_code)); | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | } | ||
| 36 | |||
| 37 | namespace HLE { | ||
| 38 | namespace Applets { | ||
| 39 | |||
| 40 | static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets; | ||
| 41 | static u32 applet_update_event = | ||
| 42 | -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 | static const u64 applet_update_interval_us = 16666; | ||
| 45 | |||
| 46 | ResultCode Applet::Create(Service::APT::AppletId id) { | ||
| 47 | switch (id) { | ||
| 48 | case Service::APT::AppletId::SoftwareKeyboard1: | ||
| 49 | case Service::APT::AppletId::SoftwareKeyboard2: | ||
| 50 | applets[id] = std::make_shared<SoftwareKeyboard>(id); | ||
| 51 | break; | ||
| 52 | case Service::APT::AppletId::Ed1: | ||
| 53 | case Service::APT::AppletId::Ed2: | ||
| 54 | applets[id] = std::make_shared<MiiSelector>(id); | ||
| 55 | break; | ||
| 56 | case Service::APT::AppletId::Error: | ||
| 57 | case Service::APT::AppletId::Error2: | ||
| 58 | applets[id] = std::make_shared<ErrEula>(id); | ||
| 59 | break; | ||
| 60 | case Service::APT::AppletId::Mint: | ||
| 61 | case Service::APT::AppletId::Mint2: | ||
| 62 | applets[id] = std::make_shared<Mint>(id); | ||
| 63 | break; | ||
| 64 | default: | ||
| 65 | LOG_ERROR(Service_APT, "Could not create applet %u", id); | ||
| 66 | // TODO(Subv): Find the right error code | ||
| 67 | return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, | ||
| 68 | ErrorSummary::NotSupported, ErrorLevel::Permanent); | ||
| 69 | } | ||
| 70 | |||
| 71 | return RESULT_SUCCESS; | ||
| 72 | } | ||
| 73 | |||
| 74 | std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) { | ||
| 75 | auto itr = applets.find(id); | ||
| 76 | if (itr != applets.end()) | ||
| 77 | return itr->second; | ||
| 78 | return nullptr; | ||
| 79 | } | ||
| 80 | |||
| 81 | /// Handles updating the current Applet every time it's called. | ||
| 82 | static void AppletUpdateEvent(u64 applet_id, int cycles_late) { | ||
| 83 | Service::APT::AppletId id = static_cast<Service::APT::AppletId>(applet_id); | ||
| 84 | std::shared_ptr<Applet> applet = Applet::Get(id); | ||
| 85 | ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id=%08X", id); | ||
| 86 | |||
| 87 | applet->Update(); | ||
| 88 | |||
| 89 | // If the applet is still running after the last update, reschedule the event | ||
| 90 | if (applet->IsRunning()) { | ||
| 91 | CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us) - cycles_late, | ||
| 92 | applet_update_event, applet_id); | ||
| 93 | } else { | ||
| 94 | // Otherwise the applet has terminated, in which case we should clean it up | ||
| 95 | applets[id] = nullptr; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter) { | ||
| 100 | ResultCode result = StartImpl(parameter); | ||
| 101 | if (result.IsError()) | ||
| 102 | return result; | ||
| 103 | // Schedule the update event | ||
| 104 | CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event, | ||
| 105 | static_cast<u64>(id)); | ||
| 106 | return result; | ||
| 107 | } | ||
| 108 | |||
| 109 | bool Applet::IsRunning() const { | ||
| 110 | return is_running; | ||
| 111 | } | ||
| 112 | |||
| 113 | bool IsLibraryAppletRunning() { | ||
| 114 | // Check the applets map for instances of any applet | ||
| 115 | for (auto itr = applets.begin(); itr != applets.end(); ++itr) | ||
| 116 | if (itr->second != nullptr) | ||
| 117 | return true; | ||
| 118 | return false; | ||
| 119 | } | ||
| 120 | |||
| 121 | void Init() { | ||
| 122 | // Register the applet update callback | ||
| 123 | applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); | ||
| 124 | } | ||
| 125 | |||
| 126 | void Shutdown() { | ||
| 127 | CoreTiming::RemoveEvent(applet_update_event); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } // namespace | ||