diff options
| author | 2019-01-10 17:05:21 -0500 | |
|---|---|---|
| committer | 2019-01-10 17:05:21 -0500 | |
| commit | c9ef8b0af1a5908822ca0f3bb3b2238018a555e8 (patch) | |
| tree | 157da486e44b5f7083607159e1bb8bb3e4f20842 /src/core | |
| parent | Merge pull request #1939 from DarkLordZach/web-applet (diff) | |
| parent | settings: Fix comment structure (diff) | |
| download | yuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.tar.gz yuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.tar.xz yuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.zip | |
Merge pull request #1959 from DarkLordZach/custom-rtc
settings: Add support for setting the RTC manually
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 16 | ||||
| -rw-r--r-- | src/core/settings.h | 6 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 715172771..31c590866 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include "core/hle/service/sm/sm.h" | 30 | #include "core/hle/service/sm/sm.h" |
| 31 | #include "core/loader/loader.h" | 31 | #include "core/loader/loader.h" |
| 32 | #include "core/perf_stats.h" | 32 | #include "core/perf_stats.h" |
| 33 | #include "core/settings.h" | ||
| 33 | #include "core/telemetry_session.h" | 34 | #include "core/telemetry_session.h" |
| 34 | #include "frontend/applets/profile_select.h" | 35 | #include "frontend/applets/profile_select.h" |
| 35 | #include "frontend/applets/software_keyboard.h" | 36 | #include "frontend/applets/software_keyboard.h" |
| @@ -96,6 +97,11 @@ struct System::Impl { | |||
| 96 | CoreTiming::Init(); | 97 | CoreTiming::Init(); |
| 97 | kernel.Initialize(); | 98 | kernel.Initialize(); |
| 98 | 99 | ||
| 100 | const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( | ||
| 101 | std::chrono::system_clock::now().time_since_epoch()); | ||
| 102 | Settings::values.custom_rtc_differential = | ||
| 103 | Settings::values.custom_rtc.value_or(current_time) - current_time; | ||
| 104 | |||
| 99 | // Create a default fs if one doesn't already exist. | 105 | // Create a default fs if one doesn't already exist. |
| 100 | if (virtual_filesystem == nullptr) | 106 | if (virtual_filesystem == nullptr) |
| 101 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | 107 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 16564de24..c13640ad8 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -12,9 +12,16 @@ | |||
| 12 | #include "core/hle/kernel/client_session.h" | 12 | #include "core/hle/kernel/client_session.h" |
| 13 | #include "core/hle/service/time/interface.h" | 13 | #include "core/hle/service/time/interface.h" |
| 14 | #include "core/hle/service/time/time.h" | 14 | #include "core/hle/service/time/time.h" |
| 15 | #include "core/settings.h" | ||
| 15 | 16 | ||
| 16 | namespace Service::Time { | 17 | namespace Service::Time { |
| 17 | 18 | ||
| 19 | static std::chrono::seconds GetSecondsSinceEpoch() { | ||
| 20 | return std::chrono::duration_cast<std::chrono::seconds>( | ||
| 21 | std::chrono::system_clock::now().time_since_epoch()) + | ||
| 22 | Settings::values.custom_rtc_differential; | ||
| 23 | } | ||
| 24 | |||
| 18 | static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, | 25 | static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, |
| 19 | CalendarAdditionalInfo& additional_info, | 26 | CalendarAdditionalInfo& additional_info, |
| 20 | [[maybe_unused]] const TimeZoneRule& /*rule*/) { | 27 | [[maybe_unused]] const TimeZoneRule& /*rule*/) { |
| @@ -68,9 +75,7 @@ public: | |||
| 68 | 75 | ||
| 69 | private: | 76 | private: |
| 70 | void GetCurrentTime(Kernel::HLERequestContext& ctx) { | 77 | void GetCurrentTime(Kernel::HLERequestContext& ctx) { |
| 71 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( | 78 | const s64 time_since_epoch{GetSecondsSinceEpoch().count()}; |
| 72 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 73 | .count()}; | ||
| 74 | LOG_DEBUG(Service_Time, "called"); | 79 | LOG_DEBUG(Service_Time, "called"); |
| 75 | 80 | ||
| 76 | IPC::ResponseBuilder rb{ctx, 4}; | 81 | IPC::ResponseBuilder rb{ctx, 4}; |
| @@ -266,10 +271,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | |||
| 266 | IPC::RequestParser rp{ctx}; | 271 | IPC::RequestParser rp{ctx}; |
| 267 | const auto initial_type = rp.PopRaw<u8>(); | 272 | const auto initial_type = rp.PopRaw<u8>(); |
| 268 | 273 | ||
| 269 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( | 274 | const s64 time_since_epoch{GetSecondsSinceEpoch().count()}; |
| 270 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 271 | .count()}; | ||
| 272 | |||
| 273 | const std::time_t time(time_since_epoch); | 275 | const std::time_t time(time_since_epoch); |
| 274 | const std::tm* tm = std::localtime(&time); | 276 | const std::tm* tm = std::localtime(&time); |
| 275 | if (tm == nullptr) { | 277 | if (tm == nullptr) { |
diff --git a/src/core/settings.h b/src/core/settings.h index de01b05c0..29ce98983 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include <chrono> | ||
| 9 | #include <map> | 10 | #include <map> |
| 10 | #include <optional> | 11 | #include <optional> |
| 11 | #include <string> | 12 | #include <string> |
| @@ -350,6 +351,11 @@ struct Values { | |||
| 350 | bool use_docked_mode; | 351 | bool use_docked_mode; |
| 351 | bool enable_nfc; | 352 | bool enable_nfc; |
| 352 | std::optional<u32> rng_seed; | 353 | std::optional<u32> rng_seed; |
| 354 | // Measured in seconds since epoch | ||
| 355 | std::optional<std::chrono::seconds> custom_rtc; | ||
| 356 | // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` | ||
| 357 | std::chrono::seconds custom_rtc_differential; | ||
| 358 | |||
| 353 | s32 current_user; | 359 | s32 current_user; |
| 354 | s32 language_index; | 360 | s32 language_index; |
| 355 | 361 | ||