FRD update (#409)
Fix Mii struct padding + some changes for consistency Documentation update
This commit is contained in:
parent
c579e745a8
commit
3810a5586b
@ -5,10 +5,11 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
|
||||
#define FRIENDS_SCREEN_NAME_SIZE 0x16 // 11 (0x16 because UTF-16)
|
||||
#define FRIENDS_COMMENT_SIZE 0x22 // 16 (0x21 because UTF-16 + null character)
|
||||
#define FRIEND_LIST_SIZE 0x64 // 100 (Number of Friends)
|
||||
#define FRIEND_MII_STORE_DATA_SIZE 0x60 // 96 (Mii data)
|
||||
#define FRIEND_SCREEN_NAME_SIZE 0x16 // 11 (0x16 because UTF-16)
|
||||
#define FRIEND_COMMENT_SIZE 0x22 // 16 (0x21 because UTF-16 + null character)
|
||||
#define FRIEND_LIST_SIZE 0x64 // 100 (Max. number of friends)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/// Friend key data
|
||||
typedef struct
|
||||
@ -25,6 +26,7 @@ typedef struct
|
||||
u32 version;
|
||||
u32 unk;
|
||||
} TitleData;
|
||||
|
||||
/// Structure containing basic Mii information.
|
||||
typedef struct
|
||||
{
|
||||
@ -55,7 +57,7 @@ typedef struct
|
||||
u8 language; // Language code.
|
||||
u8 platform; // Platform code.
|
||||
u32 padding;
|
||||
} Profile;
|
||||
} FriendProfile;
|
||||
|
||||
/// Game Description structure
|
||||
typedef struct
|
||||
@ -71,21 +73,23 @@ typedef struct
|
||||
u8 padding3[3];
|
||||
u32 padding;
|
||||
FriendKey key;
|
||||
}NotificationEvent;
|
||||
} NotificationEvent;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/// Enum to use with FRD_GetNotificationEvent
|
||||
typedef enum
|
||||
{
|
||||
selfOnline = 1, // Self went online
|
||||
selfOffline, // Self went offline
|
||||
friendOnline, // Friend Went Online
|
||||
friendPresence, // Friend Presence changed
|
||||
friendMii, // Friend Mii changed
|
||||
friendProfile, // Friend Profile changed
|
||||
friendOffline, // Friend went offline
|
||||
friendBecameFriend, // Friend registered self as friend
|
||||
friendInvitaton // Friend Sent invitation
|
||||
}NotificationTypes;
|
||||
USER_WENT_ONLINE = 1, // Self went online
|
||||
USER_WENT_OFFLINE, // Self went offline
|
||||
FRIEND_WENT_ONLINE, // Friend Went Online
|
||||
FRIEND_UPDATED_PRESENCE, // Friend Presence changed
|
||||
FRIEND_UPDATED_MII, // Friend Mii changed
|
||||
FRIEND_UPDATED_PROFILE, // Friend Profile changed
|
||||
FRIEND_WENT_OFFLINE, // Friend went offline
|
||||
FRIEND_REGISTERED_USER, // Friend registered self as friend
|
||||
FRIEND_SENT_INVITATION // Friend Sent invitation
|
||||
} NotificationTypes;
|
||||
|
||||
/// Initializes FRD service.
|
||||
Result frdInit(void);
|
||||
@ -134,14 +138,14 @@ Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isSho
|
||||
* @brief Gets the current user's profile information.
|
||||
* @param profile Pointer to write the current user's profile information to.
|
||||
*/
|
||||
Result FRD_GetMyProfile(Profile *profile);
|
||||
Result FRD_GetMyProfile(FriendProfile *profile);
|
||||
|
||||
/**
|
||||
* @brief Gets the current user's screen name.
|
||||
* @param name Pointer to write the current user's screen name to.
|
||||
* @param max_size Max size of the screen name.
|
||||
*/
|
||||
Result FRD_GetMyScreenName(char *name, size_t max_size);
|
||||
Result FRD_GetMyScreenName(char *name, u32 max_size);
|
||||
|
||||
/**
|
||||
* @brief Gets the current user's Mii data.
|
||||
@ -166,55 +170,59 @@ Result FRD_GetMyFavoriteGame(u64 *titleId);
|
||||
* @param comment Pointer to write the current user's comment to.
|
||||
* @param max_size Max size of the comment.
|
||||
*/
|
||||
Result FRD_GetMyComment(char *comment, size_t max_size);
|
||||
Result FRD_GetMyComment(char *comment, u32 max_size);
|
||||
|
||||
/**
|
||||
* @brief Gets the current user's firend key list
|
||||
* @brief Gets the current user's friend key list
|
||||
* @param friendKeyList Pointer to write the friend key list to.
|
||||
* @param num Stores the number of friend keys obtained.
|
||||
* @param offset the index of the friend key to start with.
|
||||
* @param size Size of the friend key list. (FRIEND_LIST_SIZE)
|
||||
* @param offset The index of the friend key to start with.
|
||||
* @param count Number of entries to read (max is FRIEND_LIST_SIZE).
|
||||
*/
|
||||
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, size_t *num, size_t offset, size_t size);
|
||||
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 count);
|
||||
|
||||
/**
|
||||
* @brief Gets Friends Mii data.
|
||||
* @param mii Pointer to write Mii data to.
|
||||
* @param keys Pointer to FriendKeys.
|
||||
* @param numberOfKeys Number of Friendkeys.
|
||||
* @brief Gets current user's friends' Mii data
|
||||
* @param miis Pointer to output the Miis to.
|
||||
* @param keys Pointer to the friend key list.
|
||||
* @param offset Starting offset.
|
||||
* @param count Mii count.
|
||||
*/
|
||||
Result FRD_GetFriendMii(MiiData *mii, const FriendKey *keys, size_t numberOfKeys);
|
||||
Result FRD_GetFriendMii(MiiData *miis, const FriendKey *keys, u32 offset, u32 count);
|
||||
|
||||
/**
|
||||
* @brief Get a friend's profile data.
|
||||
* @brief Get current user's friends' profile data.
|
||||
* @param profile Pointer to write profile data to.
|
||||
* @param keys Pointer to FriendKeys.
|
||||
* @param numberOfKeys Number of FriendKeys.
|
||||
* @param keys Pointer to the friend key list.
|
||||
* @param offset Starting offset.
|
||||
* @param count Profile count.
|
||||
*/
|
||||
Result FRD_GetFriendProfile(Profile *profile, const FriendKey *keys, size_t numberOfKeys);
|
||||
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *keys, u32 offset, u32 count);
|
||||
|
||||
/**
|
||||
* @brief Get a friend's playing Game.
|
||||
* @brief Get current user's friends' playing game.
|
||||
* @param desc Pointer to write Game Description data to.
|
||||
* @param keys Pointer to FriendKeys,
|
||||
* @param numberOfKeys Number Of FriendKeys.
|
||||
* @param keys Pointer to the friend key list.
|
||||
* @param offset Starting offset.
|
||||
* @param count Entry count.
|
||||
*/
|
||||
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, size_t numberOfKeys);
|
||||
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count);
|
||||
|
||||
/**
|
||||
* @brief Get a friend's favourite Game.
|
||||
* @brief Get current user's friends' favourite game.
|
||||
* @param desc Pointer to write Game Description data to.
|
||||
* @param keys Pointer to FriendKeys,
|
||||
* @param numberOfKeys Number Of FriendKeys.
|
||||
* @param keys Pointer to the friend key list.
|
||||
* @param offset Starting offset.
|
||||
* @param count Entry count.
|
||||
*/
|
||||
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, size_t numberOfKeys);
|
||||
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count);
|
||||
|
||||
/**
|
||||
* @brief Determines if the application was started using the join game option in the friends applet.
|
||||
* @param friendKeyList Pointer to a list of friend keys.
|
||||
* @param isFromList Pointer to a write the friendship status to.
|
||||
* @brief Gets whether a friend code is included on the user's friend list.
|
||||
* @param friendCode Friend code to check.
|
||||
* @param isFromList Pointer to output the result to.
|
||||
*/
|
||||
Result FRD_IsFromFriendList(FriendKey *friendKeyList, bool *isFromList);
|
||||
Result FRD_IsIncludedInFriendList(u64 friendCode, bool *isFromList);
|
||||
|
||||
/**
|
||||
* @brief Updates the game mode description string.
|
||||
@ -234,7 +242,7 @@ Result FRD_AttachToEventNotification(Handle event);
|
||||
* @param size Number of events
|
||||
* @param recievedNotifCount Number of notification reccieved.
|
||||
*/
|
||||
Result FRD_GetEventNotification(NotificationEvent *event, size_t size, u32 *recievedNotifCount);
|
||||
Result FRD_GetEventNotification(NotificationEvent *event, u32 size, u32 *recievedNotifCount);
|
||||
|
||||
/**
|
||||
* @brief Returns the friend code using the given principal ID.
|
||||
|
@ -142,14 +142,14 @@ Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isSho
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
*isPublicMode = cmdbuf[2] & 0xFF; // Public mode
|
||||
*isShowGameName = cmdbuf[3] & 0xFF; // Show current game
|
||||
*isShowPlayedGame = cmdbuf[4] & 0xFF; // Show game history.
|
||||
*isPublicMode = cmdbuf[2] & 0x1; // Public mode
|
||||
*isShowGameName = cmdbuf[3] & 0x1; // Show current game
|
||||
*isShowPlayedGame = cmdbuf[4] & 0x1; // Show game history.
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetMyProfile(Profile *profile)
|
||||
Result FRD_GetMyProfile(FriendProfile *profile)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
@ -158,12 +158,12 @@ Result FRD_GetMyProfile(Profile *profile)
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
memcpy(profile, &cmdbuf[2], sizeof(Profile));
|
||||
memcpy(profile, &cmdbuf[2], sizeof(FriendProfile));
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetMyScreenName(char *name, size_t max_size)
|
||||
Result FRD_GetMyScreenName(char *name, u32 max_size)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
@ -186,7 +186,7 @@ Result FRD_GetMyMii(MiiData *mii)
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
memcpy(mii, &cmdbuf[2], FRIEND_MII_STORE_DATA_SIZE);
|
||||
memcpy(mii, &cmdbuf[2], sizeof(MiiData));
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -219,7 +219,7 @@ Result FRD_GetMyFavoriteGame(u64 *titleId)
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetMyComment(char *comment, size_t max_size)
|
||||
Result FRD_GetMyComment(char *comment, u32 max_size)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
@ -233,15 +233,15 @@ Result FRD_GetMyComment(char *comment, size_t max_size)
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, size_t *num, size_t offset, size_t size)
|
||||
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x11,2,0); // 0x110080
|
||||
cmdbuf[1] = 0;
|
||||
cmdbuf[2] = size;
|
||||
cmdbuf[64] = (size << 18) | 2;
|
||||
cmdbuf[1] = offset;
|
||||
cmdbuf[2] = count;
|
||||
cmdbuf[64] = (count << 18) | 2;
|
||||
cmdbuf[65] = (u32)friendKeyList;
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
@ -251,35 +251,35 @@ Result FRD_GetFriendKeyList(FriendKey *friendKeyList, size_t *num, size_t offset
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetFriendMii(MiiData *mii, const FriendKey *keys, size_t numberOfKeys)
|
||||
Result FRD_GetFriendMii(MiiData *miis, const FriendKey *keys, u32 offset, u32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x14,1,4); //0x140044
|
||||
cmdbuf[1] = numberOfKeys;
|
||||
cmdbuf[2] = (numberOfKeys << 18)|2;
|
||||
cmdbuf[0] = IPC_MakeHeader(0x14,1,4); // 0x140044
|
||||
cmdbuf[1] = offset;
|
||||
cmdbuf[2] = (count << 18) | 2;
|
||||
cmdbuf[3] = (u32)keys;
|
||||
cmdbuf[4] = 0x600 * numberOfKeys | 0xC;
|
||||
cmdbuf[5] = (u32)mii;
|
||||
cmdbuf[4] = IPC_Desc_Buffer(count * sizeof(MiiData), IPC_BUFFER_W);
|
||||
cmdbuf[5] = (u32)miis;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetFriendProfile(Profile *profile, const FriendKey *keys, size_t numberOfKeys)
|
||||
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *keys, u32 offset, u32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x15,1,2); // 0x150042
|
||||
cmdbuf[1] = numberOfKeys;
|
||||
cmdbuf[2] = (numberOfKeys << 18)|2;
|
||||
cmdbuf[1] = offset;
|
||||
cmdbuf[2] = (count << 18) | 2;
|
||||
cmdbuf[3] = (u32)keys;
|
||||
|
||||
u32 *staticbuf = getThreadStaticBuffers();
|
||||
staticbuf[0] = (numberOfKeys << 17)|2;
|
||||
staticbuf[0] = (count << 17) | 2;
|
||||
staticbuf[1] = (u32)profile;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
@ -287,16 +287,16 @@ Result FRD_GetFriendProfile(Profile *profile, const FriendKey *keys, size_t numb
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, size_t numberOfKeys)
|
||||
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x18,1,4); // 0x180044
|
||||
cmdbuf[1] = numberOfKeys;
|
||||
cmdbuf[2] = (numberOfKeys << 18) | 2;
|
||||
cmdbuf[1] = offset;
|
||||
cmdbuf[2] = (count << 18) | 2;
|
||||
cmdbuf[3] = (u32)keys;
|
||||
cmdbuf[4] = 0x1100 * numberOfKeys | 0xC;
|
||||
cmdbuf[4] = IPC_Desc_Buffer(count * sizeof(GameDescription), IPC_BUFFER_W);
|
||||
cmdbuf[5] = (u32)desc;
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
@ -304,19 +304,19 @@ Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, si
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, size_t numberOfKeys)
|
||||
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x19,1,2); // 0x190042
|
||||
cmdbuf[1] = numberOfKeys;
|
||||
cmdbuf[2] = (numberOfKeys << 18) | 2;
|
||||
cmdbuf[1] = offset;
|
||||
cmdbuf[2] = (count << 18) | 2;
|
||||
cmdbuf[3] = (u32)keys;
|
||||
|
||||
u32 *staticbuf = getThreadStaticBuffers();
|
||||
|
||||
staticbuf[0] = (numberOfKeys << 18) | 2;
|
||||
staticbuf[0] = (count << 18) | 2;
|
||||
staticbuf[1] = (u32)desc;
|
||||
|
||||
if(R_FAILED(svcSendSyncRequest(frdHandle))) return ret;
|
||||
@ -324,18 +324,18 @@ Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys,
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_IsFromFriendList(FriendKey *friendKeyList, bool *isFromList)
|
||||
Result FRD_IsIncludedInFriendList(u64 friendCode, bool *isFromList)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x1B,2,0); // 0x1B0080
|
||||
cmdbuf[1] = (u32)(friendKeyList->localFriendCode & 0xFFFFFFFF);
|
||||
cmdbuf[2] = (u32)(friendKeyList->localFriendCode >> 32);
|
||||
cmdbuf[1] = (u32)(friendCode & 0xFFFFFFFF);
|
||||
cmdbuf[2] = (u32)(friendCode >> 32);
|
||||
|
||||
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
*isFromList = cmdbuf[2] & 0xFF;
|
||||
*isFromList = cmdbuf[2] & 0x1;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -372,20 +372,19 @@ Result FRD_AttachToEventNotification(Handle event)
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result FRD_GetEventNotification(NotificationEvent *event, size_t size, u32 *recievedNotifCount)
|
||||
Result FRD_GetEventNotification(NotificationEvent *event, u32 size, u32 *recievedNotifCount)
|
||||
{
|
||||
Result ret = 0;
|
||||
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = IPC_MakeHeader(0x22,1,0); //0x220040
|
||||
cmdbuf[1] = (u32)size;
|
||||
cmdbuf[1] = size;
|
||||
|
||||
u32 *staticbuf = getThreadStaticBuffers();
|
||||
staticbuf[0] = 0x60000 * size | 2;
|
||||
staticbuf[1] = (u32)event;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle)))
|
||||
return ret;
|
||||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
|
||||
|
||||
*recievedNotifCount = cmdbuf[3];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user