Skip to content

Commit a88ab66

Browse files
authored
apt: Add aptLaunchSystemApplet (#557)
Needed for launching system applets like the Miiverse posting applet "solv3". The screen transfer is expected to be done after launching the applet.
1 parent 1b1762f commit a88ab66

File tree

2 files changed

+34
-0
lines changed
  • libctru

2 files changed

+34
-0
lines changed

libctru/include/3ds/services/apt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ void aptSetMessageCallback(aptMessageCb callback, void* user);
227227
*/
228228
void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);
229229

230+
/**
231+
* @brief Launches a system applet.
232+
* @param appId ID of the applet to launch.
233+
* @param buf Input/output buffer that contains launch parameters on entry and result data on exit.
234+
* @param bufsize Size of the buffer.
235+
* @param handle Handle to pass to the system applet.
236+
*/
237+
void aptLaunchSystemApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);
238+
230239
/// Clears the chainloader state.
231240
void aptClearChainloader(void);
232241

libctru/source/services/apt.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,31 @@ void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle ha
909909
aptSetSleepAllowed(sleep);
910910
}
911911

912+
void aptLaunchSystemApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle)
913+
{
914+
bool sleep = aptIsSleepAllowed();
915+
916+
aptSetSleepAllowed(false);
917+
aptFlags &= ~FLAG_SPURIOUS; // If we haven't received a spurious wakeup by now, we probably never will (see aptInit)
918+
APT_PrepareToStartSystemApplet(appId);
919+
aptSetSleepAllowed(sleep);
920+
921+
aptCallHook(APTHOOK_ONSUSPEND);
922+
923+
GSPGPU_SaveVramSysArea();
924+
GSPGPU_ReleaseRight();
925+
926+
aptSetSleepAllowed(false);
927+
APT_StartSystemApplet(appId, buf, bufsize, handle);
928+
aptFlags &= ~FLAG_ACTIVE;
929+
930+
aptScreenTransfer(appId, true);
931+
932+
aptWaitForWakeUp(TR_SYSAPPLET);
933+
memcpy(buf, aptParameters, bufsize);
934+
aptSetSleepAllowed(sleep);
935+
}
936+
912937
Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
913938
{
914939
u32 cmdbuf[16];

0 commit comments

Comments
 (0)