INfc.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Ryujinx.Common.Logging;
  2. namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager
  3. {
  4. class INfc : IpcService
  5. {
  6. private NfcPermissionLevel _permissionLevel;
  7. private State _state;
  8. public INfc(NfcPermissionLevel permissionLevel)
  9. {
  10. _permissionLevel = permissionLevel;
  11. _state = State.NonInitialized;
  12. }
  13. [CommandHipc(0)]
  14. [CommandHipc(400)] // 4.0.0+
  15. // Initialize(u64, u64, pid, buffer<unknown, 5>)
  16. public ResultCode Initialize(ServiceCtx context)
  17. {
  18. _state = State.Initialized;
  19. Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
  20. return ResultCode.Success;
  21. }
  22. [CommandHipc(1)]
  23. [CommandHipc(401)] // 4.0.0+
  24. // Finalize()
  25. public ResultCode Finalize(ServiceCtx context)
  26. {
  27. _state = State.NonInitialized;
  28. Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
  29. return ResultCode.Success;
  30. }
  31. [CommandHipc(2)]
  32. [CommandHipc(402)] // 4.0.0+
  33. // GetState() -> u32
  34. public ResultCode GetState(ServiceCtx context)
  35. {
  36. context.ResponseData.Write((int)_state);
  37. return ResultCode.Success;
  38. }
  39. [CommandHipc(3)]
  40. [CommandHipc(403)] // 4.0.0+
  41. // IsNfcEnabled() -> b8
  42. public ResultCode IsNfcEnabled(ServiceCtx context)
  43. {
  44. // NOTE: Write false value here could make nfp service not called.
  45. context.ResponseData.Write(true);
  46. Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
  47. return ResultCode.Success;
  48. }
  49. }
  50. }