libnx  v4.6.0
mii.h
Go to the documentation of this file.
1 /**
2  * @file mii.h
3  * @brief Mii services (mii:*) IPC wrapper.
4  * @author XorTroll
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../sf/service.h"
10 
11 typedef enum {
12  MiiServiceType_System = 0, ///< Initializes mii:e.
13  MiiServiceType_User = 1, ///< Initializes mii:u.
15 
16 /// Mii age.
17 typedef enum {
18  MiiAge_Young = 0, ///< Young
19  MiiAge_Normal = 1, ///< Normal
20  MiiAge_Old = 2, ///< Old
21  MiiAge_All = 3, ///< All of them
22 } MiiAge;
23 
24 /// Mii gender.
25 typedef enum {
26  MiiGender_Male = 0, ///< Male
27  MiiGender_Female = 1, ///< Female
28  MiiGender_All = 2, ///< Both of them
29 } MiiGender;
30 
31 /// Mii face color.
32 typedef enum {
33  MiiFaceColor_Black = 0, ///< Black
34  MiiFaceColor_White = 1, ///< White
35  MiiFaceColor_Asian = 2, ///< Asian
36  MiiFaceColor_All = 3, ///< All of them
37 } MiiFaceColor;
38 
39 // Mii source flag.
40 typedef enum {
41  MiiSourceFlag_Database = BIT(0), ///< Miis created by the user
42  MiiSourceFlag_Default = BIT(1), ///< Default console miis
45 
46 // Mii special key code
47 typedef enum {
48  MiiSpecialKeyCode_Normal = 0, ///< Normal miis
49  MiiSpecialKeyCode_Special = 0xA523B78F, ///< Special miis
51 
52 typedef struct {
53  Service s;
54 } MiiDatabase;
55 
56 // Mii create ID.
57 typedef struct {
58  Uuid uuid;
59 } MiiCreateId;
60 
61 // Mii data structure.
62 typedef struct {
63  MiiCreateId create_id;
64  u16 mii_name[10+1]; ///< utf-16be, null-terminated
65  u8 unk_x26;
66  u8 mii_color;
67  u8 mii_sex;
68  u8 mii_height;
69  u8 mii_width;
70  u8 unk_x2b[2];
71  u8 mii_face_shape;
72  u8 mii_face_color;
73  u8 mii_wrinkles_style;
74  u8 mii_makeup_style;
75  u8 mii_hair_style;
76  u8 mii_hair_color;
77  u8 mii_has_hair_flipped;
78  u8 mii_eye_style;
79  u8 mii_eye_color;
80  u8 mii_eye_size;
81  u8 mii_eye_thickness;
82  u8 mii_eye_angle;
83  u8 mii_eye_pos_x;
84  u8 mii_eye_pos_y;
85  u8 mii_eyebrow_style;
86  u8 mii_eyebrow_color;
87  u8 mii_eyebrow_size;
88  u8 mii_eyebrow_thickness;
89  u8 mii_eyebrow_angle;
90  u8 mii_eyebrow_pos_x;
91  u8 mii_eyebrow_pos_y;
92  u8 mii_nose_style;
93  u8 mii_nose_size;
94  u8 mii_nose_pos;
95  u8 mii_mouth_style;
96  u8 mii_mouth_color;
97  u8 mii_mouth_size;
98  u8 mii_mouth_thickness;
99  u8 mii_mouth_pos;
100  u8 mii_facial_hair_color;
101  u8 mii_beard_style;
102  u8 mii_mustache_style;
103  u8 mii_mustache_size;
104  u8 mii_mustache_pos;
105  u8 mii_glasses_style;
106  u8 mii_glasses_color;
107  u8 mii_glasses_size;
108  u8 mii_glasses_pos;
109  u8 mii_has_mole;
110  u8 mii_mole_size;
111  u8 mii_mole_pos_x;
112  u8 mii_mole_pos_y;
113  u8 unk_x57;
114 } MiiCharInfo;
115 
116 // Original Mii colors and types before Ver3StoreData conversion
117 typedef struct {
118  u8 faceline_color;
119  u8 hair_color;
120  u8 eye_color;
121  u8 eyebrow_color;
122  u8 mouth_color;
123  u8 beard_color;
124  u8 glass_color;
125  u8 glass_type;
127 
128 /// Initialize mii.
130 
131 /// Exit mii.
132 void miiExit(void);
133 
134 /// Gets the Service object for the actual mii service session.
136 
137 /**
138  * @brief Opens a mii database.
139  * @param[in] key_code Mii key code filter.
140  * @param[out] out Database.
141  */
143 
144 /**
145  * @brief Returns whether the mii database is updated.
146  * @param[in] db Database.
147  * @param[in] flag Source flag.
148  * @param[out] out_updated Whether the mii database is updated.
149  */
150 Result miiDatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag);
151 
152 /**
153  * @brief Returns whether the mii database is full.
154  * @param[in] db Database.
155  * @param[out] out_full Whether the mii database is full.
156  */
157 Result miiDatabaseIsFull(MiiDatabase *db, bool *out_full);
158 
159 /**
160  * @brief Returns number of miis in the database with the specified source flag.
161  * @param[in] db Database.
162  * @param[in] flag Source flag.
163  * @param[out] out_count Out mii count.
164  */
166 
167 /**
168  * @brief Reads mii charinfo data from the specified source flag.
169  * @param[in] db Database.
170  * @param[in] flag Source flag.
171  * @param[out] out_infos Output mii charinfo array.
172  * @param[in] count Number of mii chainfos to read.
173  * @param[out] total_out Number of mii charinfos which were actually read.
174  */
175 Result miiDatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out);
176 
177 /**
178  * @brief Generates a random mii charinfo (doesn't register it in the console database).
179  * @param[in] db Database.
180  * @param[in] age Mii's age.
181  * @param[in] gender Mii's gender.
182  * @param[in] face_color Mii's face color.
183  * @param[out] out_info Out mii charinfo data.
184  */
186 
187 /// Closes a mii database.
Result miiDatabaseGetCount(MiiDatabase *db, s32 *out_count, MiiSourceFlag flag)
Returns number of miis in the database with the specified source flag.
MiiServiceType
Definition: mii.h:11
@ MiiServiceType_User
Initializes mii:u.
Definition: mii.h:13
@ MiiServiceType_System
Initializes mii:e.
Definition: mii.h:12
void miiDatabaseClose(MiiDatabase *db)
Closes a mii database.
Result miiDatabaseIsFull(MiiDatabase *db, bool *out_full)
Returns whether the mii database is full.
Result miiDatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag)
Returns whether the mii database is updated.
MiiAge
Mii age.
Definition: mii.h:17
@ MiiAge_All
All of them.
Definition: mii.h:21
@ MiiAge_Normal
Normal.
Definition: mii.h:19
@ MiiAge_Old
Old.
Definition: mii.h:20
@ MiiAge_Young
Young.
Definition: mii.h:18
MiiFaceColor
Mii face color.
Definition: mii.h:32
@ MiiFaceColor_White
White.
Definition: mii.h:34
@ MiiFaceColor_Black
Black.
Definition: mii.h:33
@ MiiFaceColor_Asian
Asian.
Definition: mii.h:35
@ MiiFaceColor_All
All of them.
Definition: mii.h:36
MiiSpecialKeyCode
Definition: mii.h:47
@ MiiSpecialKeyCode_Special
Special miis.
Definition: mii.h:49
@ MiiSpecialKeyCode_Normal
Normal miis.
Definition: mii.h:48
Service * miiGetServiceSession(void)
Gets the Service object for the actual mii service session.
Result miiOpenDatabase(MiiDatabase *out, MiiSpecialKeyCode key_code)
Opens a mii database.
Result miiDatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out)
Reads mii charinfo data from the specified source flag.
Result miiDatabaseBuildRandom(MiiDatabase *db, MiiAge age, MiiGender gender, MiiFaceColor face_color, MiiCharInfo *out_info)
Generates a random mii charinfo (doesn't register it in the console database).
MiiGender
Mii gender.
Definition: mii.h:25
@ MiiGender_Male
Male.
Definition: mii.h:26
@ MiiGender_All
Both of them.
Definition: mii.h:28
@ MiiGender_Female
Female.
Definition: mii.h:27
void miiExit(void)
Exit mii.
Result miiInitialize(MiiServiceType service_type)
Initialize mii.
MiiSourceFlag
Definition: mii.h:40
@ MiiSourceFlag_Database
Miis created by the user.
Definition: mii.h:41
@ MiiSourceFlag_Default
Default console miis.
Definition: mii.h:42
@ MiiSourceFlag_All
All of them.
Definition: mii.h:43
Definition: mii.h:62
Definition: mii.h:57
Definition: mii.h:52
Definition: mii.h:117
Service object structure.
Definition: service.h:14
Definition: types.h:48
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27