libctru  v2.3.1
miiselector.h
Go to the documentation of this file.
1 /**
2  * @file miiselector.h
3  * @brief Mii Selector Applet (appletEd).
4  */
5 
6 #pragma once
7 #include <3ds/types.h>
8 #include <3ds/mii.h>
9 
10 /// Magic value needed to launch the applet.
11 #define MIISELECTOR_MAGIC 0x13DE28CF
12 
13 /// Maximum length of title to be displayed at the top of the Mii selector applet
14 #define MIISELECTOR_TITLE_LEN 64
15 
16 /// Number of Guest Miis available for selection
17 #define MIISELECTOR_GUESTMII_SLOTS 6
18 
19 /// Maximum number of user Miis available for selection
20 #define MIISELECTOR_USERMII_SLOTS 100
21 
22 /// Parameter structure passed to AppletEd
23 typedef struct
24 {
25  u8 enable_cancel_button; ///< Enables canceling of selection if nonzero.
26  u8 enable_selecting_guests; ///< Makes Guets Miis selectable if nonzero.
27  u8 show_on_top_screen; ///< Shows applet on top screen if nonzero,
28  ///< otherwise show it on the bottom screen.
29  u8 _unk0x3[5]; ///< @private
30  u16 title[MIISELECTOR_TITLE_LEN]; ///< UTF16-LE string displayed at the top of the applet. If
31  ///< set to the empty string, a default title is displayed.
32  u8 _unk0x88[4]; ///< @private
33  u8 show_guest_page; ///< If nonzero, the applet shows a page with Guest
34  ///< Miis on launch.
35  u8 _unk0x8D[3]; ///< @private
36  u32 initial_index; ///< Index of the initially selected Mii. If
37  ///< @ref MiiSelectorConf.show_guest_page is
38  ///< set, this is the index of a Guest Mii,
39  ///< otherwise that of a user Mii.
40  u8 mii_guest_whitelist[MIISELECTOR_GUESTMII_SLOTS]; ///< Each byte set to a nonzero value
41  ///< enables its corresponding Guest
42  ///< Mii to be enabled for selection.
43  u8 mii_whitelist[MIISELECTOR_USERMII_SLOTS]; ///< Each byte set to a nonzero value enables
44  ///< its corresponding user Mii to be enabled
45  ///< for selection.
46  u16 _unk0xFE; ///< @private
47  u32 magic; ///< Will be set to @ref MIISELECTOR_MAGIC before launching the
48  ///< applet.
50 
51 /// Maximum length of the localized name of a Guest Mii
52 #define MIISELECTOR_GUESTMII_NAME_LEN 12
53 
54 /// Structure written by AppletEd
55 typedef struct
56 {
57  u32 no_mii_selected; ///< 0 if a Mii was selected, 1 if the selection was
58  ///< canceled.
59  u32 guest_mii_was_selected; ///< 1 if a Guest Mii was selected, 0 otherwise.
60  u32 guest_mii_index; ///< Index of the selected Guest Mii,
61  ///< 0xFFFFFFFF if no guest was selected.
62  MiiData mii; ///< Data of selected Mii.
63  u16 _pad0x68; ///< @private
64  u16 checksum; ///< Checksum of the returned Mii data.
65  ///< Stored as a big-endian value; use
66  ///< @ref miiSelectorChecksumIsValid to
67  ///< verify.
68  u16 guest_mii_name[MIISELECTOR_GUESTMII_NAME_LEN]; ///< Localized name of a Guest Mii,
69  ///< if one was selected (UTF16-LE
70  ///< string). Zeroed otherwise.
72 
73 /// AppletEd options
74 enum
75 {
76  MIISELECTOR_CANCEL = BIT(0), ///< Show the cancel button
77  MIISELECTOR_GUESTS = BIT(1), ///< Make Guets Miis selectable
78  MIISELECTOR_TOP = BIT(2), ///< Show AppletEd on top screen
79  MIISELECTOR_GUESTSTART = BIT(3), ///< Start on guest page
80 };
81 
82 /**
83  * @brief Initialize Mii selector config
84  * @param conf Pointer to Miiselector config.
85  */
87 
88 /**
89  * @brief Launch the Mii selector library applet
90  *
91  * @param conf Configuration determining how the applet should behave
92  */
93 void miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn* returnbuf);
94 
95 /**
96  * @brief Sets title of the Mii selector library applet
97  *
98  * @param conf Pointer to miiSelector configuration
99  * @param text Title text of Mii selector
100  */
101 void miiSelectorSetTitle(MiiSelectorConf *conf, const char* text);
102 
103 /**
104  * @brief Specifies which special options are enabled in the Mii selector
105  *
106  * @param conf Pointer to miiSelector configuration
107  * @param options Options bitmask
108  */
110 
111 /**
112  * @brief Specifies which guest Miis will be selectable
113  *
114  * @param conf Pointer to miiSelector configuration
115  * @param index Index of the guest Miis that will be whitelisted.
116  * @ref MIISELECTOR_GUESTMII_SLOTS can be used to whitelist all the guest Miis.
117  */
119 
120 /**
121  * @brief Specifies which guest Miis will be unselectable
122  *
123  * @param conf Pointer to miiSelector configuration
124  * @param index Index of the guest Miis that will be blacklisted.
125  * @ref MIISELECTOR_GUESTMII_SLOTS can be used to blacklist all the guest Miis.
126  */
128 
129 /**
130  * @brief Specifies which user Miis will be selectable
131  *
132  * @param conf Pointer to miiSelector configuration
133  * @param index Index of the user Miis that will be whitelisted.
134  * @ref MIISELECTOR_USERMII_SLOTS can be used to whitlist all the user Miis
135  */
137 
138 /**
139  * @brief Specifies which user Miis will be selectable
140  *
141  * @param conf Pointer to miiSelector configuration
142  * @param index Index of the user Miis that will be blacklisted.
143  * @ref MIISELECTOR_USERMII_SLOTS can be used to blacklist all the user Miis
144  */
146 
147 /**
148  * @brief Specifies which Mii the cursor should start from
149  *
150  * @param conf Pointer to miiSelector configuration
151  * @param index Indexed number of the Mii that the cursor will start on.
152  * If there is no mii with that index, the the cursor will start at the Mii
153  * with the index 0 (the personal Mii).
154  */
155 static inline void miiSelectorSetInitialIndex(MiiSelectorConf *conf, u32 index)
156 {
157  conf->initial_index = index;
158 }
159 
160 /**
161  * @brief Get Mii name
162  *
163  * @param returnbuf Pointer to miiSelector return
164  * @param out String containing a Mii's name
165  * @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
166  * (assuming that no non-BMP characters are used), this value should be 36 (or 30 if you are not
167  * dealing with guest miis).
168  */
169 void miiSelectorReturnGetName(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
170 
171 /**
172  * @brief Get Mii Author
173  *
174  * @param returnbuf Pointer to miiSelector return
175  * @param out String containing a Mii's author
176  * @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
177  * (assuming that no non-BMP characters are used), this value should be 30.
178  */
179 void miiSelectorReturnGetAuthor(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
180 
181 /**
182  * @brief Verifies that the Mii data returned from the applet matches its
183  * checksum
184  *
185  * @param returnbuf Buffer filled by Mii selector applet
186  * @return `true` if `returnbuf->checksum` is the same as the one computed from `returnbuf`
187  */
Shared Mii struct.
void miiSelectorWhitelistUserMii(MiiSelectorConf *conf, u32 index)
Specifies which user Miis will be selectable.
void miiSelectorBlacklistGuestMii(MiiSelectorConf *conf, u32 index)
Specifies which guest Miis will be unselectable.
static void miiSelectorSetInitialIndex(MiiSelectorConf *conf, u32 index)
Specifies which Mii the cursor should start from.
Definition: miiselector.h:155
#define MIISELECTOR_TITLE_LEN
Maximum length of title to be displayed at the top of the Mii selector applet.
Definition: miiselector.h:14
void miiSelectorReturnGetName(const MiiSelectorReturn *returnbuf, char *out, size_t max_size)
Get Mii name.
void miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn *returnbuf)
Launch the Mii selector library applet.
#define MIISELECTOR_GUESTMII_SLOTS
Number of Guest Miis available for selection.
Definition: miiselector.h:17
void miiSelectorSetOptions(MiiSelectorConf *conf, u32 options)
Specifies which special options are enabled in the Mii selector.
void miiSelectorSetTitle(MiiSelectorConf *conf, const char *text)
Sets title of the Mii selector library applet.
#define MIISELECTOR_USERMII_SLOTS
Maximum number of user Miis available for selection.
Definition: miiselector.h:20
void miiSelectorBlacklistUserMii(MiiSelectorConf *conf, u32 index)
Specifies which user Miis will be selectable.
@ MIISELECTOR_GUESTSTART
Start on guest page.
Definition: miiselector.h:79
@ MIISELECTOR_TOP
Show AppletEd on top screen.
Definition: miiselector.h:78
@ MIISELECTOR_CANCEL
Show the cancel button.
Definition: miiselector.h:76
@ MIISELECTOR_GUESTS
Make Guets Miis selectable.
Definition: miiselector.h:77
void miiSelectorWhitelistGuestMii(MiiSelectorConf *conf, u32 index)
Specifies which guest Miis will be selectable.
void miiSelectorInit(MiiSelectorConf *conf)
Initialize Mii selector config.
void miiSelectorReturnGetAuthor(const MiiSelectorReturn *returnbuf, char *out, size_t max_size)
Get Mii Author.
bool miiSelectorChecksumIsValid(const MiiSelectorReturn *returnbuf)
Verifies that the Mii data returned from the applet matches its checksum.
#define MIISELECTOR_GUESTMII_NAME_LEN
Maximum length of the localized name of a Guest Mii.
Definition: miiselector.h:52
Shared Mii struct.
Definition: mii.h:13
Parameter structure passed to AppletEd.
Definition: miiselector.h:24
u8 enable_selecting_guests
Makes Guets Miis selectable if nonzero.
Definition: miiselector.h:26
u8 show_guest_page
If nonzero, the applet shows a page with Guest Miis on launch.
Definition: miiselector.h:33
u32 magic
Will be set to MIISELECTOR_MAGIC before launching the applet.
Definition: miiselector.h:47
u8 enable_cancel_button
Enables canceling of selection if nonzero.
Definition: miiselector.h:25
u8 show_on_top_screen
Shows applet on top screen if nonzero, otherwise show it on the bottom screen.
Definition: miiselector.h:27
u32 initial_index
Index of the initially selected Mii.
Definition: miiselector.h:36
Structure written by AppletEd.
Definition: miiselector.h:56
u32 no_mii_selected
0 if a Mii was selected, 1 if the selection was canceled.
Definition: miiselector.h:57
u32 guest_mii_was_selected
1 if a Guest Mii was selected, 0 otherwise.
Definition: miiselector.h:59
MiiData mii
Data of selected Mii.
Definition: miiselector.h:62
u16 checksum
Checksum of the returned Mii data.
Definition: miiselector.h:64
u32 guest_mii_index
Index of the selected Guest Mii, 0xFFFFFFFF if no guest was selected.
Definition: miiselector.h:60
Various system types.
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
uint32_t u32
32-bit unsigned integer
Definition: types.h:23