summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/applets/applet.cpp9
-rw-r--r--src/core/hle/applets/applet.h3
-rw-r--r--src/core/hle/service/apt/apt.cpp32
-rw-r--r--src/core/hle/service/apt/apt.h19
4 files changed, 49 insertions, 14 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index 826f6cbb6..e9ab6ffd8 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -89,12 +89,21 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
89 return result; 89 return result;
90} 90}
91 91
92bool IsLibraryAppletRunning() {
93 // Check the applets map for instances of any applet
94 for (auto& itr = applets.begin(); itr != applets.end(); ++itr)
95 if (itr->second != nullptr)
96 return true;
97 return false;
98}
99
92void Init() { 100void Init() {
93 // Register the applet update callback 101 // Register the applet update callback
94 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); 102 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent);
95} 103}
96 104
97void Shutdown() { 105void Shutdown() {
106 CoreTiming::RemoveEvent(applet_update_event);
98} 107}
99 108
100} 109}
diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h
index b235d0b8a..af442f81d 100644
--- a/src/core/hle/applets/applet.h
+++ b/src/core/hle/applets/applet.h
@@ -67,6 +67,9 @@ protected:
67 Service::APT::AppletId id; ///< Id of this Applet 67 Service::APT::AppletId id; ///< Id of this Applet
68}; 68};
69 69
70/// Returns whether a library applet is currently running
71bool IsLibraryAppletRunning();
72
70/// Initializes the HLE applets 73/// Initializes the HLE applets
71void Init(); 74void Init();
72 75
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 7b6ab4ce0..1988be521 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -101,18 +101,19 @@ void NotifyToWait(Service::Interface* self) {
101 101
102void GetLockHandle(Service::Interface* self) { 102void GetLockHandle(Service::Interface* self) {
103 u32* cmd_buff = Kernel::GetCommandBuffer(); 103 u32* cmd_buff = Kernel::GetCommandBuffer();
104 u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field 104 // Bits [0:2] are the applet type (System, Library, etc)
105 // Bit 5 tells the application that there's a pending APT parameter,
106 // this will cause the app to wait until parameter_event is signaled.
107 u32 applet_attributes = cmd_buff[1];
105 108
106 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 109 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
107 110
108 // Not sure what these parameters are used for, but retail apps check that they are 0 after 111 cmd_buff[2] = applet_attributes; // Applet Attributes, this value is passed to Enable.
109 // GetLockHandle has been called. 112 cmd_buff[3] = 0; // Least significant bit = power button state
110 cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. 113 cmd_buff[4] = IPC::CopyHandleDesc();
111 cmd_buff[3] = 0;
112 cmd_buff[4] = 0;
113
114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom(); 114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom();
115 LOG_TRACE(Service_APT, "called handle=0x%08X", cmd_buff[5]); 115
116 LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5], applet_attributes);
116} 117}
117 118
118void Enable(Service::Interface* self) { 119void Enable(Service::Interface* self) {
@@ -139,13 +140,16 @@ void IsRegistered(Service::Interface* self) {
139 u32* cmd_buff = Kernel::GetCommandBuffer(); 140 u32* cmd_buff = Kernel::GetCommandBuffer();
140 u32 app_id = cmd_buff[1]; 141 u32 app_id = cmd_buff[1];
141 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 142 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
142 /// TODO(Subv): It is currently unknown what this value (0x400) means, 143
143 /// but i believe it is used as a global "LibraryApplet" id, to verify if there's 144 // TODO(Subv): An application is considered "registered" if it has already called APT::Enable
144 /// any LibApplet currently running. This is not verified. 145 // handle this properly once we implement multiprocess support.
145 if (app_id != 0x400) 146 cmd_buff[2] = 0; // Set to not registered by default
147
148 if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) {
149 cmd_buff[2] = HLE::Applets::IsLibraryAppletRunning() ? 1 : 0;
150 } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) {
146 cmd_buff[2] = 1; // Set to registered 151 cmd_buff[2] = 1; // Set to registered
147 else 152 }
148 cmd_buff[2] = 0; // Set to not registered
149 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); 153 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
150} 154}
151 155
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 72972d05b..563068d5a 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -62,6 +62,7 @@ enum class AppletId : u32 {
62 Extrapad = 0x208, 62 Extrapad = 0x208,
63 Memolib = 0x209, 63 Memolib = 0x209,
64 Application = 0x300, 64 Application = 0x300,
65 AnyLibraryApplet = 0x400,
65 SoftwareKeyboard2 = 0x401, 66 SoftwareKeyboard2 = 0x401,
66}; 67};
67 68
@@ -96,8 +97,26 @@ void GetSharedFont(Service::Interface* self);
96 */ 97 */
97void NotifyToWait(Service::Interface* self); 98void NotifyToWait(Service::Interface* self);
98 99
100/**
101 * APT::GetLockHandle service function
102 * Inputs:
103 * 1 : Applet attributes
104 * Outputs:
105 * 1 : Result of function, 0 on success, otherwise error code
106 * 2 : Applet attributes
107 * 3 : Power button state
108 * 4 : IPC handle descriptor
109 * 5 : APT mutex handle
110 */
99void GetLockHandle(Service::Interface* self); 111void GetLockHandle(Service::Interface* self);
100 112
113/**
114 * APT::Enable service function
115 * Inputs:
116 * 1 : Applet attributes
117 * Outputs:
118 * 1 : Result of function, 0 on success, otherwise error code
119 */
101void Enable(Service::Interface* self); 120void Enable(Service::Interface* self);
102 121
103/** 122/**