From 0e69515e3d9efcff6b106fa8ad22083a571029c1 Mon Sep 17 00:00:00 2001 From: caeyo Date: Sun, 16 Aug 2026 16:49:39 +1000 Subject: [PATCH] Allow autosplitters to set timer's timing method --- src/runtime/sys.rs | 2 ++ src/runtime/timer.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/runtime/sys.rs b/src/runtime/sys.rs index 002e218d..3459da96 100644 --- a/src/runtime/sys.rs +++ b/src/runtime/sys.rs @@ -110,6 +110,8 @@ extern "C" { /// Resumes the game time. This does not resume the timer, only the /// automatic flow of time for the game time. pub fn timer_resume_game_time(); + /// Sets whether the timer compares against real time or game time. + pub fn timer_set_timing_method(method: u32); /// Attaches to a process based on its name. The pointer needs to point to /// valid UTF-8 encoded text with the given length. diff --git a/src/runtime/timer.rs b/src/runtime/timer.rs index 2b286081..e5f70769 100644 --- a/src/runtime/timer.rs +++ b/src/runtime/timer.rs @@ -19,6 +19,17 @@ pub enum TimerState { Unknown, } +/// The timing method that LiveSplit compares against. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[non_exhaustive] +#[repr(u32)] +pub enum TimingMethod { + /// Real time. + RealTime = 0, + /// Game time. + GameTime = 1, +} + /// Starts the timer. #[inline] pub fn start() { @@ -150,3 +161,10 @@ pub fn set_game_time(time: time::Duration) { // SAFETY: It is always safe to call this function. unsafe { sys::timer_set_game_time(time.whole_seconds(), time.subsec_nanoseconds()) } } + +/// Sets whether LiveSplit compares against real time or game time. +#[inline] +pub fn set_timing_method(method: TimingMethod) { + // SAFETY: Always safe. + unsafe { sys::timer_set_timing_method(method as u32) } +}