libctru  v2.4.1
apt.h
Go to the documentation of this file.
1 /**
2  * @file apt.h
3  * @brief APT (Applet) service.
4  */
5 #pragma once
6 
7 /**
8  * @brief NS Application IDs.
9  *
10  * Retrieved from http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs
11  */
12 typedef enum {
13  APPID_NONE = 0,
14  APPID_HOMEMENU = 0x101, ///< Home Menu
15  APPID_CAMERA = 0x110, ///< Camera applet
16  APPID_FRIENDS_LIST = 0x112, ///< Friends List applet
17  APPID_GAME_NOTES = 0x113, ///< Game Notes applet
18  APPID_WEB = 0x114, ///< Internet Browser
19  APPID_INSTRUCTION_MANUAL = 0x115, ///< Instruction Manual applet
20  APPID_NOTIFICATIONS = 0x116, ///< Notifications applet
21  APPID_MIIVERSE = 0x117, ///< Miiverse applet (olv)
22  APPID_MIIVERSE_POSTING = 0x118, ///< Miiverse posting applet (solv3)
23  APPID_AMIIBO_SETTINGS = 0x119, ///< Amiibo settings applet (cabinet)
24  APPID_APPLICATION = 0x300, ///< Application
25  APPID_ESHOP = 0x301, ///< eShop (tiger)
26  APPID_SOFTWARE_KEYBOARD = 0x401, ///< Software Keyboard
27  APPID_APPLETED = 0x402, ///< appletEd
28  APPID_PNOTE_AP = 0x404, ///< PNOTE_AP
29  APPID_SNOTE_AP = 0x405, ///< SNOTE_AP
30  APPID_ERROR = 0x406, ///< error
31  APPID_MINT = 0x407, ///< mint
32  APPID_EXTRAPAD = 0x408, ///< extrapad
33  APPID_MEMOLIB = 0x409, ///< memolib
34 } NS_APPID;
35 
36 /// APT applet position.
37 typedef enum {
38  APTPOS_NONE = -1, ///< No position specified.
39  APTPOS_APP = 0, ///< Application.
40  APTPOS_APPLIB = 1, ///< Application library (?).
41  APTPOS_SYS = 2, ///< System applet.
42  APTPOS_SYSLIB = 3, ///< System library (?).
43  APTPOS_RESIDENT = 4, ///< Resident applet.
45 
46 typedef u8 APT_AppletAttr;
47 
48 struct PtmWakeEvents;
49 
50 /// Create an APT_AppletAttr bitfield from its components.
51 static inline APT_AppletAttr aptMakeAppletAttr(APT_AppletPos pos, bool manualGpuRights, bool manualDspRights)
52 {
53  return (pos&7) | (manualGpuRights ? BIT(3) : 0) | (manualDspRights ? BIT(4) : 0);
54 }
55 
56 /// APT query reply.
57 typedef enum {
58  APTREPLY_REJECT = 0,
59  APTREPLY_ACCEPT = 1,
60  APTREPLY_LATER = 2,
62 
63 /// APT signals.
64 typedef enum {
65  APTSIGNAL_NONE = 0, ///< No signal received.
66  APTSIGNAL_HOMEBUTTON = 1, ///< HOME button pressed.
67  APTSIGNAL_HOMEBUTTON2 = 2, ///< HOME button pressed (again?).
68  APTSIGNAL_SLEEP_QUERY = 3, ///< Prepare to enter sleep mode.
69  APTSIGNAL_SLEEP_CANCEL = 4, ///< Triggered when ptm:s GetShellStatus() returns 5.
70  APTSIGNAL_SLEEP_ENTER = 5, ///< Enter sleep mode.
71  APTSIGNAL_SLEEP_WAKEUP = 6, ///< Wake from sleep mode.
72  APTSIGNAL_SHUTDOWN = 7, ///< Shutdown.
73  APTSIGNAL_POWERBUTTON = 8, ///< POWER button pressed.
74  APTSIGNAL_POWERBUTTON2 = 9, ///< POWER button cleared (?).
75  APTSIGNAL_TRY_SLEEP = 10, ///< System sleeping (?).
76  APTSIGNAL_ORDERTOCLOSE = 11, ///< Order to close (such as when an error happens?).
77 } APT_Signal;
78 
79 /// APT commands.
80 typedef enum {
81  APTCMD_NONE = 0, ///< No command received.
82  APTCMD_WAKEUP = 1, ///< Applet should wake up.
83  APTCMD_REQUEST = 2, ///< Source applet sent us a parameter.
84  APTCMD_RESPONSE = 3, ///< Target applet replied to our parameter.
85  APTCMD_EXIT = 4, ///< Exit (??)
86  APTCMD_MESSAGE = 5, ///< Message (??)
87  APTCMD_HOMEBUTTON_ONCE = 6, ///< HOME button pressed once.
88  APTCMD_HOMEBUTTON_TWICE = 7, ///< HOME button pressed twice (double-pressed).
89  APTCMD_DSP_SLEEP = 8, ///< DSP should sleep (manual DSP rights related?).
90  APTCMD_DSP_WAKEUP = 9, ///< DSP should wake up (manual DSP rights related?).
91  APTCMD_WAKEUP_EXIT = 10, ///< Applet wakes up due to a different applet exiting.
92  APTCMD_WAKEUP_PAUSE = 11, ///< Applet wakes up after being paused through HOME menu.
93  APTCMD_WAKEUP_CANCEL = 12, ///< Applet wakes up due to being cancelled.
94  APTCMD_WAKEUP_CANCELALL = 13, ///< Applet wakes up due to all applets being cancelled.
95  APTCMD_WAKEUP_POWERBUTTON = 14, ///< Applet wakes up due to POWER button being pressed (?).
96  APTCMD_WAKEUP_JUMPTOHOME = 15, ///< Applet wakes up and is instructed to jump to HOME menu (?).
97  APTCMD_SYSAPPLET_REQUEST = 16, ///< Request for sysapplet (?).
98  APTCMD_WAKEUP_LAUNCHAPP = 17, ///< Applet wakes up and is instructed to launch another applet (?).
99 } APT_Command;
100 
101 /// APT capture buffer information.
102 typedef struct
103 {
104  u32 size;
105  u32 is3D;
106  struct
107  {
108  u32 leftOffset;
109  u32 rightOffset;
110  u32 format;
111  } top, bottom;
113 
114 /// APT hook types.
115 typedef enum {
116  APTHOOK_ONSUSPEND = 0, ///< App suspended.
117  APTHOOK_ONRESTORE, ///< App restored.
118  APTHOOK_ONSLEEP, ///< App sleeping.
119  APTHOOK_ONWAKEUP, ///< App waking up.
120  APTHOOK_ONEXIT, ///< App exiting.
121 
122  APTHOOK_COUNT, ///< Number of APT hook types.
123 } APT_HookType;
124 
125 /// APT hook function.
126 typedef void (*aptHookFn)(APT_HookType hook, void* param);
127 
128 /// APT hook cookie.
129 typedef struct tag_aptHookCookie
130 {
131  struct tag_aptHookCookie* next; ///< Next cookie.
132  aptHookFn callback; ///< Hook callback.
133  void* param; ///< Callback parameter.
134 } aptHookCookie;
135 
136 /// APT message callback.
137 typedef void (*aptMessageCb)(void* user, NS_APPID sender, void* msg, size_t msgsize);
138 
139 /// Initializes APT.
141 
142 /// Exits APT.
143 void aptExit(void);
144 
145 /**
146  * @brief Sends an APT command through IPC, taking care of locking, opening and closing an APT session.
147  * @param aptcmdbuf Pointer to command buffer (should have capacity for at least 16 words).
148  */
150 
151 /// Returns true if the application is currently in the foreground.
152 bool aptIsActive(void);
153 
154 /// Returns true if the system has told the application to close.
155 bool aptShouldClose(void);
156 
157 /// Returns true if the system can enter sleep mode while the application is active.
158 bool aptIsSleepAllowed(void);
159 
160 /// Configures whether the system can enter sleep mode while the application is active.
161 void aptSetSleepAllowed(bool allowed);
162 
163 /// Handles incoming sleep mode requests.
164 void aptHandleSleep(void);
165 
166 /// Returns true if the user can press the HOME button to jump back to the HOME menu while the application is active.
167 bool aptIsHomeAllowed(void);
168 
169 /// Configures whether the user can press the HOME button to jump back to the HOME menu while the application is active.
170 void aptSetHomeAllowed(bool allowed);
171 
172 /// Returns true if the system requires the application to jump back to the HOME menu.
174 
175 /// Returns true if there is an incoming HOME button press rejected by the policy set by \ref aptSetHomeAllowed (use this to show a "no HOME allowed" icon).
177 
178 /// \deprecated Alias for \ref aptCheckHomePressRejected.
179 static inline CTR_DEPRECATED bool aptIsHomePressed(void)
180 {
181  return aptCheckHomePressRejected();
182 }
183 
184 /// Jumps back to the HOME menu.
185 void aptJumpToHomeMenu(void);
186 
187 /// Handles incoming jump-to-HOME requests.
188 static inline void aptHandleJumpToHome(void)
189 {
190  if (aptShouldJumpToHome())
192 }
193 
194 /**
195  * @brief Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every frame.
196  * @return true if the application should keep running, false otherwise (see \ref aptShouldClose).
197  */
198 bool aptMainLoop(void);
199 
200 /**
201  * @brief Sets up an APT status hook.
202  * @param cookie Hook cookie to use.
203  * @param callback Function to call when APT's status changes.
204  * @param param User-defined parameter to pass to the callback.
205  */
206 void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
207 
208 /**
209  * @brief Removes an APT status hook.
210  * @param cookie Hook cookie to remove.
211  */
212 void aptUnhook(aptHookCookie* cookie);
213 
214 /**
215  * @brief Sets the function to be called when an APT message from another applet is received.
216  * @param callback Callback function.
217  * @param user User-defined data to be passed to the callback.
218  */
219 void aptSetMessageCallback(aptMessageCb callback, void* user);
220 
221 /**
222  * @brief Launches a library applet.
223  * @param appId ID of the applet to launch.
224  * @param buf Input/output buffer that contains launch parameters on entry and result data on exit.
225  * @param bufsize Size of the buffer.
226  * @param handle Handle to pass to the library applet.
227  */
228 void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);
229 
230 /// Clears the chainloader state.
232 
233 /**
234  * @brief Configures the chainloader to launch a specific application.
235  * @param programID ID of the program to chainload to.
236  * @param mediatype Media type of the program to chainload to.
237  */
238 void aptSetChainloader(u64 programID, u8 mediatype);
239 
240 /// Configures the chainloader to launch the previous application.
242 
243 /// Configures the chainloader to relaunch the current application (i.e. soft-reset)
245 
246 /**
247  * @brief Sets the "deliver arg" and HMAC for the chainloader, which will
248  * be passed to the target 3DS/DS(i) application. The meaning of each
249  * parameter varies on a per-application basis.
250  * @param deliverArg Deliver arg to pass to the target application.
251  * @param deliverArgSize Size of the deliver arg, maximum 0x300 bytes.
252  * @param hmac HMAC buffer, 32 bytes. Use NULL to pass an all-zero dummy HMAC.
253  */
254 void aptSetChainloaderArgs(const void *deliverArg, size_t deliverArgSize, const void *hmac);
255 
256 /**
257  * @brief Gets an APT lock handle.
258  * @param flags Flags to use.
259  * @param lockHandle Pointer to output the lock handle to.
260  */
261 Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
262 
263 /**
264  * @brief Initializes an application's registration with APT.
265  * @param appId ID of the application.
266  * @param attr Attributes of the application.
267  * @param signalEvent Pointer to output the signal event handle to.
268  * @param resumeEvent Pointer to output the resume event handle to.
269  */
270 Result APT_Initialize(NS_APPID appId, APT_AppletAttr attr, Handle* signalEvent, Handle* resumeEvent);
271 
272 /**
273  * @brief Terminates an application's registration with APT.
274  * @param appID ID of the application.
275  */
277 
278 /// Asynchronously resets the hardware.
280 
281 /**
282  * @brief Enables APT.
283  * @param attr Attributes of the application.
284  */
285 Result APT_Enable(APT_AppletAttr attr);
286 
287 /**
288  * @brief Gets applet management info.
289  * @param inpos Requested applet position.
290  * @param outpos Pointer to output the position of the current applet to.
291  * @param req_appid Pointer to output the AppID of the applet at the requested position to.
292  * @param menu_appid Pointer to output the HOME menu AppID to.
293  * @param active_appid Pointer to output the AppID of the currently active applet to.
294  */
295 Result APT_GetAppletManInfo(APT_AppletPos inpos, APT_AppletPos* outpos, NS_APPID* req_appid, NS_APPID* menu_appid, NS_APPID* active_appid);
296 
297 /**
298  * @brief Gets the menu's app ID.
299  * @return The menu's app ID.
300  */
301 static inline NS_APPID aptGetMenuAppID(void)
302 {
303  NS_APPID menu_appid = APPID_NONE;
304  APT_GetAppletManInfo(APTPOS_NONE, NULL, NULL, &menu_appid, NULL);
305  return menu_appid;
306 }
307 
308 /**
309  * @brief Gets an applet's information.
310  * @param appID AppID of the applet.
311  * @param pProgramID Pointer to output the program ID to.
312  * @param pMediaType Pointer to output the media type to.
313  * @param pRegistered Pointer to output the registration status to.
314  * @param pLoadState Pointer to output the load state to.
315  * @param pAttributes Pointer to output the applet atrributes to.
316  */
317 Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, bool* pRegistered, bool* pLoadState, APT_AppletAttr* pAttributes);
318 
319 /**
320  * @brief Gets an applet's program information.
321  * @param id ID of the applet.
322  * @param flags Flags to use when retreiving the information.
323  * @param titleversion Pointer to output the applet's title version to.
324  *
325  * Flags:
326  * - 0x01: Use AM_ListTitles with NAND media type.
327  * - 0x02: Use AM_ListTitles with SDMC media type.
328  * - 0x04: Use AM_ListTitles with GAMECARD media type.
329  * - 0x10: Input ID is an app ID. Must be set if 0x20 is not.
330  * - 0x20: Input ID is a program ID. Must be set if 0x10 is not.
331  * - 0x100: Sets program ID high to 0x00040000, else it is 0x00040010. Only used when 0x20 is set.
332  */
333 Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion);
334 
335 /**
336  * @brief Gets the current application's program ID.
337  * @param pProgramID Pointer to output the program ID to.
338  */
340 
341 /// Prepares to jump to the home menu.
343 
344 /**
345  * @brief Jumps to the home menu.
346  * @param param Parameters to jump with.
347  * @param Size of the parameter buffer.
348  * @param handle Handle to pass.
349  */
350 Result APT_JumpToHomeMenu(const void* param, size_t paramSize, Handle handle);
351 
352 /**
353  * @brief Prepares to jump to an application.
354  * @param exiting Specifies whether the applet is exiting.
355  */
357 
358 /**
359  * @brief Jumps to an application.
360  * @param param Parameters to jump with.
361  * @param Size of the parameter buffer.
362  * @param handle Handle to pass.
363  */
364 Result APT_JumpToApplication(const void* param, size_t paramSize, Handle handle);
365 
366 /**
367  * @brief Gets whether an application is registered.
368  * @param appID ID of the application.
369  * @param out Pointer to output the registration state to.
370  */
371 Result APT_IsRegistered(NS_APPID appID, bool* out);
372 
373 /**
374  * @brief Inquires as to whether a signal has been received.
375  * @param appID ID of the application.
376  * @param signalType Pointer to output the signal type to.
377  */
379 
380 /**
381  * @brief Requests to enter sleep mode, and later sets wake events if allowed to.
382  * @param wakeEvents The wake events. Limited to "shell" (bit 1) for the PDN wake events part
383  * and "shell opened", "shell closed" and "HOME button pressed" for the MCU interrupts part.
384  */
385 Result APT_SleepSystem(const struct PtmWakeEvents *wakeEvents);
386 
387 /**
388  * @brief Notifies an application to wait.
389  * @param appID ID of the application.
390  */
392 
393 /**
394  * @brief Calls an applet utility function.
395  * @param id Utility function to call.
396  * @param out Pointer to write output data to.
397  * @param outSize Size of the output buffer.
398  * @param in Pointer to the input data.
399  * @param inSize Size of the input buffer.
400  */
401 Result APT_AppletUtility(int id, void* out, size_t outSize, const void* in, size_t inSize);
402 
403 /// Sleeps if shell is closed (?).
405 
406 /**
407  * @brief Locks a transition (?).
408  * @param transition Transition ID.
409  * @param flag Flag (?)
410  */
411 Result APT_LockTransition(u32 transition, bool flag);
412 
413 /**
414  * @brief Tries to lock a transition (?).
415  * @param transition Transition ID.
416  * @param succeeded Pointer to output whether the lock was successfully applied.
417  */
418 Result APT_TryLockTransition(u32 transition, bool* succeeded);
419 
420 /**
421  * @brief Unlocks a transition (?).
422  * @param transition Transition ID.
423  */
425 
426 /**
427  * @brief Glances at a receieved parameter without removing it from the queue.
428  * @param appID AppID of the application.
429  * @param buffer Buffer to receive to.
430  * @param bufferSize Size of the buffer.
431  * @param sender Pointer to output the sender's AppID to.
432  * @param command Pointer to output the command ID to.
433  * @param actualSize Pointer to output the actual received data size to.
434  * @param parameter Pointer to output the parameter handle to.
435  */
436 Result APT_GlanceParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
437 
438 /**
439  * @brief Receives a parameter.
440  * @param appID AppID of the application.
441  * @param buffer Buffer to receive to.
442  * @param bufferSize Size of the buffer.
443  * @param sender Pointer to output the sender's AppID to.
444  * @param command Pointer to output the command ID to.
445  * @param actualSize Pointer to output the actual received data size to.
446  * @param parameter Pointer to output the parameter handle to.
447  */
448 Result APT_ReceiveParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
449 
450 /**
451  * @brief Sends a parameter.
452  * @param source AppID of the source application.
453  * @param dest AppID of the destination application.
454  * @param command Command to send.
455  * @param buffer Buffer to send.
456  * @param bufferSize Size of the buffer.
457  * @param parameter Parameter handle to pass.
458  */
459 Result APT_SendParameter(NS_APPID source, NS_APPID dest, APT_Command command, const void* buffer, u32 bufferSize, Handle parameter);
460 
461 /**
462  * @brief Cancels a parameter which matches the specified source and dest AppIDs.
463  * @param source AppID of the source application (use APPID_NONE to disable the check).
464  * @param dest AppID of the destination application (use APPID_NONE to disable the check).
465  * @param success Pointer to output true if a parameter was cancelled, or false otherwise.
466  */
467 Result APT_CancelParameter(NS_APPID source, NS_APPID dest, bool* success);
468 
469 /**
470  * @brief Sends capture buffer information.
471  * @param captureBuf Capture buffer information to send.
472  */
474 
475 /**
476  * @brief Replies to a sleep query.
477  * @param appID ID of the application.
478  * @param reply Query reply value.
479  */
481 
482 /**
483  * @brief Replies that a sleep notification has been completed.
484  * @param appID ID of the application.
485  */
487 
488 /**
489  * @brief Prepares to close the application.
490  * @param cancelPreload Whether applet preloads should be cancelled.
491  */
493 
494 /**
495  * @brief Closes the application.
496  * @param param Parameters to close with.
497  * @param paramSize Size of param.
498  * @param handle Handle to pass.
499  */
500 Result APT_CloseApplication(const void* param, size_t paramSize, Handle handle);
501 
502 /**
503  * @brief Sets the application's CPU time limit.
504  * @param percent CPU time limit percentage to set.
505  */
507 
508 /**
509  * @brief Gets the application's CPU time limit.
510  * @param percent Pointer to output the CPU time limit percentage to.
511  */
513 
514 /**
515  * @brief Checks whether the system is a New 3DS.
516  * @param out Pointer to write the New 3DS flag to.
517  */
519 
520 /**
521  * @brief Prepares for an applicaton jump.
522  * @param flags Flags to use.
523  * @param programID ID of the program to jump to.
524  * @param mediatype Media type of the program to jump to.
525  */
526 Result APT_PrepareToDoApplicationJump(u8 flags, u64 programID, u8 mediatype);
527 
528 /**
529  * @brief Performs an application jump.
530  * @param param Parameter buffer.
531  * @param paramSize Size of parameter buffer.
532  * @param hmac HMAC buffer (should be 0x20 bytes long).
533  */
534 Result APT_DoApplicationJump(const void* param, size_t paramSize, const void* hmac);
535 
536 /**
537  * @brief Prepares to start a library applet.
538  * @param appID AppID of the applet to start.
539  */
541 
542 /**
543  * @brief Starts a library applet.
544  * @param appID AppID of the applet to launch.
545  * @param param Buffer containing applet parameters.
546  * @param paramsize Size of the buffer.
547  * @param handle Handle to pass to the applet.
548  */
549 Result APT_StartLibraryApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
550 
551 /**
552  * @brief Prepares to start a system applet.
553  * @param appID AppID of the applet to start.
554  */
556 
557 /**
558  * @brief Starts a system applet.
559  * @param appID AppID of the applet to launch.
560  * @param param Buffer containing applet parameters.
561  * @param paramSize Size of the parameter buffer.
562  * @param handle Handle to pass to the applet.
563  */
564 Result APT_StartSystemApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
565 
566 /**
567  * @brief Retrieves the shared system font.
568  * @brief fontHandle Pointer to write the handle of the system font memory block to.
569  * @brief mapAddr Pointer to write the mapping address of the system font memory block to.
570  */
571 Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr);
572 
573 /**
574  * @brief Receives the deliver (launch) argument
575  * @param param Parameter buffer.
576  * @param paramSize Size of parameter buffer.
577  * @param hmac HMAC buffer (should be 0x20 bytes long).
578  * @param sender Pointer to output the sender's AppID to.
579  * @param received Pointer to output whether an argument was received to.
580  */
581 Result APT_ReceiveDeliverArg(void* param, size_t paramSize, void* hmac, u64* sender, bool* received);
APT_QueryReply
APT query reply.
Definition: apt.h:57
void aptSetChainloaderToCaller(void)
Configures the chainloader to launch the previous application.
Result APT_PrepareToCloseApplication(bool cancelPreload)
Prepares to close the application.
Result APT_SendCaptureBufferInfo(const aptCaptureBufInfo *captureBuf)
Sends capture buffer information.
Result APT_AppletUtility(int id, void *out, size_t outSize, const void *in, size_t inSize)
Calls an applet utility function.
Result APT_GetProgramID(u64 *pProgramID)
Gets the current application's program ID.
Result APT_GetSharedFont(Handle *fontHandle, u32 *mapAddr)
Retrieves the shared system font.
APT_Signal
APT signals.
Definition: apt.h:64
@ APTSIGNAL_SLEEP_QUERY
Prepare to enter sleep mode.
Definition: apt.h:68
@ APTSIGNAL_POWERBUTTON
POWER button pressed.
Definition: apt.h:73
@ APTSIGNAL_SLEEP_WAKEUP
Wake from sleep mode.
Definition: apt.h:71
@ APTSIGNAL_POWERBUTTON2
POWER button cleared (?).
Definition: apt.h:74
@ APTSIGNAL_ORDERTOCLOSE
Order to close (such as when an error happens?).
Definition: apt.h:76
@ APTSIGNAL_SHUTDOWN
Shutdown.
Definition: apt.h:72
@ APTSIGNAL_TRY_SLEEP
System sleeping (?).
Definition: apt.h:75
@ APTSIGNAL_NONE
No signal received.
Definition: apt.h:65
@ APTSIGNAL_HOMEBUTTON2
HOME button pressed (again?).
Definition: apt.h:67
@ APTSIGNAL_SLEEP_ENTER
Enter sleep mode.
Definition: apt.h:70
@ APTSIGNAL_HOMEBUTTON
HOME button pressed.
Definition: apt.h:66
@ APTSIGNAL_SLEEP_CANCEL
Triggered when ptm:s GetShellStatus() returns 5.
Definition: apt.h:69
Result APT_UnlockTransition(u32 transition)
Unlocks a transition (?).
Result APT_JumpToHomeMenu(const void *param, size_t paramSize, Handle handle)
Jumps to the home menu.
Result APT_SleepIfShellClosed(void)
Sleeps if shell is closed (?).
Result APT_ReceiveParameter(NS_APPID appID, void *buffer, size_t bufferSize, NS_APPID *sender, APT_Command *command, size_t *actualSize, Handle *parameter)
Receives a parameter.
void aptExit(void)
Exits APT.
Result APT_SleepSystem(const struct PtmWakeEvents *wakeEvents)
Requests to enter sleep mode, and later sets wake events if allowed to.
Result APT_CancelParameter(NS_APPID source, NS_APPID dest, bool *success)
Cancels a parameter which matches the specified source and dest AppIDs.
Result APT_Finalize(NS_APPID appId)
Terminates an application's registration with APT.
Result APT_GetAppletInfo(NS_APPID appID, u64 *pProgramID, u8 *pMediaType, bool *pRegistered, bool *pLoadState, APT_AppletAttr *pAttributes)
Gets an applet's information.
void aptSetSleepAllowed(bool allowed)
Configures whether the system can enter sleep mode while the application is active.
void aptSetChainloaderToSelf(void)
Configures the chainloader to relaunch the current application (i.e. soft-reset)
void aptSetChainloaderArgs(const void *deliverArg, size_t deliverArgSize, const void *hmac)
Sets the "deliver arg" and HMAC for the chainloader, which will be passed to the target 3DS/DS(i) app...
Result APT_GetLockHandle(u16 flags, Handle *lockHandle)
Gets an APT lock handle.
static APT_AppletAttr aptMakeAppletAttr(APT_AppletPos pos, bool manualGpuRights, bool manualDspRights)
Create an APT_AppletAttr bitfield from its components.
Definition: apt.h:51
bool aptShouldJumpToHome(void)
Returns true if the system requires the application to jump back to the HOME menu.
Result APT_PrepareToJumpToHomeMenu(void)
Prepares to jump to the home menu.
static CTR_DEPRECATED bool aptIsHomePressed(void)
Definition: apt.h:179
void aptUnhook(aptHookCookie *cookie)
Removes an APT status hook.
APT_HookType
APT hook types.
Definition: apt.h:115
@ APTHOOK_ONEXIT
App exiting.
Definition: apt.h:120
@ APTHOOK_ONSUSPEND
App suspended.
Definition: apt.h:116
@ APTHOOK_ONSLEEP
App sleeping.
Definition: apt.h:118
@ APTHOOK_ONWAKEUP
App waking up.
Definition: apt.h:119
@ APTHOOK_ONRESTORE
App restored.
Definition: apt.h:117
@ APTHOOK_COUNT
Number of APT hook types.
Definition: apt.h:122
Result APT_InquireNotification(u32 appID, APT_Signal *signalType)
Inquires as to whether a signal has been received.
Result APT_LockTransition(u32 transition, bool flag)
Locks a transition (?).
Result APT_DoApplicationJump(const void *param, size_t paramSize, const void *hmac)
Performs an application jump.
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
Result APT_GetAppletManInfo(APT_AppletPos inpos, APT_AppletPos *outpos, NS_APPID *req_appid, NS_APPID *menu_appid, NS_APPID *active_appid)
Gets applet management info.
APT_Command
APT commands.
Definition: apt.h:80
@ APTCMD_WAKEUP_CANCEL
Applet wakes up due to being cancelled.
Definition: apt.h:93
@ APTCMD_WAKEUP_EXIT
Applet wakes up due to a different applet exiting.
Definition: apt.h:91
@ APTCMD_MESSAGE
Message (??)
Definition: apt.h:86
@ APTCMD_SYSAPPLET_REQUEST
Request for sysapplet (?).
Definition: apt.h:97
@ APTCMD_WAKEUP_POWERBUTTON
Applet wakes up due to POWER button being pressed (?).
Definition: apt.h:95
@ APTCMD_NONE
No command received.
Definition: apt.h:81
@ APTCMD_WAKEUP_JUMPTOHOME
Applet wakes up and is instructed to jump to HOME menu (?).
Definition: apt.h:96
@ APTCMD_RESPONSE
Target applet replied to our parameter.
Definition: apt.h:84
@ APTCMD_DSP_WAKEUP
DSP should wake up (manual DSP rights related?).
Definition: apt.h:90
@ APTCMD_WAKEUP
Applet should wake up.
Definition: apt.h:82
@ APTCMD_HOMEBUTTON_TWICE
HOME button pressed twice (double-pressed).
Definition: apt.h:88
@ APTCMD_DSP_SLEEP
DSP should sleep (manual DSP rights related?).
Definition: apt.h:89
@ APTCMD_WAKEUP_PAUSE
Applet wakes up after being paused through HOME menu.
Definition: apt.h:92
@ APTCMD_HOMEBUTTON_ONCE
HOME button pressed once.
Definition: apt.h:87
@ APTCMD_REQUEST
Source applet sent us a parameter.
Definition: apt.h:83
@ APTCMD_WAKEUP_LAUNCHAPP
Applet wakes up and is instructed to launch another applet (?).
Definition: apt.h:98
@ APTCMD_WAKEUP_CANCELALL
Applet wakes up due to all applets being cancelled.
Definition: apt.h:94
@ APTCMD_EXIT
Exit (??)
Definition: apt.h:85
static NS_APPID aptGetMenuAppID(void)
Gets the menu's app ID.
Definition: apt.h:301
Result APT_JumpToApplication(const void *param, size_t paramSize, Handle handle)
Jumps to an application.
Result APT_HardwareResetAsync(void)
Asynchronously resets the hardware.
NS_APPID
NS Application IDs.
Definition: apt.h:12
@ APPID_WEB
Internet Browser.
Definition: apt.h:18
@ APPID_INSTRUCTION_MANUAL
Instruction Manual applet.
Definition: apt.h:19
@ APPID_PNOTE_AP
PNOTE_AP.
Definition: apt.h:28
@ APPID_MIIVERSE_POSTING
Miiverse posting applet (solv3)
Definition: apt.h:22
@ APPID_APPLICATION
Application.
Definition: apt.h:24
@ APPID_EXTRAPAD
extrapad
Definition: apt.h:32
@ APPID_MIIVERSE
Miiverse applet (olv)
Definition: apt.h:21
@ APPID_APPLETED
appletEd
Definition: apt.h:27
@ APPID_AMIIBO_SETTINGS
Amiibo settings applet (cabinet)
Definition: apt.h:23
@ APPID_MEMOLIB
memolib
Definition: apt.h:33
@ APPID_CAMERA
Camera applet.
Definition: apt.h:15
@ APPID_HOMEMENU
Home Menu.
Definition: apt.h:14
@ APPID_FRIENDS_LIST
Friends List applet.
Definition: apt.h:16
@ APPID_SOFTWARE_KEYBOARD
Software Keyboard.
Definition: apt.h:26
@ APPID_NOTIFICATIONS
Notifications applet.
Definition: apt.h:20
@ APPID_MINT
mint
Definition: apt.h:31
@ APPID_ESHOP
eShop (tiger)
Definition: apt.h:25
@ APPID_SNOTE_AP
SNOTE_AP.
Definition: apt.h:29
@ APPID_GAME_NOTES
Game Notes applet.
Definition: apt.h:17
@ APPID_ERROR
error
Definition: apt.h:30
Result APT_PrepareToStartSystemApplet(NS_APPID appID)
Prepares to start a system applet.
Result aptInit(void)
Initializes APT.
void(* aptMessageCb)(void *user, NS_APPID sender, void *msg, size_t msgsize)
APT message callback.
Definition: apt.h:137
Result APT_SendParameter(NS_APPID source, NS_APPID dest, APT_Command command, const void *buffer, u32 bufferSize, Handle parameter)
Sends a parameter.
APT_AppletPos
APT applet position.
Definition: apt.h:37
@ APTPOS_NONE
No position specified.
Definition: apt.h:38
@ APTPOS_SYSLIB
System library (?).
Definition: apt.h:42
@ APTPOS_RESIDENT
Resident applet.
Definition: apt.h:43
@ APTPOS_APP
Application.
Definition: apt.h:39
@ APTPOS_SYS
System applet.
Definition: apt.h:41
@ APTPOS_APPLIB
Application library (?).
Definition: apt.h:40
bool aptCheckHomePressRejected(void)
Returns true if there is an incoming HOME button press rejected by the policy set by aptSetHomeAllowe...
Result APT_ReceiveDeliverArg(void *param, size_t paramSize, void *hmac, u64 *sender, bool *received)
Receives the deliver (launch) argument.
Result APT_IsRegistered(NS_APPID appID, bool *out)
Gets whether an application is registered.
Result APT_NotifyToWait(NS_APPID appID)
Notifies an application to wait.
Result APT_ReplySleepNotificationComplete(NS_APPID appID)
Replies that a sleep notification has been completed.
Result APT_Initialize(NS_APPID appId, APT_AppletAttr attr, Handle *signalEvent, Handle *resumeEvent)
Initializes an application's registration with APT.
Result APT_SetAppCpuTimeLimit(u32 percent)
Sets the application's CPU time limit.
Result APT_TryLockTransition(u32 transition, bool *succeeded)
Tries to lock a transition (?).
void aptSetHomeAllowed(bool allowed)
Configures whether the user can press the HOME button to jump back to the HOME menu while the applica...
void aptHook(aptHookCookie *cookie, aptHookFn callback, void *param)
Sets up an APT status hook.
Result APT_PrepareToDoApplicationJump(u8 flags, u64 programID, u8 mediatype)
Prepares for an applicaton jump.
void(* aptHookFn)(APT_HookType hook, void *param)
APT hook function.
Definition: apt.h:126
bool aptIsActive(void)
Returns true if the application is currently in the foreground.
Result APT_StartLibraryApplet(NS_APPID appID, const void *param, size_t paramSize, Handle handle)
Starts a library applet.
Result APT_CloseApplication(const void *param, size_t paramSize, Handle handle)
Closes the application.
void aptHandleSleep(void)
Handles incoming sleep mode requests.
Result APT_Enable(APT_AppletAttr attr)
Enables APT.
bool aptIsSleepAllowed(void)
Returns true if the system can enter sleep mode while the application is active.
static void aptHandleJumpToHome(void)
Handles incoming jump-to-HOME requests.
Definition: apt.h:188
Result aptSendCommand(u32 *aptcmdbuf)
Sends an APT command through IPC, taking care of locking, opening and closing an APT session.
Result APT_GetAppCpuTimeLimit(u32 *percent)
Gets the application's CPU time limit.
Result APT_StartSystemApplet(NS_APPID appID, const void *param, size_t paramSize, Handle handle)
Starts a system applet.
Result APT_CheckNew3DS(bool *out)
Checks whether the system is a New 3DS.
Result APT_GlanceParameter(NS_APPID appID, void *buffer, size_t bufferSize, NS_APPID *sender, APT_Command *command, size_t *actualSize, Handle *parameter)
Glances at a receieved parameter without removing it from the queue.
void aptJumpToHomeMenu(void)
Jumps back to the HOME menu.
void aptSetChainloader(u64 programID, u8 mediatype)
Configures the chainloader to launch a specific application.
Result APT_ReplySleepQuery(NS_APPID appID, APT_QueryReply reply)
Replies to a sleep query.
void aptLaunchLibraryApplet(NS_APPID appId, void *buf, size_t bufsize, Handle handle)
Launches a library applet.
Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion)
Gets an applet's program information.
void aptSetMessageCallback(aptMessageCb callback, void *user)
Sets the function to be called when an APT message from another applet is received.
bool aptIsHomeAllowed(void)
Returns true if the user can press the HOME button to jump back to the HOME menu while the applicatio...
bool aptShouldClose(void)
Returns true if the system has told the application to close.
Result APT_PrepareToJumpToApplication(bool exiting)
Prepares to jump to an application.
Result APT_PrepareToStartLibraryApplet(NS_APPID appID)
Prepares to start a library applet.
void aptClearChainloader(void)
Clears the chainloader state.
PDN wake events and MCU interrupts to select, combined with those of other processes.
Definition: ptmsysm.h:10
APT capture buffer information.
Definition: apt.h:103
APT hook cookie.
Definition: apt.h:130
void * param
Callback parameter.
Definition: apt.h:133
struct tag_aptHookCookie * next
Next cookie.
Definition: apt.h:131
aptHookFn callback
Hook callback.
Definition: apt.h:132
#define CTR_DEPRECATED
Flags a function as deprecated.
Definition: types.h:56
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
u32 Handle
Resource handle.
Definition: types.h:41
s32 Result
Function result.
Definition: types.h:42
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
uint32_t u32
32-bit unsigned integer
Definition: types.h:23