2018-08-16 19:47:36 -04:00
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
|
|
|
|
using Ryujinx.HLE.Input;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
using Ryujinx.HLE.Logging;
|
2018-06-02 18:46:09 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nfp
|
2018-06-02 18:46:09 -04:00
|
|
|
|
{
|
|
|
|
|
class IUser : IpcService
|
|
|
|
|
{
|
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
|
|
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private const HidControllerId NpadId = HidControllerId.CONTROLLER_PLAYER_1;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private State State = State.NonInitialized;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private DeviceState DeviceState = DeviceState.Initialized;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private KEvent ActivateEvent;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private KEvent DeactivateEvent;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
private KEvent AvailabilityChangeEvent;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
|
public IUser(Horizon System)
|
2018-06-02 18:46:09 -04:00
|
|
|
|
{
|
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
|
{
|
2018-06-10 00:36:07 -04:00
|
|
|
|
{ 0, Initialize },
|
|
|
|
|
{ 17, AttachActivateEvent },
|
|
|
|
|
{ 18, AttachDeactivateEvent },
|
|
|
|
|
{ 19, GetState },
|
|
|
|
|
{ 20, GetDeviceState },
|
|
|
|
|
{ 21, GetNpadId },
|
|
|
|
|
{ 23, AttachAvailabilityChangeEvent }
|
2018-06-02 18:46:09 -04:00
|
|
|
|
};
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
|
ActivateEvent = new KEvent(System);
|
|
|
|
|
DeactivateEvent = new KEvent(System);
|
|
|
|
|
AvailabilityChangeEvent = new KEvent(System);
|
2018-06-02 18:46:09 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long Initialize(ServiceCtx Context)
|
|
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-02 18:46:09 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
State = State.Initialized;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long AttachActivateEvent(ServiceCtx Context)
|
|
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
|
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(ActivateEvent);
|
|
|
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long AttachDeactivateEvent(ServiceCtx Context)
|
|
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
|
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(DeactivateEvent);
|
|
|
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long GetState(ServiceCtx Context)
|
2018-06-10 20:46:42 -04:00
|
|
|
|
{
|
2018-06-10 00:36:07 -04:00
|
|
|
|
Context.ResponseData.Write((int)State);
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long GetDeviceState(ServiceCtx Context)
|
|
|
|
|
{
|
|
|
|
|
Context.ResponseData.Write((int)DeviceState);
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long GetNpadId(ServiceCtx Context)
|
|
|
|
|
{
|
|
|
|
|
Context.ResponseData.Write((int)NpadId);
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 00:36:07 -04:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long AttachAvailabilityChangeEvent(ServiceCtx Context)
|
|
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
|
2018-06-10 20:46:42 -04:00
|
|
|
|
|
2018-06-10 00:36:07 -04:00
|
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(AvailabilityChangeEvent);
|
|
|
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
|
|
|
|
|
2018-06-02 18:46:09 -04:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|