mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-08-31 09:49:08 +01:00
time: Use custom RTC settings if applicable for game
This commit is contained in:
parent
21f1b2889d
commit
dbb1eb9c29
2 changed files with 12 additions and 8 deletions
|
@ -12,9 +12,17 @@
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/service/time/interface.h"
|
#include "core/hle/service/time/interface.h"
|
||||||
#include "core/hle/service/time/time.h"
|
#include "core/hle/service/time/time.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
|
||||||
namespace Service::Time {
|
namespace Service::Time {
|
||||||
|
|
||||||
|
static s64 GetSecondsSinceEpoch() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::system_clock::now().time_since_epoch())
|
||||||
|
.count() +
|
||||||
|
Settings::values.custom_rtc_differential;
|
||||||
|
}
|
||||||
|
|
||||||
static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time,
|
static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time,
|
||||||
CalendarAdditionalInfo& additional_info,
|
CalendarAdditionalInfo& additional_info,
|
||||||
[[maybe_unused]] const TimeZoneRule& /*rule*/) {
|
[[maybe_unused]] const TimeZoneRule& /*rule*/) {
|
||||||
|
@ -68,9 +76,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetCurrentTime(Kernel::HLERequestContext& ctx) {
|
void GetCurrentTime(Kernel::HLERequestContext& ctx) {
|
||||||
const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>(
|
const s64 time_since_epoch{GetSecondsSinceEpoch()};
|
||||||
std::chrono::system_clock::now().time_since_epoch())
|
|
||||||
.count()};
|
|
||||||
LOG_DEBUG(Service_Time, "called");
|
LOG_DEBUG(Service_Time, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
|
@ -266,9 +272,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto initial_type = rp.PopRaw<u8>();
|
const auto initial_type = rp.PopRaw<u8>();
|
||||||
|
|
||||||
const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>(
|
const s64 time_since_epoch{GetSecondsSinceEpoch()};
|
||||||
std::chrono::system_clock::now().time_since_epoch())
|
|
||||||
.count()};
|
|
||||||
|
|
||||||
const std::time_t time(time_since_epoch);
|
const std::time_t time(time_since_epoch);
|
||||||
const std::tm* tm = std::localtime(&time);
|
const std::tm* tm = std::localtime(&time);
|
||||||
|
|
|
@ -186,8 +186,8 @@ rng_seed =
|
||||||
# Sets the current time (in seconds since 12:00 AM Jan 1, 1970) that will be used by the time service
|
# Sets the current time (in seconds since 12:00 AM Jan 1, 1970) that will be used by the time service
|
||||||
# This will auto-increment, with the time set being the time the game is started
|
# This will auto-increment, with the time set being the time the game is started
|
||||||
# This override will only occur if custom_rtc_enabled is true, otherwise the current time is used
|
# This override will only occur if custom_rtc_enabled is true, otherwise the current time is used
|
||||||
custom_rtc_enabled =
|
custom_rtc_enabled =
|
||||||
custom_rtc =
|
custom_rtc =
|
||||||
|
|
||||||
# Sets the account username, max length is 32 characters
|
# Sets the account username, max length is 32 characters
|
||||||
# yuzu (default)
|
# yuzu (default)
|
||||||
|
|
Loading…
Reference in a new issue