diff options
author | bunnei <bunneidev@gmail.com> | 2020-01-20 04:45:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-20 04:45:05 +0100 |
commit | 8b9f433d9510b4a02f432c2fdb1eded323ddff25 (patch) | |
tree | 90f30f2c4a0fd05789b56a624ada99ed069f3d2c /src/core/hle/service/time/system_clock_core.h | |
parent | Merge pull request #3313 from ReinUsesLisp/vk-rasterizer (diff) | |
parent | service: time: Implement GetStandardLocalSystemClock. (diff) | |
download | yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar.gz yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar.bz2 yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar.lz yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar.xz yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.tar.zst yuzu-8b9f433d9510b4a02f432c2fdb1eded323ddff25.zip |
Diffstat (limited to 'src/core/hle/service/time/system_clock_core.h')
-rw-r--r-- | src/core/hle/service/time/system_clock_core.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h new file mode 100644 index 000000000..54407a6c5 --- /dev/null +++ b/src/core/hle/service/time/system_clock_core.h @@ -0,0 +1,71 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" +#include "core/hle/service/time/clock_types.h" + +namespace Core { +class System; +} + +namespace Service::Time::Clock { + +class SteadyClockCore; +class SystemClockContextUpdateCallback; + +// Parts of this implementation were based on Ryujinx (https://github.com/Ryujinx/Ryujinx/pull/783). +// This code was released under public domain. + +class SystemClockCore { +public: + explicit SystemClockCore(SteadyClockCore& steady_clock_core); + ~SystemClockCore(); + + SteadyClockCore& GetSteadyClockCore() const { + return steady_clock_core; + } + + ResultCode GetCurrentTime(Core::System& system, s64& posix_time) const; + + ResultCode SetCurrentTime(Core::System& system, s64 posix_time); + + virtual ResultCode GetClockContext([[maybe_unused]] Core::System& system, + SystemClockContext& value) const { + value = context; + return RESULT_SUCCESS; + } + + virtual ResultCode SetClockContext(const SystemClockContext& value) { + context = value; + return RESULT_SUCCESS; + } + + virtual ResultCode Flush(const SystemClockContext& context); + + void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) { + system_clock_context_update_callback = std::move(callback); + } + + ResultCode SetSystemClockContext(const SystemClockContext& context); + + bool IsInitialized() const { + return is_initialized; + } + + void MarkAsInitialized() { + is_initialized = true; + } + + bool IsClockSetup(Core::System& system) const; + +private: + SteadyClockCore& steady_clock_core; + SystemClockContext context{}; + bool is_initialized{}; + std::shared_ptr<SystemClockContextUpdateCallback> system_clock_context_update_callback; +}; + +} // namespace Service::Time::Clock |