From 9e0f259f6cff753c61a66f1a9ea70c9bb9c043ef Mon Sep 17 00:00:00 2001 From: XorTroll Date: Thu, 16 Apr 2020 15:08:42 +0200 Subject: [PATCH] Properly document both services --- nx/include/switch/services/mii.h | 89 +++++++++++++++++++++++------ nx/include/switch/services/miiimg.h | 40 ++++++++++++- 2 files changed, 107 insertions(+), 22 deletions(-) diff --git a/nx/include/switch/services/mii.h b/nx/include/switch/services/mii.h index f9ddaaa8..b5ddc66f 100644 --- a/nx/include/switch/services/mii.h +++ b/nx/include/switch/services/mii.h @@ -1,6 +1,6 @@ /** * @file mii.h - * @brief Mii services IPC wrapper. + * @brief Mii services (mii:*) IPC wrapper. * @author XorTroll * @copyright libnx Authors */ @@ -9,49 +9,56 @@ #include "../sf/service.h" typedef enum { - MiiServiceType_System, - MiiServiceType_User + MiiServiceType_System = 0, ///< Initializes mii:e. + MiiServiceType_User = 1, ///< Initializes mii:u. } MiiServiceType; +/// Mii age. typedef enum { - MiiAge_Young, - MiiAge_Normal, - MiiAge_Old, - MiiAge_All + MiiAge_Young = 0, ///< Young + MiiAge_Normal = 1, ///< Normal + MiiAge_Old = 2, ///< Old + MiiAge_All = 3, ///< All of them } MiiAge; +/// Mii gender. typedef enum { - MiiGender_Male, - MiiGender_Female, - MiiGender_All + MiiGender_Male = 0, ///< Male + MiiGender_Female = 1, ///< Female + MiiGender_All = 2, ///< Both of them } MiiGender; +/// Mii race. typedef enum { - MiiRace_Black, - MiiRace_White, - MiiRace_Asian, - MiiRace_All + MiiRace_Black = 0, ///< Black + MiiRace_White = 1, ///< White + MiiRace_Asian = 2, ///< Asian + MiiRace_All = 3, ///< All of them } MiiRace; +// Mii source flag. typedef enum { - MiiSourceFlag_Database = BIT(0), - MiiSourceFlag_Default = BIT(1), - MiiSourceFlag_All = MiiSourceFlag_Database | MiiSourceFlag_Default + MiiSourceFlag_Database = BIT(0), ///< Miis created by the user + MiiSourceFlag_Default = BIT(1), ///< Default console miis + MiiSourceFlag_All = MiiSourceFlag_Database | MiiSourceFlag_Default, ///< All of them } MiiSourceFlag; +// Mii special key code typedef enum { - MiiSpecialKeyCode_Normal, - MiiSpecialKeyCode_Special = 0xA523B78F + MiiSpecialKeyCode_Normal = 0, ///< Normal miis + MiiSpecialKeyCode_Special = 0xA523B78F, ///< Special miis } MiiSpecialKeyCode; typedef struct { Service s; } MiiDatabase; +// Mii create ID. typedef struct { Uuid uuid; } MiiCreateId; +// Mii data structure. typedef struct { MiiCreateId create_id; u16 mii_name[10+1]; ///< utf-16be, null-terminated @@ -115,12 +122,56 @@ void miiExit(void); /// Gets the Service object for the actual mii service session. Service* miiGetServiceSession(void); +/** + * @brief Opens a mii database. + * @param[in] key_code Mii key code filter. + * @param[out] out Database. + */ Result miiOpenDatabase(MiiDatabase *out, MiiSpecialKeyCode key_code); +/** + * @brief Returns whether the mii database is updated. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out Out boolean. + */ Result miiDatabaseIsUpdated(MiiDatabase *db, u8 *out, MiiSourceFlag flag); + +/** + * @brief Returns whether the mii database is full. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out Out boolean. + */ Result miiDatabaseIsFull(MiiDatabase *db, u8 *out); + +/** + * @brief Returns number of miis in the database with the specified source flag. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out Out count. + */ Result miiDatabaseGetCount(MiiDatabase *db, u32 *out, MiiSourceFlag flag); + +/** + * @brief Reads mii charinfo data from the specified source flag. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out_infos Output mii charinfo array. + * @param[in] out_infos_count Amount of mii chainfos to read. + * @param[out] out_count Number of mii charinfos which were read. + */ Result miiDatabaseGetCharInfo(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, size_t out_infos_count, u32 *out_count); + +/** + * @brief Generates a random mii charinfo (doesn't register it in the console database). + * @param[in] db Database. + * @param[in] age Mii's age. + * @param[in] gender Mii's gender. + * @param[in] race Mii's race. + * @param[out] out_info Out mii charinfo data. + */ Result miiDatabaseBuildRandom(MiiDatabase *db, MiiAge age, MiiGender gender, MiiRace race, MiiCharInfo *out_info); +/// Closes a mii database. void miiDatabaseClose(MiiDatabase *db); diff --git a/nx/include/switch/services/miiimg.h b/nx/include/switch/services/miiimg.h index 7a086c16..4309e98d 100644 --- a/nx/include/switch/services/miiimg.h +++ b/nx/include/switch/services/miiimg.h @@ -7,15 +7,17 @@ #pragma once #include "mii.h" +/// Image ID. typedef struct { Uuid uuid; } MiiimgImageId; +/// Image attribute. typedef struct { - MiiimgImageId image_id; - MiiCreateId create_id; + MiiimgImageId image_id; ///< Image ID. + MiiCreateId create_id; ///< Mii's create ID. u32 unk; - u16 mii_name[10+1]; + u16 mii_name[10+1]; ///< utf-16be, null-terminated } PACKED MiiimgImageAttribute; /// Initialize miiimg. @@ -27,9 +29,41 @@ void miiimgExit(void); /// Gets the Service object for the actual miiimg service session. Service* miiimgGetServiceSession(void); +/** + * @brief Reloads the image database. + */ Result miiimgReload(); + +/** + * @brief Gets the number of mii images in the database. + * @param[out] out_count Mii image count. + */ Result miiimgGetCount(u32 *out_count); + +/** + * @brief Gets whether the image database is empty. + * @param[out] out_empty Whether the database is empty. + */ Result miiimgIsEmpty(u8 *out_empty); + +/** + * @brief Gets whether the image database is full. + * @param[out] out_empty Whether the database is full. + */ Result miiimgIsFull(u8 *out_full); + +/** + * @brief Gets the image attribute for the specified image index. + * @param[in] index Image index. + * @param[out] out_attr Out image attribute. + */ Result miiimgGetAttribute(u32 index, MiiimgImageAttribute *out_attr); + +/** + * @brief Loads the image data (raw RGBA8) for the specified image ID. + * @param[in] id Input image ID. + * @param[out] out_image Out iamge buffer. + * @param[in] out_image_size Out image buffer size. + * @note Server doesn't seem to check the image buffer size, but 0x40000 is the optimal size. + */ Result miiimgLoadImage(MiiimgImageId id, void *out_image, size_t out_image_size);