libnx
applet.h
Go to the documentation of this file.
1 /**
2  * @file applet.h
3  * @brief Applet (applet) service IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 
10 typedef enum {
11  AppletType_None = -2,
12  AppletType_Default = -1,
13  AppletType_Application = 0,
14  AppletType_SystemApplet = 1,
15  AppletType_LibraryApplet = 2,
16  AppletType_OverlayApplet = 3,
17  AppletType_SystemApplication = 4,
18 } AppletType;
19 
20 typedef enum {
21  AppletOperationMode_Handheld = 0,
22  AppletOperationMode_Docked = 1,
23 } AppletOperationMode;
24 
25 /// applet hook types.
26 typedef enum {
27  AppletHookType_OnFocusState = 0, ///< FocusState changed.
28  AppletHookType_OnOperationMode, ///< OperationMode changed.
29  AppletHookType_OnPerformanceMode, ///< PerformanceMode changed.
30 
31  AppletHookType_Max, ///< Number of applet hook types.
33 
34 /// applet hook function.
35 typedef void (*AppletHookFn)(AppletHookType hook, void* param);
36 
37 /// applet hook cookie.
38 typedef struct AppletHookCookie AppletHookCookie;
39 
41 {
42  AppletHookCookie* next; ///< Next cookie.
43  AppletHookFn callback; ///< Hook callback.
44  void* param; ///< Callback parameter.
45 };
46 
47 Result appletInitialize(void);
48 void appletExit(void);
49 Result appletGetAppletResourceUserId(u64 *out);
50 
51 void appletNotifyRunning(u8 *out);
52 Result appletCreateManagedDisplayLayer(u64 *out);
53 
54 Result appletGetDesiredLanguage(u64 *LanguageCode);
55 
56 /**
57  * @brief Controls whether screenshot-capture is allowed.
58  * @param val 0 = disable, 1 = enable.
59  */
61 
62 Result appletSetScreenShotImageOrientation(s32 val);
63 
64 /**
65  * @brief Processes the current applet status. Generally used within a main loop.
66  * @return Whether the application should continue running.
67  */
68 bool appletMainLoop(void);
69 
70 
71 /**
72  * @brief Sets up an applet status hook.
73  * @param cookie Hook cookie to use.
74  * @param callback Function to call when applet's status changes.
75  * @param param User-defined parameter to pass to the callback.
76  */
78 
79 /**
80  * @brief Removes an applet status hook.
81  * @param cookie Hook cookie to remove.
82  */
83 void appletUnhook(AppletHookCookie* cookie);
84 
85 /// These return state which is updated by appletMainLoop() when notifications are received.
87 u32 appletGetPerformanceMode(void);
88 u8 appletGetFocusState(void);
OperationMode changed.
Definition: applet.h:28
applet hook cookie.
Definition: applet.h:40
u32 Result
Function error code result type.
Definition: types.h:46
uint8_t u8
8-bit unsigned integer.
Definition: types.h:21
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
AppletHookCookie * next
Next cookie.
Definition: applet.h:42
AppletHookType
applet hook types.
Definition: applet.h:26
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
PerformanceMode changed.
Definition: applet.h:29
void(* AppletHookFn)(AppletHookType hook, void *param)
applet hook function.
Definition: applet.h:35
int32_t s32
32-bit signed integer.
Definition: types.h:29
Result appletSetScreenShotPermission(s32 val)
Controls whether screenshot-capture is allowed.
void * param
Callback parameter.
Definition: applet.h:44
u8 appletGetOperationMode(void)
These return state which is updated by appletMainLoop() when notifications are received.
Number of applet hook types.
Definition: applet.h:31
void appletUnhook(AppletHookCookie *cookie)
Removes an applet status hook.
FocusState changed.
Definition: applet.h:27
AppletHookFn callback
Hook callback.
Definition: applet.h:43
void appletHook(AppletHookCookie *cookie, AppletHookFn callback, void *param)
Sets up an applet status hook.
bool appletMainLoop(void)
Processes the current applet status.