kj
This commit is contained in:
@@ -147,8 +147,6 @@ struct System::Impl {
|
|||||||
core_timing.SetMulticore(is_multicore);
|
core_timing.SetMulticore(is_multicore);
|
||||||
core_timing.Initialize([&system]() { system.RegisterHostThread(); });
|
core_timing.Initialize([&system]() { system.RegisterHostThread(); });
|
||||||
|
|
||||||
RefreshTime();
|
|
||||||
|
|
||||||
// Create a default fs if one doesn't already exist.
|
// Create a default fs if one doesn't already exist.
|
||||||
if (virtual_filesystem == nullptr) {
|
if (virtual_filesystem == nullptr) {
|
||||||
virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
|
virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
|
||||||
@@ -186,16 +184,6 @@ struct System::Impl {
|
|||||||
Initialize(system);
|
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() {
|
void Run() {
|
||||||
std::unique_lock<std::mutex> lk(suspend_guard);
|
std::unique_lock<std::mutex> lk(suspend_guard);
|
||||||
|
|
||||||
@@ -1061,13 +1049,7 @@ void System::Exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void System::ApplySettings() {
|
void System::ApplySettings() {
|
||||||
impl->RefreshTime();
|
|
||||||
|
|
||||||
if (IsPoweredOn()) {
|
if (IsPoweredOn()) {
|
||||||
if (Settings::values.custom_rtc_enabled) {
|
|
||||||
const s64 posix_time{Settings::values.custom_rtc.GetValue()};
|
|
||||||
GetTimeManager().UpdateLocalSystemClockTime(posix_time);
|
|
||||||
}
|
|
||||||
Renderer().RefreshBaseSettings();
|
Renderer().RefreshBaseSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/file_sys/system_archive/time_zone_binary.h"
|
#include "core/file_sys/system_archive/time_zone_binary.h"
|
||||||
#include "core/file_sys/vfs_vector.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"
|
#include "nx_tzdb.h"
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "common/uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/service/service.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 {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
@@ -254,7 +254,7 @@ private:
|
|||||||
struct InitialLaunchSettings {
|
struct InitialLaunchSettings {
|
||||||
InitialLaunchFlag flags;
|
InitialLaunchFlag flags;
|
||||||
INSERT_PADDING_BYTES(0x4);
|
INSERT_PADDING_BYTES(0x4);
|
||||||
Time::Clock::SteadyClockTimePoint timestamp;
|
Time::SteadyClockTimePoint timestamp;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
|
static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ private:
|
|||||||
EulaVersionClockType clock_type;
|
EulaVersionClockType clock_type;
|
||||||
INSERT_PADDING_BYTES(0x4);
|
INSERT_PADDING_BYTES(0x4);
|
||||||
s64 posix_time;
|
s64 posix_time;
|
||||||
Time::Clock::SteadyClockTimePoint timestamp;
|
Time::SteadyClockTimePoint timestamp;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
|
||||||
|
|
||||||
|
@@ -20,6 +20,8 @@ public:
|
|||||||
|
|
||||||
bool IsInitialized();
|
bool IsInitialized();
|
||||||
|
|
||||||
|
void UpdateTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetCurrentTimePoint(HLERequestContext& ctx);
|
void GetCurrentTimePoint(HLERequestContext& ctx);
|
||||||
|
|
||||||
|
@@ -21,6 +21,8 @@ public:
|
|||||||
Result GetClockContext(SystemClockContext& out_context);
|
Result GetClockContext(SystemClockContext& out_context);
|
||||||
bool IsStandardNetworkSystemClockAccuracySufficient();
|
bool IsStandardNetworkSystemClockAccuracySufficient();
|
||||||
|
|
||||||
|
void UpdateTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetCurrentTime(HLERequestContext& ctx);
|
void GetCurrentTime(HLERequestContext& ctx);
|
||||||
void GetSystemClockContext(HLERequestContext& ctx);
|
void GetSystemClockContext(HLERequestContext& ctx);
|
||||||
|
@@ -4,6 +4,5 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/time/clock_types/steady_clock.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
|
namespace Service::Time {} // namespace Service::Time
|
||||||
|
@@ -4,6 +4,5 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/time/clock_types/steady_clock.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
|
namespace Service::Time {} // namespace Service::Time
|
||||||
|
@@ -4,6 +4,5 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/time/clock_types/steady_clock.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
|
namespace Service::Time {} // namespace Service::Time
|
||||||
|
@@ -3,7 +3,97 @@
|
|||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/time/clock_types/steady_clock.h"
|
#include "core/hle/service/time/time_manager.h"
|
||||||
#include "core/hle/service/time/clock_types/system_clock.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;
|
s64 time) const;
|
||||||
|
|
||||||
SteadyClock& GetStandardSteadyClock();
|
SteadyClock& GetStandardSteadyClock();
|
||||||
|
|
||||||
const SteadyClock& GetStandardSteadyClock() const;
|
const SteadyClock& GetStandardSteadyClock() const;
|
||||||
|
|
||||||
LocalSystemClock& GetStandardLocalSystemClock();
|
LocalSystemClock& GetStandardLocalSystemClock();
|
||||||
|
|
||||||
const LocalSystemClock& GetStandardLocalSystemClock() const;
|
const LocalSystemClock& GetStandardLocalSystemClock() const;
|
||||||
|
|
||||||
NetworkSystemClock& GetStandardNetworkSystemClock();
|
NetworkSystemClock& GetStandardNetworkSystemClock();
|
||||||
|
|
||||||
const NetworkSystemClock& GetStandardNetworkSystemClock() const;
|
const NetworkSystemClock& GetStandardNetworkSystemClock() const;
|
||||||
|
|
||||||
UserSystemClock& GetStandardUserSystemClock();
|
UserSystemClock& GetStandardUserSystemClock();
|
||||||
|
|
||||||
const UserSystemClock& GetStandardUserSystemClock() const;
|
const UserSystemClock& GetStandardUserSystemClock() const;
|
||||||
|
|
||||||
ITimeZoneService& GetTimeZoneService();
|
ITimeZoneService& GetTimeZoneService();
|
||||||
|
|
||||||
const ITimeZoneService& GetTimeZoneService() const;
|
const ITimeZoneService& GetTimeZoneService() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void UpdateTime();
|
||||||
|
|
||||||
|
std::shared_ptr<Core::Timing::EventType> time_update_event;
|
||||||
|
|
||||||
SteadyClock steady_clock;
|
SteadyClock steady_clock;
|
||||||
LocalSystemClock local_system_clock;
|
LocalSystemClock local_system_clock;
|
||||||
NetworkSystemClock network_system_clock;
|
NetworkSystemClock network_system_clock;
|
||||||
UserSystemClock user_system_clock;
|
UserSystemClock user_system_clock;
|
||||||
ITimeZoneService time_zone_service;
|
ITimeZoneService time_zone_service;
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::Time
|
} // namespace Service::Time
|
||||||
|
@@ -16,6 +16,8 @@ public:
|
|||||||
explicit ITimeZoneService(Core::System& system_);
|
explicit ITimeZoneService(Core::System& system_);
|
||||||
~ITimeZoneService();
|
~ITimeZoneService();
|
||||||
|
|
||||||
|
void UpdateTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetDeviceLocationName(HLERequestContext& ctx);
|
void GetDeviceLocationName(HLERequestContext& ctx);
|
||||||
void GetTotalLocationNameCount(HLERequestContext& ctx);
|
void GetTotalLocationNameCount(HLERequestContext& ctx);
|
||||||
|
Reference in New Issue
Block a user