mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
miiLa: Added for support for 10.2.0 functionality + various fixes.
This commit is contained in:
parent
0d5dcde5b9
commit
d4014bde62
@ -10,18 +10,26 @@
|
|||||||
|
|
||||||
/// AppletMode
|
/// AppletMode
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NfpLaMiiLaAppletMode_ShowMiiEdit = 0, ///< ShowMiiEdit
|
MiiLaAppletMode_ShowMiiEdit = 0, ///< ShowMiiEdit
|
||||||
NfpLaMiiLaAppletMode_AppendMii = 1, ///< AppendMii
|
MiiLaAppletMode_AppendMii = 1, ///< AppendMii
|
||||||
NfpLaMiiLaAppletMode_AppendMiiImage = 2, ///< AppendMiiImage
|
MiiLaAppletMode_AppendMiiImage = 2, ///< AppendMiiImage
|
||||||
NfpLaMiiLaAppletMode_UpdateMiiImage = 3, ///< UpdateMiiImage
|
MiiLaAppletMode_UpdateMiiImage = 3, ///< UpdateMiiImage
|
||||||
|
MiiLaAppletMode_CreateMii = 4, ///< [10.2.0+] CreateMii
|
||||||
|
MiiLaAppletMode_EditMii = 5, ///< [10.2.0+] EditMii
|
||||||
} MiiLaAppletMode;
|
} MiiLaAppletMode;
|
||||||
|
|
||||||
/// AppletInput
|
/// AppletInput
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 unk_x0; ///< Always set to value 0x3.
|
s32 version; ///< Version
|
||||||
u32 mode; ///< \ref MiiLaAppletMode
|
u32 mode; ///< \ref MiiLaAppletMode
|
||||||
s32 special_key_code; ///< \ref MiiSpecialKeyCode
|
s32 special_key_code; ///< \ref MiiSpecialKeyCode
|
||||||
Uuid valid_uuid_array[8]; ///< ValidUuidArray. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_AppendMiiImage / ::NfpLaMiiLaAppletMode_UpdateMiiImage.
|
union {
|
||||||
|
Uuid valid_uuid_array[8]; ///< ValidUuidArray. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_AppendMiiImage / ::NfpLaMiiLaAppletMode_UpdateMiiImage.
|
||||||
|
struct {
|
||||||
|
MiiCharInfo char_info; ///< \ref MiiCharInfo
|
||||||
|
u8 unused_x64[0x28]; ///< Unused
|
||||||
|
} char_info;
|
||||||
|
};
|
||||||
Uuid used_uuid; ///< UsedUuid. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_UpdateMiiImage.
|
Uuid used_uuid; ///< UsedUuid. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_UpdateMiiImage.
|
||||||
u8 unk_x9C[0x64]; ///< Unused
|
u8 unk_x9C[0x64]; ///< Unused
|
||||||
} MiiLaAppletInput;
|
} MiiLaAppletInput;
|
||||||
@ -33,6 +41,13 @@ typedef struct {
|
|||||||
u8 unk_x8[0x18]; ///< Unused
|
u8 unk_x8[0x18]; ///< Unused
|
||||||
} MiiLaAppletOutput;
|
} MiiLaAppletOutput;
|
||||||
|
|
||||||
|
/// AppletOutputForCharInfoEditing
|
||||||
|
typedef struct {
|
||||||
|
u32 res; ///< MiiLaAppletOutput::res
|
||||||
|
MiiCharInfo char_info; ///< \ref MiiCharInfo
|
||||||
|
u8 unused[0x24]; ///< Unused
|
||||||
|
} MiiLaAppletOutputForCharInfoEditing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Launches the applet for ShowMiiEdit.
|
* @brief Launches the applet for ShowMiiEdit.
|
||||||
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
||||||
@ -50,7 +65,7 @@ Result miiLaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index);
|
|||||||
* @brief Launches the applet for AppendMiiImage.
|
* @brief Launches the applet for AppendMiiImage.
|
||||||
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
||||||
* @param[in] valid_uuid_array Input array of Uuid.
|
* @param[in] valid_uuid_array Input array of Uuid.
|
||||||
* @oaram[in] count Total entries for the valid_uuid_array. Must be 0-8.
|
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
|
||||||
* @param[out] index Output Index.
|
* @param[out] index Output Index.
|
||||||
*/
|
*/
|
||||||
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index);
|
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index);
|
||||||
@ -59,9 +74,28 @@ Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid
|
|||||||
* @brief Launches the applet for UpdateMiiImage.
|
* @brief Launches the applet for UpdateMiiImage.
|
||||||
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
||||||
* @param[in] valid_uuid_array Input array of Uuid.
|
* @param[in] valid_uuid_array Input array of Uuid.
|
||||||
* @oaram[in] count Total entries for the valid_uuid_array. Must be 0-8.
|
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
|
||||||
* @param[in] used_uuid UsedUuid
|
* @param[in] used_uuid UsedUuid
|
||||||
* @param[out] index Output Index.
|
* @param[out] index Output Index.
|
||||||
*/
|
*/
|
||||||
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index);
|
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Launches the applet for CreateMii.
|
||||||
|
* @note This creates a Mii and returns it, without saving it in the database.
|
||||||
|
* @note Only available on [10.2.0+].
|
||||||
|
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
||||||
|
* @param[out] out_char \ref MiiCharInfo
|
||||||
|
*/
|
||||||
|
Result miiLaCreateMii(MiiSpecialKeyCode special_key_code, MiiCharInfo *out_char);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Launches the applet for EditMii.
|
||||||
|
* @note This edits the specified Mii and returns it, without saving it in the database.
|
||||||
|
* @note Only available on [10.2.0+].
|
||||||
|
* @param[in] special_key_code \ref MiiSpecialKeyCode
|
||||||
|
* @param[in] in_char \ref MiiCharInfo
|
||||||
|
* @param[out] out_char \ref MiiCharInfo
|
||||||
|
*/
|
||||||
|
Result miiLaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char);
|
||||||
|
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libapplet_internal.h"
|
#include "libapplet_internal.h"
|
||||||
#include "applets/mii_la.h"
|
#include "applets/mii_la.h"
|
||||||
|
#include "runtime/hosversion.h"
|
||||||
|
|
||||||
static Result _miiLaShow(const MiiLaAppletInput *in, MiiLaAppletOutput *out) {
|
static s32 _miiLaGetVersion(void) {
|
||||||
|
s32 version = 0x3;
|
||||||
|
|
||||||
|
if (hosversionAtLeast(10,2,0)) version = 0x4;
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _miiLaShow(const MiiLaAppletInput *in, void* out, size_t out_size) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
AppletHolder holder;
|
AppletHolder holder;
|
||||||
AppletStorage storage;
|
AppletStorage storage;
|
||||||
@ -25,7 +34,7 @@ static Result _miiLaShow(const MiiLaAppletInput *in, MiiLaAppletOutput *out) {
|
|||||||
if (R_SUCCEEDED(rc)) rc = appletHolderPopOutData(&holder, &storage);
|
if (R_SUCCEEDED(rc)) rc = appletHolderPopOutData(&holder, &storage);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
rc = appletStorageRead(&storage, 0, out, sizeof(*out));
|
rc = appletStorageRead(&storage, 0, out, out_size);
|
||||||
appletStorageClose(&storage);
|
appletStorageClose(&storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,12 +50,12 @@ static void _miiLaInitializeValidUuidArray(MiiLaAppletInput *in, const Uuid *in_
|
|||||||
for (s32 i=0; i<count; i++) in->valid_uuid_array[i] = in_array[i];
|
for (s32 i=0; i<count; i++) in->valid_uuid_array[i] = in_array[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _miiLaGetResult(MiiLaAppletOutput *out) {
|
static Result _miiLaGetResult(u32 res) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
if (out->res == 0)
|
if (res == 0)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
else if (out->res == 1)
|
else if (res == 1)
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit);
|
rc = MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit);
|
||||||
else
|
else
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen);
|
rc = MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen);
|
||||||
@ -56,12 +65,12 @@ static Result _miiLaGetResult(MiiLaAppletOutput *out) {
|
|||||||
|
|
||||||
Result miiLaShowMiiEdit(MiiSpecialKeyCode special_key_code) {
|
Result miiLaShowMiiEdit(MiiSpecialKeyCode special_key_code) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
MiiLaAppletInput in = {.unk_x0 = 0x3, .mode = NfpLaMiiLaAppletMode_ShowMiiEdit, .special_key_code = special_key_code};
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_ShowMiiEdit, .special_key_code = special_key_code};
|
||||||
MiiLaAppletOutput out={0};
|
MiiLaAppletOutput out={0};
|
||||||
|
|
||||||
rc = _miiLaShow(&in, &out);
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
rc = _miiLaGetResult(&out);
|
rc = _miiLaGetResult(out.res);
|
||||||
rc = R_VALUE(rc) == MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit) ? 0 : rc;
|
rc = R_VALUE(rc) == MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit) ? 0 : rc;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@ -69,37 +78,69 @@ Result miiLaShowMiiEdit(MiiSpecialKeyCode special_key_code) {
|
|||||||
|
|
||||||
Result miiLaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index) {
|
Result miiLaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
MiiLaAppletInput in = {.unk_x0 = 0x3, .mode = NfpLaMiiLaAppletMode_AppendMii, .special_key_code = special_key_code};
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_AppendMii, .special_key_code = special_key_code};
|
||||||
MiiLaAppletOutput out={0};
|
MiiLaAppletOutput out={0};
|
||||||
|
|
||||||
rc = _miiLaShow(&in, &out);
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(&out);
|
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(out.res);
|
||||||
if (R_SUCCEEDED(rc)) *index = out.index;
|
if (R_SUCCEEDED(rc)) *index = out.index;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index) {
|
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
MiiLaAppletInput in = {.unk_x0 = 0x3, .mode = NfpLaMiiLaAppletMode_AppendMiiImage, .special_key_code = special_key_code};
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_AppendMiiImage, .special_key_code = special_key_code};
|
||||||
MiiLaAppletOutput out={0};
|
MiiLaAppletOutput out={0};
|
||||||
|
|
||||||
_miiLaInitializeValidUuidArray(&in, valid_uuid_array, count);
|
_miiLaInitializeValidUuidArray(&in, valid_uuid_array, count);
|
||||||
rc = _miiLaShow(&in, &out);
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(&out);
|
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(out.res);
|
||||||
if (R_SUCCEEDED(rc)) *index = out.index;
|
if (R_SUCCEEDED(rc)) *index = out.index;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index) {
|
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
MiiLaAppletInput in = {.unk_x0 = 0x3, .mode = NfpLaMiiLaAppletMode_UpdateMiiImage, .special_key_code = special_key_code};
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_UpdateMiiImage, .special_key_code = special_key_code};
|
||||||
MiiLaAppletOutput out={0};
|
MiiLaAppletOutput out={0};
|
||||||
|
|
||||||
_miiLaInitializeValidUuidArray(&in, valid_uuid_array, count);
|
_miiLaInitializeValidUuidArray(&in, valid_uuid_array, count);
|
||||||
in.used_uuid = used_uuid;
|
in.used_uuid = used_uuid;
|
||||||
rc = _miiLaShow(&in, &out);
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(&out);
|
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(out.res);
|
||||||
if (R_SUCCEEDED(rc)) *index = out.index;
|
if (R_SUCCEEDED(rc)) *index = out.index;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result miiLaCreateMii(MiiSpecialKeyCode special_key_code, MiiCharInfo *out_char) {
|
||||||
|
Result rc=0;
|
||||||
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_CreateMii, .special_key_code = special_key_code};
|
||||||
|
MiiLaAppletOutputForCharInfoEditing out={0};
|
||||||
|
|
||||||
|
if (hosversionBefore(10,2,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
|
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(out.res);
|
||||||
|
if (R_SUCCEEDED(rc)) *out_char = out.char_info;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result miiLaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char) {
|
||||||
|
Result rc=0;
|
||||||
|
MiiLaAppletInput in = {.version = _miiLaGetVersion(), .mode = MiiLaAppletMode_EditMii, .special_key_code = special_key_code};
|
||||||
|
MiiLaAppletOutputForCharInfoEditing out={0};
|
||||||
|
|
||||||
|
if (hosversionBefore(10,2,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
// sdknso does various validation with in_char, we won't do so.
|
||||||
|
|
||||||
|
in.char_info.char_info = *in_char;
|
||||||
|
|
||||||
|
rc = _miiLaShow(&in, &out, sizeof(out));
|
||||||
|
if (R_SUCCEEDED(rc)) rc = _miiLaGetResult(out.res);
|
||||||
|
if (R_SUCCEEDED(rc)) *out_char = out.char_info;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user