1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use leap_sys::{
LeapCreateClockRebaser, LeapDestroyClockRebaser, LeapRebaseClock, LeapUpdateRebase,
LEAP_CLOCK_REBASER,
};
use crate::{leap_try, Error};
crate::leap_struct!(
#[doc = " \\ingroup Structs"]
#[doc = " \\struct LEAP_CLOCK_REBASER"]
#[doc = " An opaque clock rebase state structure. @since 3.1.2"]
ClockRebaser,
LEAP_CLOCK_REBASER
);
impl Drop for ClockRebaser {
fn drop(&mut self) {
unsafe {
LeapDestroyClockRebaser(self.handle);
}
}
}
impl ClockRebaser {
#[doc = " Initializes a new Leap clock-rebaser handle object."]
#[doc = ""]
#[doc = " Pass the filled-in LEAP_CLOCK_REBASER object to calls to LeapUpdateRebase(),"]
#[doc = " LeapRebaseClock(), and LeapDestroyClockRebaser()."]
#[doc = ""]
#[doc = " @param[out] phClockRebaser The pointer to the clock-rebaser object to be initialized."]
#[doc = " @returns The operation result code, a member of the eLeapRS enumeration."]
#[doc = " @since 3.1.2"]
pub fn create() -> Result<Self, Error> {
unsafe {
let mut handle: LEAP_CLOCK_REBASER = std::mem::zeroed();
leap_try(LeapCreateClockRebaser(&mut handle))?;
Ok(Self { handle })
}
}
#[doc = " Updates the relationship between the Ultraleap Tracking Service clock and the user clock."]
#[doc = ""]
#[doc = " When using LeapInterpolateFrame(), call this function for every graphics frame"]
#[doc = " rendered by your application. The function should be called as close to the"]
#[doc = " actual point of rendering as possible."]
#[doc = ""]
#[doc = " The relationship between the application clock and the Ultraleap Tracking Service clock is"]
#[doc = " neither fixed nor stable. Simulation restarts can cause user clock values to change"]
#[doc = " instantaneously. Certain systems simulate slow motion, or respond to heavy load, by reducing the tick rate"]
#[doc = " of the user clock. As a result, the LeapUpdateRebase() function must be called for every rendered frame."]
#[doc = ""]
#[doc = " @param hClockRebaser The handle to a rebaser object created by LeapCreateClockRebaser()."]
#[doc = " @param userClock A clock value supplied by the application, sampled at about the same time as LeapGetNow() was sampled."]
#[doc = " @param leapClock The Ultraleap Tracking Service clock value sampled by a call to LeapGetNow()."]
#[doc = " @returns The operation result code, a member of the eLeapRS enumeration."]
#[doc = " @since 3.1.2"]
pub fn update_rebase(&mut self, user_clock: i64, leap_clock: i64) -> Result<(), Error> {
unsafe {
leap_try(LeapUpdateRebase(self.handle, user_clock, leap_clock))?;
}
Ok(())
}
#[doc = " Computes the Ultraleap Tracking Service clock corresponding to a specified application clock value."]
#[doc = ""]
#[doc = " Use this function to translate your application clock to the Ultraleap Tracking Service clock"]
#[doc = " when interpolating frames. LeapUpdateRebase() must be called for every rendered"]
#[doc = " frame for the relationship between the two clocks to remain synchronized."]
#[doc = ""]
#[doc = " @param hClockRebaser The handle to a rebaser object created by LeapCreateClockRebaser()."]
#[doc = " @param userClock The clock in microseconds referenced to the application clock."]
#[doc = " @param[out] pLeapClock The corresponding Ultraleap Tracking Service clock value."]
#[doc = " @returns The operation result code, a member of the eLeapRS enumeration."]
#[doc = " @since 3.1.2"]
pub fn rebase_clock(&mut self, user_clock: i64) -> Result<i64, Error> {
let mut leap_clock: i64 = 0;
unsafe {
leap_try(LeapRebaseClock(self.handle, user_clock, &mut leap_clock))?;
}
Ok(leap_clock)
}
}