diff --git a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs index 3b06ba8afc..39c7c11267 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs @@ -15,11 +15,50 @@ namespace Ryujinx.HLE.HOS.Services.Friend { m_Commands = new Dictionary() { + { 10101, GetFriendList }, { 10601, DeclareCloseOnlinePlaySession }, { 10610, UpdateUserPresence } }; } + // nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array + public long GetFriendList(ServiceCtx Context) + { + UserId Uuid = new UserId( + Context.RequestData.ReadInt64(), + Context.RequestData.ReadInt64()); + + int Unknown0 = Context.RequestData.ReadInt32(); + + FriendFilter Filter = new FriendFilter() + { + PresenceStatus = (PresenceStatusFilter)Context.RequestData.ReadInt32(), + IsFavoriteOnly = Context.RequestData.ReadBoolean(), + IsSameAppPresenceOnly = Context.RequestData.ReadBoolean(), + IsSameAppPlayedOnly = Context.RequestData.ReadBoolean(), + IsArbitraryAppPlayedOnly = Context.RequestData.ReadBoolean(), + PresenceGroupId = Context.RequestData.ReadInt64() + }; + + long Unknown1 = Context.RequestData.ReadInt64(); + + // There is any friend online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty. + Context.ResponseData.Write(0); + + Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. UserId: {Uuid.UserIdHex} - " + + $"Unknown0: {Unknown0} - " + + $"PresenceStatus: {Filter.PresenceStatus} - " + + $"IsFavoriteOnly: {Filter.IsFavoriteOnly} - " + + $"IsSameAppPresenceOnly: {Filter.IsSameAppPresenceOnly} - " + + $"IsSameAppPlayedOnly: {Filter.IsSameAppPlayedOnly} - " + + $"IsArbitraryAppPlayedOnly: {Filter.IsArbitraryAppPlayedOnly} - " + + $"PresenceGroupId: {Filter.PresenceGroupId} - " + + $"Unknown1: {Unknown1}"); + + return 0; + } + + // DeclareCloseOnlinePlaySession(nn::account::Uid) public long DeclareCloseOnlinePlaySession(ServiceCtx Context) { UserId Uuid = new UserId( @@ -31,17 +70,28 @@ namespace Ryujinx.HLE.HOS.Services.Friend Profile.OnlinePlayState = OpenCloseState.Closed; } + Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.UserIdHex} - " + + $"OnlinePlayState: {Profile.OnlinePlayState}"); + return 0; } + // UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer public long UpdateUserPresence(ServiceCtx Context) { UserId Uuid = new UserId( Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64()); - //TODO. - Context.Device.Log.PrintStub(LogClass.ServiceFriend, "Stubbed."); + long Unknown0 = Context.RequestData.ReadInt64(); + + long Position = Context.Request.PtrBuff[0].Position; + long Size = Context.Request.PtrBuff[0].Size; + + //Todo: Write the nn::friends::detail::UserPresenceImpl inside the buffer. + + Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.UserIdHex} - " + + $"Unknown0: {Unknown0}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs b/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs new file mode 100644 index 0000000000..7a23ca4b2f --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs @@ -0,0 +1,20 @@ +namespace Ryujinx.HLE.HOS.Services.Friend +{ + public enum PresenceStatusFilter + { + None, + Online, + OnlinePlay, + OnlineOrOnlinePlay + } + + public struct FriendFilter + { + public PresenceStatusFilter PresenceStatus; + public bool IsFavoriteOnly; + public bool IsSameAppPresenceOnly; + public bool IsSameAppPlayedOnly; + public bool IsArbitraryAppPlayedOnly; + public long PresenceGroupId; + }; +}