libnx  v4.2.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 /// Initialize mii.
117 Result miiInitialize(MiiServiceType service_type);
118 
119 /// Exit mii.
120 void miiExit(void);
121 
122 /// Gets the Service object for the actual mii service session.
124 
125 /**
126  * @brief Opens a mii database.
127  * @param[in] key_code Mii key code filter.
128  * @param[out] out Database.
129  */
131 
132 /**
133  * @brief Returns whether the mii database is updated.
134  * @param[in] db Database.
135  * @param[in] flag Source flag.
136  * @param[out] out_updated Whether the mii database is updated.
137  */
138 Result miiDatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag);
139 
140 /**
141  * @brief Returns whether the mii database is full.
142  * @param[in] db Database.
143  * @param[out] out_full Whether the mii database is full.
144  */
145 Result miiDatabaseIsFull(MiiDatabase *db, bool *out_full);
146 
147 /**
148  * @brief Returns number of miis in the database with the specified source flag.
149  * @param[in] db Database.
150  * @param[in] flag Source flag.
151  * @param[out] out_count Out mii count.
152  */
154 
155 /**
156  * @brief Reads mii charinfo data from the specified source flag.
157  * @param[in] db Database.
158  * @param[in] flag Source flag.
159  * @param[out] out_infos Output mii charinfo array.
160  * @param[in] count Number of mii chainfos to read.
161  * @param[out] total_out Number of mii charinfos which were actually read.
162  */
163 Result miiDatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out);
164 
165 /**
166  * @brief Generates a random mii charinfo (doesn't register it in the console database).
167  * @param[in] db Database.
168  * @param[in] age Mii's age.
169  * @param[in] gender Mii's gender.
170  * @param[in] face_color Mii's face color.
171  * @param[out] out_info Out mii charinfo data.
172  */
173 Result miiDatabaseBuildRandom(MiiDatabase *db, MiiAge age, MiiGender gender, MiiFaceColor face_color, MiiCharInfo *out_info);
174 
175 /// Closes a mii database.
176 void miiDatabaseClose(MiiDatabase *db);
miiExit
void miiExit(void)
Exit mii.
MiiAge_All
@ MiiAge_All
All of them.
Definition: mii.h:21
miiDatabaseGetCount
Result miiDatabaseGetCount(MiiDatabase *db, s32 *out_count, MiiSourceFlag flag)
Returns number of miis in the database with the specified source flag.
MiiGender_All
@ MiiGender_All
Both of them.
Definition: mii.h:28
MiiSpecialKeyCode_Special
@ MiiSpecialKeyCode_Special
Special miis.
Definition: mii.h:49
MiiGender_Female
@ MiiGender_Female
Female.
Definition: mii.h:27
MiiAge_Young
@ MiiAge_Young
Young.
Definition: mii.h:18
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
MiiSpecialKeyCode
MiiSpecialKeyCode
Definition: mii.h:47
miiDatabaseGet1
Result miiDatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out)
Reads mii charinfo data from the specified source flag.
MiiServiceType
MiiServiceType
Definition: mii.h:11
miiDatabaseIsFull
Result miiDatabaseIsFull(MiiDatabase *db, bool *out_full)
Returns whether the mii database is full.
s32
int32_t s32
32-bit signed integer.
Definition: types.h:27
miiOpenDatabase
Result miiOpenDatabase(MiiDatabase *out, MiiSpecialKeyCode key_code)
Opens a mii database.
MiiSourceFlag_Default
@ MiiSourceFlag_Default
Default console miis.
Definition: mii.h:42
miiGetServiceSession
Service * miiGetServiceSession(void)
Gets the Service object for the actual mii service session.
MiiDatabase
Definition: mii.h:52
MiiCharInfo
Definition: mii.h:62
miiInitialize
Result miiInitialize(MiiServiceType service_type)
Initialize mii.
MiiServiceType_System
@ MiiServiceType_System
Initializes mii:e.
Definition: mii.h:12
MiiFaceColor_All
@ MiiFaceColor_All
All of them.
Definition: mii.h:36
MiiAge_Normal
@ MiiAge_Normal
Normal.
Definition: mii.h:19
Result
u32 Result
Function error code result type.
Definition: types.h:44
MiiSourceFlag_All
@ MiiSourceFlag_All
All of them.
Definition: mii.h:43
miiDatabaseClose
void miiDatabaseClose(MiiDatabase *db)
Closes a mii database.
MiiSourceFlag
MiiSourceFlag
Definition: mii.h:40
MiiFaceColor_Black
@ MiiFaceColor_Black
Black.
Definition: mii.h:33
MiiGender_Male
@ MiiGender_Male
Male.
Definition: mii.h:26
Uuid
Definition: types.h:48
MiiAge_Old
@ MiiAge_Old
Old.
Definition: mii.h:20
MiiGender
MiiGender
Mii gender.
Definition: mii.h:25
MiiCreateId
Definition: mii.h:57
MiiFaceColor_Asian
@ MiiFaceColor_Asian
Asian.
Definition: mii.h:35
BIT
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
Service
Service object structure.
Definition: service.h:13
MiiSpecialKeyCode_Normal
@ MiiSpecialKeyCode_Normal
Normal miis.
Definition: mii.h:48
MiiFaceColor
MiiFaceColor
Mii face color.
Definition: mii.h:32
MiiFaceColor_White
@ MiiFaceColor_White
White.
Definition: mii.h:34
miiDatabaseIsUpdated
Result miiDatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag)
Returns whether the mii database is updated.
MiiAge
MiiAge
Mii age.
Definition: mii.h:17
miiDatabaseBuildRandom
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).
u16
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
MiiSourceFlag_Database
@ MiiSourceFlag_Database
Miis created by the user.
Definition: mii.h:41
MiiServiceType_User
@ MiiServiceType_User
Initializes mii:u.
Definition: mii.h:13