This commit is contained in:
parent
3c3ca709de
commit
47a469804b
|
@ -147,8 +147,6 @@ struct System::Impl {
|
|||
core_timing.SetMulticore(is_multicore);
|
||||
core_timing.Initialize([&system]() { system.RegisterHostThread(); });
|
||||
|
||||
RefreshTime();
|
||||
|
||||
// Create a default fs if one doesn't already exist.
|
||||
if (virtual_filesystem == nullptr) {
|
||||
virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
|
||||
|
@ -186,16 +184,6 @@ struct System::Impl {
|
|||
Initialize(system);
|
||||
}
|
||||
|
||||
void RefreshTime() {
|
||||
const auto posix_time = std::chrono::system_clock::now().time_since_epoch();
|
||||
const auto current_time =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(posix_time).count();
|
||||
Settings::values.custom_rtc_differential =
|
||||
(Settings::values.custom_rtc_enabled ? Settings::values.custom_rtc.GetValue()
|
||||
: current_time) -
|
||||
current_time;
|
||||
}
|
||||
|
||||
void Run() {
|
||||
std::unique_lock<std::mutex> lk(suspend_guard);
|
||||
|
||||
|
@ -1061,13 +1049,7 @@ void System::Exit() {
|
|||
}
|
||||
|
||||
void System::ApplySettings() {
|
||||
impl->RefreshTime();
|
||||
|
||||
if (IsPoweredOn()) {
|
||||
if (Settings::values.custom_rtc_enabled) {
|
||||
const s64 posix_time{Settings::values.custom_rtc.GetValue()};
|
||||
GetTimeManager().UpdateLocalSystemClockTime(posix_time);
|
||||
}
|
||||
Renderer().RefreshBaseSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "common/swap.h"
|
||||
#include "core/file_sys/system_archive/time_zone_binary.h"
|
||||
#include "core/file_sys/vfs_vector.h"
|
||||
#include "core/hle/service/time/time_zone_types.h"
|
||||
#include "core/hle/service/time/time_zone/time_zone_types.h"
|
||||
|
||||
#include "nx_tzdb.h"
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/time/clock_types.h"
|
||||
#include "core/hle/service/time/time_types.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
|
@ -254,7 +254,7 @@ private:
|
|||
struct InitialLaunchSettings {
|
||||
InitialLaunchFlag flags;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
Time::Clock::SteadyClockTimePoint timestamp;
|
||||
Time::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
|
||||
|
||||
|
@ -265,7 +265,7 @@ private:
|
|||
EulaVersionClockType clock_type;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
s64 posix_time;
|
||||
Time::Clock::SteadyClockTimePoint timestamp;
|
||||
Time::SteadyClockTimePoint timestamp;
|
||||
};
|
||||
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
|
||||
bool IsInitialized();
|
||||
|
||||
void UpdateTime();
|
||||
|
||||
private:
|
||||
void GetCurrentTimePoint(HLERequestContext& ctx);
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
Result GetClockContext(SystemClockContext& out_context);
|
||||
bool IsStandardNetworkSystemClockAccuracySufficient();
|
||||
|
||||
void UpdateTime();
|
||||
|
||||
private:
|
||||
void GetCurrentTime(HLERequestContext& ctx);
|
||||
void GetSystemClockContext(HLERequestContext& ctx);
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/time/clock_types/steady_clock.h"
|
||||
#include "core/hle/service/time/clock_types/system_clock.h"
|
||||
|
||||
namespace Service::Time {} // namespace Service::Time
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/time/clock_types/steady_clock.h"
|
||||
#include "core/hle/service/time/clock_types/system_clock.h"
|
||||
|
||||
namespace Service::Time {} // namespace Service::Time
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/time/clock_types/steady_clock.h"
|
||||
#include "core/hle/service/time/clock_types/system_clock.h"
|
||||
|
||||
namespace Service::Time {} // namespace Service::Time
|
||||
|
|
|
@ -3,7 +3,97 @@
|
|||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/time/clock_types/steady_clock.h"
|
||||
#include "core/hle/service/time/clock_types/system_clock.h"
|
||||
#include "core/hle/service/time/time_manager.h"
|
||||
#include "core/core_timing.h"
|
||||
|
||||
namespace Service::Time {} // namespace Service::Time
|
||||
namespace Service::Time {
|
||||
constexpr auto time_update_ns =
|
||||
std::chrono::nanoseconds{5ull * 60 * 1000 * 1000 * 1000}; // (5 minutes)
|
||||
|
||||
TimeManager::TimeManager(Core::System& system_) : time_zone_service{system_}, system{system_} {
|
||||
|
||||
// Register update callbacks
|
||||
time_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdatePadCallback",
|
||||
[this](std::uintptr_t user_data, s64 time,
|
||||
std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
UpdateTime();
|
||||
return std::nullopt;
|
||||
});
|
||||
|
||||
system.CoreTiming().ScheduleLoopingEvent(time_update_ns, time_update_ns, time_update_event);
|
||||
}
|
||||
|
||||
TimeManager::~TimeManager() {
|
||||
system.CoreTiming().UnscheduleEvent(time_update_event, 0);
|
||||
};
|
||||
|
||||
void TimeManager::UpdateTime() {
|
||||
steady_clock.UpdateTime();
|
||||
local_system_clock.UpdateTime();
|
||||
network_system_clock.UpdateTime();
|
||||
user_system_clock.UpdateTime();
|
||||
time_zone_service.UpdateTime();
|
||||
}
|
||||
|
||||
bool TimeManager::IsAutomaticCorrectionEnabled() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Result TimeManager::GetCurrentTimePoint(SteadyClockTimePoint& out_steady_time_point) const {
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result TimeManager::GetLocationName(TimeZone::LocationName& out_name) const {
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result TimeManager::GetCalendarTime(TimeZone::CalendarTime& out_calendar_time,
|
||||
TimeZone::CalendarAdditionalInfo& out_calendar_aditional_info,
|
||||
s64 time) const {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
SteadyClock& TimeManager::GetStandardSteadyClock() {
|
||||
return steady_clock;
|
||||
}
|
||||
|
||||
const SteadyClock& TimeManager::GetStandardSteadyClock() const {
|
||||
return steady_clock;
|
||||
}
|
||||
|
||||
LocalSystemClock& TimeManager::GetStandardLocalSystemClock() {
|
||||
return local_system_clock;
|
||||
}
|
||||
|
||||
const LocalSystemClock& TimeManager::GetStandardLocalSystemClock() const {
|
||||
return local_system_clock;
|
||||
}
|
||||
|
||||
NetworkSystemClock& TimeManager::GetStandardNetworkSystemClock() {
|
||||
return network_system_clock;
|
||||
}
|
||||
|
||||
const NetworkSystemClock& TimeManager::GetStandardNetworkSystemClock() const {
|
||||
return network_system_clock;
|
||||
}
|
||||
|
||||
UserSystemClock& TimeManager::GetStandardUserSystemClock() {
|
||||
return user_system_clock;
|
||||
}
|
||||
|
||||
const UserSystemClock& TimeManager::GetStandardUserSystemClock() const {
|
||||
return user_system_clock;
|
||||
}
|
||||
|
||||
ITimeZoneService& TimeManager::GetTimeZoneService() {
|
||||
return time_zone_service;
|
||||
}
|
||||
|
||||
const ITimeZoneService& TimeManager::GetTimeZoneService() const {
|
||||
return time_zone_service;
|
||||
}
|
||||
|
||||
} // namespace Service::Time
|
||||
|
|
|
@ -30,31 +30,31 @@ public:
|
|||
s64 time) const;
|
||||
|
||||
SteadyClock& GetStandardSteadyClock();
|
||||
|
||||
const SteadyClock& GetStandardSteadyClock() const;
|
||||
|
||||
LocalSystemClock& GetStandardLocalSystemClock();
|
||||
|
||||
const LocalSystemClock& GetStandardLocalSystemClock() const;
|
||||
|
||||
NetworkSystemClock& GetStandardNetworkSystemClock();
|
||||
|
||||
const NetworkSystemClock& GetStandardNetworkSystemClock() const;
|
||||
|
||||
UserSystemClock& GetStandardUserSystemClock();
|
||||
|
||||
const UserSystemClock& GetStandardUserSystemClock() const;
|
||||
|
||||
ITimeZoneService& GetTimeZoneService();
|
||||
|
||||
const ITimeZoneService& GetTimeZoneService() const;
|
||||
|
||||
private:
|
||||
void UpdateTime();
|
||||
|
||||
std::shared_ptr<Core::Timing::EventType> time_update_event;
|
||||
|
||||
SteadyClock steady_clock;
|
||||
LocalSystemClock local_system_clock;
|
||||
NetworkSystemClock network_system_clock;
|
||||
UserSystemClock user_system_clock;
|
||||
ITimeZoneService time_zone_service;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Service::Time
|
||||
|
|
|
@ -16,6 +16,8 @@ public:
|
|||
explicit ITimeZoneService(Core::System& system_);
|
||||
~ITimeZoneService();
|
||||
|
||||
void UpdateTime();
|
||||
|
||||
private:
|
||||
void GetDeviceLocationName(HLERequestContext& ctx);
|
||||
void GetTotalLocationNameCount(HLERequestContext& ctx);
|
||||
|
|
Loading…
Reference in New Issue