@@ -121,17 +121,21 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
121
121
. unwrap_or ( false ) ;
122
122
123
123
if let Some ( context) = & * SERVER_CORE_CONTEXT . read ( ) {
124
+ let target_timestamp =
125
+ sample_timestamp + context. get_motion_to_photon_latency ( ) ;
124
126
let controllers_pose_time_offset = context. get_tracker_pose_time_offset ( ) ;
127
+ let controllers_timestamp =
128
+ target_timestamp. saturating_sub ( controllers_pose_time_offset) ;
125
129
126
130
let ffi_head_motion = context
127
- . get_device_motion ( * HEAD_ID , sample_timestamp )
131
+ . get_device_motion ( * HEAD_ID , target_timestamp )
128
132
. map ( |m| tracking:: to_ffi_motion ( * HEAD_ID , m) )
129
133
. unwrap_or_else ( FfiDeviceMotion :: default) ;
130
134
let ffi_left_controller_motion = context
131
- . get_device_motion ( * HAND_LEFT_ID , sample_timestamp )
135
+ . get_device_motion ( * HAND_LEFT_ID , controllers_timestamp )
132
136
. map ( |m| tracking:: to_ffi_motion ( * HAND_LEFT_ID , m) ) ;
133
137
let ffi_right_controller_motion = context
134
- . get_device_motion ( * HAND_RIGHT_ID , sample_timestamp )
138
+ . get_device_motion ( * HAND_RIGHT_ID , controllers_timestamp )
135
139
. map ( |m| tracking:: to_ffi_motion ( * HAND_RIGHT_ID , m) ) ;
136
140
137
141
let (
@@ -222,7 +226,7 @@ extern "C" fn driver_ready_idle(set_default_chap: bool) {
222
226
// independently. Selection is done by setting deviceIsConnected.
223
227
unsafe {
224
228
SetTracking (
225
- sample_timestamp . as_nanos ( ) as _ ,
229
+ target_timestamp . as_nanos ( ) as _ ,
226
230
controllers_pose_time_offset. as_secs_f32 ( ) ,
227
231
ffi_head_motion,
228
232
ffi_left_hand_data,
0 commit comments