From d4599a312ea90463cd950c7b711f725a606e3f72 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Tue, 5 Jun 2018 15:34:43 +0200 Subject: [PATCH] Stubs for NFP --- .../OsHle/Services/Hid/ControllerID.cs | 16 ++++ .../OsHle/Services/Nfp/DeviceState.cs | 7 ++ Ryujinx.Core/OsHle/Services/Nfp/IUser.cs | 84 ++++++++++++++++++- Ryujinx.Core/OsHle/Services/Nfp/State.cs | 8 ++ 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 Ryujinx.Core/OsHle/Services/Hid/ControllerID.cs create mode 100644 Ryujinx.Core/OsHle/Services/Nfp/DeviceState.cs create mode 100644 Ryujinx.Core/OsHle/Services/Nfp/State.cs diff --git a/Ryujinx.Core/OsHle/Services/Hid/ControllerID.cs b/Ryujinx.Core/OsHle/Services/Hid/ControllerID.cs new file mode 100644 index 0000000000..b8d1e624e4 --- /dev/null +++ b/Ryujinx.Core/OsHle/Services/Hid/ControllerID.cs @@ -0,0 +1,16 @@ +namespace Ryujinx.Core.OsHle.Services.Hid +{ + enum ControllerID + { + ControllerPlayer1 = 0, + ControllerPlayer2 = 1, + ControllerPlayer3 = 2, + ControllerPlayer4 = 3, + ControllerPlayer5 = 4, + ControllerPlayer6 = 5, + ControllerPlayer7 = 6, + ControllerPlayer8 = 7, + ControllerHandheld = 8, + ControllerUnknown = 9, + } +} \ No newline at end of file diff --git a/Ryujinx.Core/OsHle/Services/Nfp/DeviceState.cs b/Ryujinx.Core/OsHle/Services/Nfp/DeviceState.cs new file mode 100644 index 0000000000..f0e748203b --- /dev/null +++ b/Ryujinx.Core/OsHle/Services/Nfp/DeviceState.cs @@ -0,0 +1,7 @@ +namespace Ryujinx.Core.OsHle.Services.Nfp +{ + enum DeviceState + { + Initialized = 0 + } +} \ No newline at end of file diff --git a/Ryujinx.Core/OsHle/Services/Nfp/IUser.cs b/Ryujinx.Core/OsHle/Services/Nfp/IUser.cs index 199d4e151b..a974e6e29a 100644 --- a/Ryujinx.Core/OsHle/Services/Nfp/IUser.cs +++ b/Ryujinx.Core/OsHle/Services/Nfp/IUser.cs @@ -1,6 +1,8 @@ using Ryujinx.Core.Logging; using Ryujinx.Core.OsHle.Ipc; using System.Collections.Generic; +using Ryujinx.Core.OsHle.Handles; +using Ryujinx.Core.OsHle.Services.Hid; namespace Ryujinx.Core.OsHle.Services.Nfp { @@ -10,18 +12,98 @@ namespace Ryujinx.Core.OsHle.Services.Nfp public override IReadOnlyDictionary Commands => m_Commands; + ulong device_handle = 0xDEAD; + ControllerID npad_id = ControllerID.ControllerPlayer1; + State state = State.NonInitialized; + DeviceState device_state = DeviceState.Initialized; + private KEvent ActivateEvent; + private KEvent DeactivateEvent; + private KEvent AvailabilityChangeEvent; + public IUser() { m_Commands = new Dictionary() { - { 0, Initialize } + { 0, Initialize }, + { 17, AttachActivateEvent }, + { 18, AttachDeactivateEvent }, + { 19, GetState }, + { 20, GetDeviceState }, + { 21, GetNpadId }, + { 23, AttachAvailabilityChangeEvent } }; + + ActivateEvent = new KEvent(); + DeactivateEvent = new KEvent(); + AvailabilityChangeEvent = new KEvent(); } public long Initialize(ServiceCtx Context) { Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + state = State.Initialized; + + return 0; + } + + public long AttachActivateEvent(ServiceCtx Context) + { + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + int Handle = Context.Process.HandleTable.OpenHandle(ActivateEvent); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);; + + return 0; + } + + public long AttachDeactivateEvent(ServiceCtx Context) + { + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + int Handle = Context.Process.HandleTable.OpenHandle(DeactivateEvent); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + + return 0; + } + + public long GetState(ServiceCtx Context) + { + Context.ResponseData.Write((int)state); + + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + return 0; + } + + public long GetDeviceState(ServiceCtx Context) + { + Context.ResponseData.Write((int)device_state); + + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + return 0; + } + + public long GetNpadId(ServiceCtx Context) + { + Context.ResponseData.Write((int)npad_id); + + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + return 0; + } + + public long AttachAvailabilityChangeEvent(ServiceCtx Context) + { + Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed."); + + int Handle = Context.Process.HandleTable.OpenHandle(AvailabilityChangeEvent); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + return 0; } } diff --git a/Ryujinx.Core/OsHle/Services/Nfp/State.cs b/Ryujinx.Core/OsHle/Services/Nfp/State.cs new file mode 100644 index 0000000000..c1a07a2240 --- /dev/null +++ b/Ryujinx.Core/OsHle/Services/Nfp/State.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Core.OsHle.Services.Nfp +{ + enum State + { + NonInitialized = 0, + Initialized = 1 + } +} \ No newline at end of file