diff options
| author | Thomas Guillemard <me@thog.eu> | 2019-07-14 22:50:11 +0200 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2019-07-14 22:50:11 +0200 |
| commit | 97d0c6242368f443c50395b2fa9d99a59f1df1e8 (patch) | |
| tree | 95fe1df8cc70f578f4c595feca6d2c253e4ad366 /Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs | |
| parent | 4ad3936afd4ca393a05b330e3848958e9598e910 (diff) | |
Accurately implement steady & system clocks (#732)
* Improve SteadyClock implementation accuracy
* Rewrite system clocks to be accurate
* Implement IStaticService 100 & 101
* Add time:* permissions
* Address comments
* Realign TimePermissions definitions
* Address gdk's comments
* Fix after rebase
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs index ccf19d7d..d9f05f29 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs @@ -1,26 +1,17 @@ -using System; +using Ryujinx.Common; +using Ryujinx.HLE.HOS.Services.Time.Clock; namespace Ryujinx.HLE.HOS.Services.Time { class ISteadyClock : IpcService { - private ulong _testOffset; - - public ISteadyClock() - { - _testOffset = 0; - } - [Command(0)] // GetCurrentTimePoint() -> nn::time::SteadyClockTimePoint public ResultCode GetCurrentTimePoint(ServiceCtx context) { - context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds); + SteadyClockTimePoint currentTimePoint = SteadyClockCore.Instance.GetCurrentTimePoint(context.Thread); - for (int i = 0; i < 0x10; i++) - { - context.ResponseData.Write((byte)0); - } + context.ResponseData.WriteStruct(currentTimePoint); return ResultCode.Success; } @@ -29,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetTestOffset() -> nn::TimeSpanType public ResultCode GetTestOffset(ServiceCtx context) { - context.ResponseData.Write(_testOffset); + context.ResponseData.WriteStruct(SteadyClockCore.Instance.GetTestOffset()); return ResultCode.Success; } @@ -38,7 +29,29 @@ namespace Ryujinx.HLE.HOS.Services.Time // SetTestOffset(nn::TimeSpanType) public ResultCode SetTestOffset(ServiceCtx context) { - _testOffset = context.RequestData.ReadUInt64(); + TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>(); + + SteadyClockCore.Instance.SetTestOffset(testOffset); + + return 0; + } + + [Command(200)] // 3.0.0+ + // GetInternalOffset() -> nn::TimeSpanType + public ResultCode GetInternalOffset(ServiceCtx context) + { + context.ResponseData.WriteStruct(SteadyClockCore.Instance.GetInternalOffset()); + + return ResultCode.Success; + } + + [Command(201)] // 3.0.0-3.0.2 + // SetInternalOffset(nn::TimeSpanType) + public ResultCode SetInternalOffset(ServiceCtx context) + { + TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>(); + + SteadyClockCore.Instance.SetInternalOffset(internalOffset); return ResultCode.Success; } |
