Manage state of NfcManager (#3678)

* Manage state of NfcManager

Very basic state management but works with Hyrule Warriors Definitive Edition. Partially fixes #2122

* Fixes changes from review
This commit is contained in:
Carl Ouellette 2022-10-18 21:14:31 -04:00 committed by GitHub
parent 7d26e4ac7b
commit 2099a3e84b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View file

@ -5,22 +5,48 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager
class INfc : IpcService class INfc : IpcService
{ {
private NfcPermissionLevel _permissionLevel; private NfcPermissionLevel _permissionLevel;
private State _state;
public INfc(NfcPermissionLevel permissionLevel) public INfc(NfcPermissionLevel permissionLevel)
{ {
_permissionLevel = permissionLevel; _permissionLevel = permissionLevel;
_state = State.NonInitialized;
} }
[CommandHipc(0)] [CommandHipc(0)]
[CommandHipc(400)] // 4.0.0+ [CommandHipc(400)] // 4.0.0+
// Initialize() // Initialize(u64, u64, pid, buffer<unknown, 5>)
public ResultCode Initialize(ServiceCtx context) public ResultCode Initialize(ServiceCtx context)
{ {
_state = State.Initialized;
Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel }); Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
return ResultCode.Success; return ResultCode.Success;
} }
[CommandHipc(1)]
[CommandHipc(401)] // 4.0.0+
// Finalize()
public ResultCode Finalize(ServiceCtx context)
{
_state = State.NonInitialized;
Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
return ResultCode.Success;
}
[CommandHipc(2)]
[CommandHipc(402)] // 4.0.0+
// GetState() -> u32
public ResultCode GetState(ServiceCtx context)
{
context.ResponseData.Write((int)_state);
return ResultCode.Success;
}
[CommandHipc(3)] [CommandHipc(3)]
[CommandHipc(403)] // 4.0.0+ [CommandHipc(403)] // 4.0.0+
// IsNfcEnabled() -> b8 // IsNfcEnabled() -> b8

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager
{
enum State
{
NonInitialized,
Initialized
}
}