Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/runtime/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/runtime/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) }
}