Fix a few frd commands

This commit is contained in:
Joel16 2018-08-10 14:10:58 -05:00
parent 3810a5586b
commit 48f0a720a4
2 changed files with 87 additions and 92 deletions

View File

@ -5,9 +5,9 @@
#pragma once
#include <3ds.h>
#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)
#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 (Number of Friends)
#pragma pack(push, 1)
@ -26,7 +26,6 @@ typedef struct
u32 version;
u32 unk;
} TitleData;
/// Structure containing basic Mii information.
typedef struct
{
@ -51,11 +50,11 @@ typedef struct
/// Friend profile data
typedef struct
{
u8 region; // The region code for the hardware.
u8 country; // Country code.
u8 area; // Area code.
u8 language; // Language code.
u8 platform; // Platform code.
u8 region; ///< The region code for the hardware.
u8 country; ///< Country code.
u8 area; ///< Area code.
u8 language; ///< Language code.
u8 platform; ///< Platform code.
u32 padding;
} FriendProfile;
@ -80,15 +79,15 @@ typedef struct
/// Enum to use with FRD_GetNotificationEvent
typedef enum
{
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
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.
@ -145,7 +144,7 @@ Result FRD_GetMyProfile(FriendProfile *profile);
* @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, u32 max_size);
Result FRD_GetMyScreenName(char *name, size_t max_size);
/**
* @brief Gets the current user's Mii data.
@ -170,59 +169,55 @@ 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, u32 max_size);
Result FRD_GetMyComment(char *comment, size_t max_size);
/**
* @brief Gets the current user's friend key list
* @brief Gets the current user's firend 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 count Number of entries to read (max is FRIEND_LIST_SIZE).
* @param offset the index of the friend key to start with.
* @param size Size of the friend key list. (FRIEND_LIST_SIZE)
*/
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 count);
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, size_t *num, size_t offset, size_t size);
/**
* @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.
* @brief Gets Friends Mii data.
* @param miiDataList Pointer to write Mii data to.
* @param friendKeyList Pointer to FriendKeys.
* @param size Number of Friendkeys.
*/
Result FRD_GetFriendMii(MiiData *miis, const FriendKey *keys, u32 offset, u32 count);
Result FRD_GetFriendMii(MiiData *miiDataList, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get current user's friends' profile data.
* @brief Get a friend's profile data.
* @param profile Pointer to write profile data to.
* @param keys Pointer to the friend key list.
* @param offset Starting offset.
* @param count Profile count.
* @param friendKeyList Pointer to FriendKeys.
* @param size Number of FriendKeys.
*/
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *keys, u32 offset, u32 count);
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get current user's friends' playing game.
* @brief Get a friend's playing Game.
* @param desc Pointer to write Game Description data to.
* @param keys Pointer to the friend key list.
* @param offset Starting offset.
* @param count Entry count.
* @param friendKeyList Pointer to FriendKeys,
* @param size Number Of FriendKeys.
*/
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count);
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get current user's friends' favourite game.
* @brief Get a friend's favourite Game.
* @param desc Pointer to write Game Description data to.
* @param keys Pointer to the friend key list.
* @param offset Starting offset.
* @param count Entry count.
* @param friendKeyList Pointer to FriendKeys,
* @param size Number Of FriendKeys.
*/
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count);
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size);
/**
* @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.
* @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.
*/
Result FRD_IsIncludedInFriendList(u64 friendCode, bool *isFromList);
Result FRD_IsFromFriendList(FriendKey *friendKeyList, bool *isFromList);
/**
* @brief Updates the game mode description string.
@ -242,7 +237,7 @@ Result FRD_AttachToEventNotification(Handle event);
* @param size Number of events
* @param recievedNotifCount Number of notification reccieved.
*/
Result FRD_GetEventNotification(NotificationEvent *event, u32 size, u32 *recievedNotifCount);
Result FRD_GetEventNotification(NotificationEvent *event, size_t size, u32 *recievedNotifCount);
/**
* @brief Returns the friend code using the given principal ID.

View File

@ -142,9 +142,9 @@ Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isSho
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
*isPublicMode = cmdbuf[2] & 0x1; // Public mode
*isShowGameName = cmdbuf[3] & 0x1; // Show current game
*isShowPlayedGame = cmdbuf[4] & 0x1; // Show game history.
*isPublicMode = cmdbuf[2] & 0xFF; // Public mode
*isShowGameName = cmdbuf[3] & 0xFF; // Show current game
*isShowPlayedGame = cmdbuf[4] & 0xFF; // Show game history.
return (Result)cmdbuf[1];
}
@ -163,7 +163,7 @@ Result FRD_GetMyProfile(FriendProfile *profile)
return (Result)cmdbuf[1];
}
Result FRD_GetMyScreenName(char *name, u32 max_size)
Result FRD_GetMyScreenName(char *name, size_t max_size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
@ -219,7 +219,7 @@ Result FRD_GetMyFavoriteGame(u64 *titleId)
return (Result)cmdbuf[1];
}
Result FRD_GetMyComment(char *comment, u32 max_size)
Result FRD_GetMyComment(char *comment, size_t max_size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
@ -233,15 +233,15 @@ Result FRD_GetMyComment(char *comment, u32 max_size)
return (Result)cmdbuf[1];
}
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 count)
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, size_t *num, size_t offset, size_t size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x11,2,0); // 0x110080
cmdbuf[1] = offset;
cmdbuf[2] = count;
cmdbuf[64] = (count << 18) | 2;
cmdbuf[2] = size;
cmdbuf[64] = (size << 18) | 2;
cmdbuf[65] = (u32)friendKeyList;
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
@ -251,35 +251,35 @@ Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32
return (Result)cmdbuf[1];
}
Result FRD_GetFriendMii(MiiData *miis, const FriendKey *keys, u32 offset, u32 count)
Result FRD_GetFriendMii(MiiData *miiDataList, const FriendKey *friendKeyList, size_t size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x14,1,4); // 0x140044
cmdbuf[1] = offset;
cmdbuf[2] = (count << 18) | 2;
cmdbuf[3] = (u32)keys;
cmdbuf[4] = IPC_Desc_Buffer(count * sizeof(MiiData), IPC_BUFFER_W);
cmdbuf[5] = (u32)miis;
cmdbuf[1] = size;
cmdbuf[2] = (size << 18) | 2;
cmdbuf[3] = (u32)friendKeyList;
cmdbuf[4] = IPC_Desc_Buffer(size * sizeof(MiiData), IPC_BUFFER_W);
cmdbuf[5] = (u32)miiDataList;
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
return (Result)cmdbuf[1];
}
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *keys, u32 offset, u32 count)
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *friendKeyList, size_t size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x15,1,2); // 0x150042
cmdbuf[1] = offset;
cmdbuf[2] = (count << 18) | 2;
cmdbuf[3] = (u32)keys;
cmdbuf[1] = size;
cmdbuf[2] = (size << 18) | 2;
cmdbuf[3] = (u32)friendKeyList;
u32 *staticbuf = getThreadStaticBuffers();
staticbuf[0] = (count << 17) | 2;
staticbuf[0] = (size << 17)|2;
staticbuf[1] = (u32)profile;
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
@ -287,16 +287,16 @@ Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *keys, u32 o
return (Result)cmdbuf[1];
}
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count)
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x18,1,4); // 0x180044
cmdbuf[1] = offset;
cmdbuf[2] = (count << 18) | 2;
cmdbuf[3] = (u32)keys;
cmdbuf[4] = IPC_Desc_Buffer(count * sizeof(GameDescription), IPC_BUFFER_W);
cmdbuf[1] = size;
cmdbuf[2] = (size << 18) | 2;
cmdbuf[3] = (u32)friendKeyList;
cmdbuf[4] = IPC_Desc_Buffer(size * 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, u3
return (Result)cmdbuf[1];
}
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *keys, u32 offset, u32 count)
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x19,1,2); // 0x190042
cmdbuf[1] = offset;
cmdbuf[2] = (count << 18) | 2;
cmdbuf[3] = (u32)keys;
cmdbuf[1] = size;
cmdbuf[2] = (size << 18) | 2;
cmdbuf[3] = (u32)friendKeyList;
u32 *staticbuf = getThreadStaticBuffers();
staticbuf[0] = (count << 18) | 2;
staticbuf[0] = (size << 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_IsIncludedInFriendList(u64 friendCode, bool *isFromList)
Result FRD_IsFromFriendList(FriendKey *friendKeyList, bool *isFromList)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x1B,2,0); // 0x1B0080
cmdbuf[1] = (u32)(friendCode & 0xFFFFFFFF);
cmdbuf[2] = (u32)(friendCode >> 32);
cmdbuf[1] = (u32)(friendKeyList->localFriendCode & 0xFFFFFFFF);
cmdbuf[2] = (u32)(friendKeyList->localFriendCode >> 32);
if (R_FAILED(ret = svcSendSyncRequest(frdHandle))) return ret;
*isFromList = cmdbuf[2] & 0x1;
*isFromList = cmdbuf[2] & 0xFF;
return (Result)cmdbuf[1];
}
@ -372,13 +372,13 @@ Result FRD_AttachToEventNotification(Handle event)
return (Result)cmdbuf[1];
}
Result FRD_GetEventNotification(NotificationEvent *event, u32 size, u32 *recievedNotifCount)
Result FRD_GetEventNotification(NotificationEvent *event, size_t size, u32 *recievedNotifCount)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x22,1,0); //0x220040
cmdbuf[1] = size;
cmdbuf[1] = (u32)size;
u32 *staticbuf = getThreadStaticBuffers();
staticbuf[0] = 0x60000 * size | 2;