Archived
1
0
Fork 0
forked from Mirror/Ryujinx
This repository has been archived on 2024-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
jinx/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs
jduncanator 35e5612766 Implement a rudimentary applets system (#804)
* Implement Player Select applet

* Initialize the Horizon system reference

* Tidy up namespaces

* Resolve nits

* Resolve nits

* Rename stack to queue

* Implement an applet FIFO

* Remove debugging log

* Log applet creation events

* Reorganise AppletFifo

* More reorganisation

* Final changes
2019-11-14 06:18:44 +01:00

55 lines
1.4 KiB
C#

using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System;
using System.IO;
namespace Ryujinx.HLE.HOS.Applets
{
internal class PlayerSelectApplet : IApplet
{
private Horizon _system;
private AppletFifo<byte[]> _inputData;
private AppletFifo<byte[]> _outputData;
public event EventHandler AppletStateChanged;
public PlayerSelectApplet(Horizon system)
{
_system = system;
}
public ResultCode Start(AppletFifo<byte[]> inData, AppletFifo<byte[]> outData)
{
_inputData = inData;
_outputData = outData;
// TODO(jduncanator): Parse PlayerSelectConfig from input data
_outputData.Push(BuildResponse());
AppletStateChanged?.Invoke(this, null);
return ResultCode.Success;
}
public ResultCode GetResult()
{
return ResultCode.Success;
}
private byte[] BuildResponse()
{
UserProfile currentUser = _system.State.Account.LastOpenedUser;
using (MemoryStream stream = new MemoryStream())
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write((ulong)PlayerSelectResult.Success);
currentUser.UserId.Write(writer);
return stream.ToArray();
}
}
}
}