1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     applet_Parameters.h
4 
5   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 35614 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_APPLET_CTR_APPLET_PARAMETERS_H_
17 #define NN_APPLET_CTR_APPLET_PARAMETERS_H_
18 
19 #include <nn/fnd.h>
20 #include <nn/gx/CTR/gx_Lcd.h>
21 
22 namespace nn{
23 namespace applet{
24 namespace CTR{
25 
26     enum Attribute
27     {
28         //---- Applet types
29         TYPE_APP                        = (0x0<<0), //000 application
30         TYPE_APPLIB                     = (0x1<<0), //001 Library applet
31         TYPE_SYS                        = (0x2<<0), //010 System applet
32         TYPE_SYSLIB                     = (0x3<<0), //011 System library applet
33         TYPE_RESIDENT                   = (0x4<<0), //100 Static applet
34         TYPE_MASK                       = (0x7<<0), //111 (Mask for applet types)
35 
36         //---- GPU rights settings
37         MANUAL_GPU_RIGHT                = (1<<3),   // Manually perform Assign/Release
38 
39         //---- DSP rights settings
40         MANUAL_DSP_RIGHT                = (1<<4)    // Manually perform Assign/Release
41     };
42     const bit32 DEFAULT_APPLET_ATTRIBUTE = (TYPE_APP);
43 
44     enum DisplayBufferMode
45     {
46         FORMAT_R8G8B8A8                 = 0,
47         FORMAT_R8G8B8                   = 1,
48         FORMAT_R5G6B5                   = 2,
49         FORMAT_R5G5B5A1                 = 3,
50         FORAMT_R4G4B4A4                 = 4,
51         FORMAT_UNIMPORTABLE             = 0xFFFFFFFF
52     };
53 
54     /* Please see man pages for details
55 
56 
57 
58 
59 
60     */
61     enum HomeButtonState
62     {
63         HOME_BUTTON_NONE                = 0, //
64         HOME_BUTTON_SINGLE_PRESSED      = 1, //
65         HOME_BUTTON_DOUBLE_PRESSED      = 2  //
66     };
67 
68     enum ShutdownState
69     {
70         SHUTDOWN_STATE_NONE             = 0, // Haven't received shutdown notification
71         SHUTDOWN_STATE_RECEIVED         = 1  // Received shutdown notification
72     };
73 
74     enum PowerButtonState
75     {
76         POWER_BUTTON_STATE_NONE         = 0, // Not pressed
77         POWER_BUTTON_STATE_CLICK        = 1  // Click
78     };
79 
80     enum OrderToCloseState
81     {
82         ORDER_TO_CLOSE_STATE_NONE       = 0, // No close order
83         ORDER_TO_CLOSE_STATE_RECEIVED   = 1  // Close order received
84     };
85 
86     /* Please see man pages for details
87 
88 
89 
90     */
91     enum SleepNotificationState
92     {
93         NOTIFY_NONE                     = 0, //
94         NOTIFY_SLEEP_QUERY              = 1, //
95         NOTIFY_SLEEP_ACCEPT             = 2, //
96         NOTIFY_SLEEP_REJECT             = 3, //
97         NOTIFY_SLEEP_ACCEPTED           = 4, //
98         NOTIFY_AWAKE                    = 5  //
99     };
100 
101     enum AppJumpType
102     {
103         JUMP_OTHER                      = 0, // Jump to another application
104         JUMP_CALLER                     = 1, // Jump to the caller
105         JUMP_SELF                       = 2  // Jump to self
106     };
107 
108     enum AppletPos
109     {
110         POS_APP                         = 0, // Application
111         POS_APPLIB                      = 1, // Library applet launched by the application
112         POS_SYS                         = 2, // System
113         POS_SYSLIB                      = 3, // Library applet launched by the system
114         POS_RESIDENT                    = 4, // Static applet
115         POS_MAX,
116 
117         POS_NONE                        = -1 // No definite position
118     };
119 
120     /* Please see man pages for details
121 
122 
123 
124     */
125     enum WakeupState
126     {
127         //Entered sleep
128         WAKEUP_SKIP                     = 0,  //
129 
130         //Woken by a normal request   → The woken side starts operation
131         WAKEUP_TO_START                 = 1,  //
132         //Terminated and woken →  Woken side starts operation
133         WAKEUP_BY_EXIT                  = 2,  //
134         // Paused and woken →  Woken side starts operation
135         WAKEUP_BY_PAUSE                 = 3,  //
136         //Woken up by cancel notification → Woken side terminates
137         WAKEUP_BY_CANCEL                = 4,  //
138         //Woken by cancel notification → Woken side terminates → Terminate others as needed
139         WAKEUP_BY_CANCELALL             = 5,  //
140         // Woken by Power button click → Only the system menu can be woken up. Transition to sleep recommended screen
141         WAKEUP_BY_POWER_BUTTON_CLICK    = 6,  //
142         //Woken for transition to HOME Menu→ The woken up side calls JumpToHomeMenu()
143         WAKEUP_TO_JUMP_HOME             = 7,  //
144         //Woken for transition to application → The woken side calls LeaveHomeMenu()
145         WAKEUP_TO_JUMP_APPLICATION      = 8,  //
146         //Woken to launch application → The woken side calls StartApplication()
147         WAKEUP_TO_LAUNCH_APPLICATION    = 9, //
148 
149         // Time out
150         WAKEUP_BY_TIMEOUT               = -1  //
151     };
152 
153     /* Please see man pages for details
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164     */
165 
166     enum QueryReply
167     {
168         REPLY_REJECT                    = 0, //
169         REPLY_ACCEPT                    = 1, //
170         REPLY_LATER                     = 2  //
171     };
172 
173 
174     enum UsableAppletId
175     {
176         APPLET_ID_NONE                  = 0,    // Unused
177         //
178         // application
179         APPLICATION_APPLET_ID           = 0x300, // application
180 
181         // library applet
182         APPLIB_APPLET_ID                = 0x400, // Library applet
183 
184         // resident applet
185         ERRDISP_APPLET_ID               = 0x501, // ERROR DISPLAY
186 
187         APPLET_ID_MAX
188     };
189 
190 
191     enum SleepCheckOnEnableSleep
192     {
193         SLEEP_IF_SHELL_CLOSED           = true,
194         NO_SHELL_CHECK                  = false
195     };
196     enum ReplyRejectOnDisableSleep
197     {
198         REPLY_REJECT_IF_LATER           = true,
199         NO_REPLY_REJECT                 = false
200     };
201 
202     /* Please see man pages for details
203 
204     */
205     typedef bit32                                  AppletId;
206 
207     /* Please see man pages for details
208 
209     */
210     typedef bit32                                   AppletAttr;
211 
212     typedef nn::applet::CTR::DisplayBufferMode      AppletDisplayBufferMode;
213 
214     typedef nn::applet::CTR::HomeButtonState        AppletHomeButtonState;
215 
216     typedef nn::applet::CTR::SleepNotificationState AppletSleepNotificationState;
217 
218     typedef nn::applet::CTR::ShutdownState          AppletShutdownState;
219 
220     typedef nn::applet::CTR::PowerButtonState       AppletPowerButtonState;
221 
222     typedef nn::applet::CTR::OrderToCloseState      AppletOrderToCloseState;
223 
224     typedef nn::applet::CTR::WakeupState            AppletWakeupState;
225 
226     typedef nn::applet::CTR::QueryReply             AppletQueryReply;
227 
228     typedef nn::applet::CTR::AppJumpType            AppletAppJumpType;
229 
230     // Invalid handle
231     extern const nn::Handle                         HANDLE_NONE;
232 
233     // Time
234     /* Please see man pages for details
235 
236 
237     */
238     extern const nn::fnd::TimeSpan                  WAIT_INFINITE;
239     /* Please see man pages for details
240 
241 
242     */
243     extern const nn::fnd::TimeSpan                  NO_WAIT;
244 
245     // Invalid applet ID
246     const bit32 INVALID_ID                          = 0;
247 
248     // Invalid program ID
249     const bit64 INVALID_PROGRAM_ID                  = 0xffffffffffffffffull;
250 
251     // ----- Callbacks
252     /* Please see man pages for details
253 
254     */
255     typedef bool (*AppletHomeButtonCallback)( uptr arg, bool isActive, nn::applet::CTR::HomeButtonState state );
256     /* Please see man pages for details
257 
258     */
259     typedef void (*AppletMessageCallback)( uptr arg, AppletId senderId, u8 pParam[], size_t paramSize, nn::Handle handle );
260 
261     // Memory request
262     typedef void (*AppletRequestMemoryCallback)( uptr arg, size_t size, nn::Handle* pHandle );
263     // Finalize memory request
264     typedef void (*AppletReleaseMemoryCallback)( uptr arg );
265 
266     // DSP sleep
267     typedef void (*AppletDspSleepCallback)( uptr arg );
268     // DSP wakeup
269     typedef void (*AppletDspWakeUpCallback)( uptr arg );
270 
271     /* Please see man pages for details
272 
273     */
274     typedef AppletQueryReply (*AppletSleepQueryCallback)( uptr arg );
275     /* Please see man pages for details
276 
277     */
278     typedef void (*AppletSleepCanceledCallback)( uptr arg );
279     /* Please see man pages for details
280 
281     */
282     typedef void (*AppletAwakeCallback)( uptr arg );
283 
284     /* Please see man pages for details
285 
286     */
287     typedef void (*AppletShutdownCallback)( uptr arg );
288     /* Please see man pages for details
289 
290     */
291     typedef void (*AppletCloseAppletCallback)( uptr arg ); // This is actually common to all applets
292 
293     /* Please see man pages for details
294 
295     */
296     typedef void (*AppletPowerButtonCallback)( uptr arg );
297 
298     /* Please see man pages for details
299 
300     */
301     typedef void (*AppletTransitionCallback)( uptr arg );
302 
303     /* Please see man pages for details
304 
305     */
306     typedef void (*AppletCloseCallback)( uptr arg );
307 
308 }
309 }
310 }
311 
312 /* Please see man pages for details
313 
314 
315 */
316 #define NN_APPLET_PORT_NAME_USER        "APT:U"  // User Application
317 
318 /* Please see man pages for details
319 
320 */
321 #define NN_APPLET_MAX_APPLET_NUM        5
322 
323 #define NN_APPLET_PARAMETER_MAX         4096    //
324 #define NN_APPLET_PARAM_BUF_SIZE        768
325 #define NN_APPLET_HMAC_BUF_SIZE         32
326 
327 // The size of the buffer (924 KB) that stores the capture image includes padding so that it can be used as texture data.
328 #define NN_APPLET_CAPTURE_BUF_SIZE      (256 * (NN_GX_DISPLAY0_HEIGHT + NN_GX_DISPLAY1_HEIGHT + 512) * 3)
329 
330 // Attribute
331 #define NN_APPLET_TYPE_APP                      (nn::applet::CTR::TYPE_APP)
332 #define NN_APPLET_TYPE_APPLIB                   (nn::applet::CTR::TYPE_APPLIB)
333 #define NN_APPLET_TYPE_SYS                      (nn::applet::CTR::TYPE_SYS)
334 #define NN_APPLET_TYPE_SYSLIB                   (nn::applet::CTR::TYPE_SYSLIB)
335 #define NN_APPLET_TYPE_RESIDENT                 (nn::applet::CTR::TYPE_RESIDENT)
336 #define NN_APPLET_TYPE_MASK                     (nn::applet::CTR::TYPE_MASK)
337 
338 #define NN_APPLET_MANUAL_GPU_RIGHT              (nn::applet::CTR::MANUAL_GPU_RIGHT)
339 #define NN_APPLET_MANUAL_DSP_RIGHT              (nn::applet::CTR::MANUAL_DSP_RIGHT)
340 
341 // HOME Button
342 #define NN_APPLET_HOME_BUTTON_NONE              (nn::applet::CTR::HOME_BUTTON_NONE)
343 #define NN_APPLET_HOME_BUTTON_SINGLE_PRESSED    (nn::applet::CTR::HOME_BUTTON_SINGLE_PRESSED)
344 #define NN_APPLET_HOME_BUTTON_DOUBLE_PRESSED    (nn::applet::CTR::HOME_BUTTON_DOUBLE_PRESSED)
345 
346 // System application notification
347 #define NN_APPLET_NOTIFY_NONE                   (nn::applet::NOTIFY_NONE)
348 #define NN_APPLET_NOTIFY_SLEEP_QUERY            (nn::applet::NOTIFY_SLEEP_QUERY)
349 #define NN_APPLET_NOTIFY_SLEEP_ACCEPT           (nn::applet::NOTIFY_SLEEP_ACCEPT)
350 #define NN_APPLET_NOTIFY_SLEEP_REJECT           (nn::applet::NOTIFY_SLEEP_REJECT)
351 #define NN_APPLET_NOTIFY_AWAKE                  (nn::applet::NOTIFY_AWAKE)
352 
353 // Applet type
354 #define NN_APPLET_POS_SYSLIB                    (nn::applet::CTR::POS_SYSLIB)
355 #define NN_APPLET_POS_SYS                       (nn::applet::CTR::POS_SYS)
356 #define NN_APPLET_POS_APP                       (nn::applet::CTR::POS_APP)
357 #define NN_APPLET_POS_APPLIB                    (nn::applet::CTR::POS_APPLIB)
358 #define NN_APPLET_POS_RESIDENT                  (nn::applet::CTR::POS_RESIDENT)
359 #define NN_APPLET_POS_MAX                       (nn::applet::CTR::POS_MAX)
360 
361 // Sleep request response
362 #define NN_APPLET_REPLY_ACCEPT                  (nn::applet::REPLY_ACCEPT)
363 #define NN_APPLET_REPLY_REJECT                  (nn::applet::REPLY_REJECT)
364 #define NN_APPLET_REPLY_LATER                   (nn::applet::REPLY_LATER)
365 
366 //
367 #define NN_APPLET_NO_PREPARATION                (nn::applet::NO_PREPARATION)
368 #define NN_APPLET_PREPARED_TO_LAUNCH_APP        (nn::applet::PREPARED_TO_LAUNCH_APP)
369 #define NN_APPLET_PREPARED_TO_CLOSE_APP         (nn::applet::PREPARED_TO_CLOSE_APP)
370 #define NN_APPLET_PREPARED_TO_LAUNCH_APPLIB     (nn::applet::PREPARED_TO_LAUNCH_APPLIB)
371 #define NN_APPLET_PREPARED_TO_CLOSE_APPLIB      (nn::applet::PREPARED_TO_CLOSE_APPLIB)
372 #define NN_APPLET_PREPARED_TO_LAUNCH_SYS        (nn::applet::PREPARED_TO_LAUNCH_SYS)
373 #define NN_APPLET_PREPARED_TO_CLOSE_SYS         (nn::applet::PREPARED_TO_CLOSE_SYS)
374 #define NN_APPLET_PREPARED_TO_LAUNCH_SYSLIB     (nn::applet::PREPARED_TO_LAUNCH_SYSLIB)
375 #define NN_APPLET_PREPARED_TO_CLOSE_SYSLIB      (nn::applet::PREPARED_TO_CLOSE_SYSLIB)
376 #define NN_APPLET_PREPARED_TO_LAUNCH_RESIDENT   (nn::applet::PREPARED_TO_LAUNCH_RESIDENT)
377 #define NN_APPLET_PREPARED_TO_LEAVE_RESIDENT    (nn::applet::PREPARED_TO_LEAVE_RESIDENT)
378 #define NN_APPLET_PREPARED_TO_DO_HOMEMENU       (nn::applet::PREPARED_TO_DO_HOMEMENU)
379 #define NN_APPLET_PREPARED_TO_LEAVE_HOMEMENU    (nn::applet::PREPARED_TO_LEAVE_HOMEMENU)
380 
381 // Applet ID
382 #define NN_APPLET_APPLICATION_APPLET_ID         (nn::applet::CTR::APPLICATION_APPLET_ID)
383 #define NN_APPLET_ERRDISP_APPLET_ID             (nn::applet::CTR::ERRDISP_APPLET_ID)
384 
385 // Invalid handle
386 #define NN_APPLET_HANDLE_NONE                   (nn::applet::CTR::HANDLE_NONE)
387 
388 // Time
389 #define NN_APPLET_WAIT_INFINITE                 (nn::applet::CTR::WAIT_INFINITE)
390 #define NN_APPLET_NO_WAIT                       (nn::applet::CTR::NO_WAIT)
391 
392 // Invalid applet ID
393 #define NN_APPLET_INVALID_ID                    (nn::applet::CTR::INVALID_ID)
394 // Invalid program ID
395 #define NN_APPLET_INVALID_PROGRAM_ID            (nn::applet::CTR::INVALID_PROGRAM_ID)
396 
397 #define NN_APPLET_DEFAULT_APPLET_ATTRIBUTE      (nn::applet::CTR::DEFAULT_APPLET_ATTRIBUTE)
398 
399 /*
400 
401 */
402 
403 
404 using nn::applet::CTR::AppletId;
405 using nn::applet::CTR::AppletAttr;
406 
407 using nn::applet::CTR::AppletHomeButtonState;
408 using nn::applet::CTR::AppletSleepNotificationState;
409 
410 using nn::applet::CTR::AppletHomeButtonCallback;
411 using nn::applet::CTR::AppletMessageCallback;
412 using nn::applet::CTR::AppletRequestMemoryCallback;
413 using nn::applet::CTR::AppletReleaseMemoryCallback;
414 using nn::applet::CTR::AppletDspSleepCallback;
415 using nn::applet::CTR::AppletDspWakeUpCallback;
416 using nn::applet::CTR::AppletSleepQueryCallback;
417 using nn::applet::CTR::AppletSleepCanceledCallback;
418 using nn::applet::CTR::AppletAwakeCallback;
419 using nn::applet::CTR::AppletShutdownCallback;
420 using nn::applet::CTR::AppletCloseAppletCallback;
421 using nn::applet::CTR::AppletPowerButtonCallback;
422 
423 using nn::applet::CTR::AppletWakeupState;
424 using nn::applet::CTR::AppletQueryReply;
425 
426 
427 #endif  // ifndef NN_APPLET_CTR_APPLET_PARAMETERS_H_
428