ISteadyClock.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.HOS.Services.Time
  5. {
  6. class ISteadyClock : IpcService
  7. {
  8. private Dictionary<int, ServiceProcessRequest> _commands;
  9. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  10. private ulong _testOffset;
  11. public ISteadyClock()
  12. {
  13. _commands = new Dictionary<int, ServiceProcessRequest>
  14. {
  15. { 0, GetCurrentTimePoint },
  16. { 1, GetTestOffset },
  17. { 2, SetTestOffset }
  18. };
  19. _testOffset = 0;
  20. }
  21. public long GetCurrentTimePoint(ServiceCtx context)
  22. {
  23. context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds);
  24. for (int i = 0; i < 0x10; i++)
  25. {
  26. context.ResponseData.Write((byte)0);
  27. }
  28. return 0;
  29. }
  30. public long GetTestOffset(ServiceCtx context)
  31. {
  32. context.ResponseData.Write(_testOffset);
  33. return 0;
  34. }
  35. public long SetTestOffset(ServiceCtx context)
  36. {
  37. _testOffset = context.RequestData.ReadUInt64();
  38. return 0;
  39. }
  40. }
  41. }