diff --git a/src/xrt/drivers/hdk/hdk_device.cpp b/src/xrt/drivers/hdk/hdk_device.cpp index 38fce346e..52f5d4ea5 100644 --- a/src/xrt/drivers/hdk/hdk_device.cpp +++ b/src/xrt/drivers/hdk/hdk_device.cpp @@ -28,6 +28,7 @@ #include "util/u_debug.h" #include "util/u_misc.h" #include "util/u_device.h" +#include "util/u_time.h" #include "hdk_device.h" @@ -99,11 +100,14 @@ hdk_device_destroy(struct xrt_device *xdev) static void hdk_device_get_tracked_pose(struct xrt_device *xdev, + struct time_state *timekeeping, + int64_t *out_timestamp, struct xrt_space_relation *out_relation) { struct hdk_device *hd = hdk_device(xdev); uint8_t buffer[32]; + int64_t now = time_state_get_now(timekeeping); auto bytesRead = hid_read(hd->dev, &(buffer[0]), sizeof(buffer)); if (bytesRead == -1) { if (!hd->disconnect_notified) { @@ -121,6 +125,8 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev, out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE; return; } + //! @todo adjust for latency here + *out_timestamp = now; uint8_t *buf = &(buffer[0]); #if 0 diff --git a/src/xrt/drivers/ohmd/oh_device.c b/src/xrt/drivers/ohmd/oh_device.c index 29f6b7ee7..4e470a054 100644 --- a/src/xrt/drivers/ohmd/oh_device.c +++ b/src/xrt/drivers/ohmd/oh_device.c @@ -20,6 +20,7 @@ #include "util/u_misc.h" #include "util/u_debug.h" #include "util/u_device.h" +#include "util/u_time.h" #include "oh_device.h" @@ -41,11 +42,16 @@ oh_device_destroy(struct xrt_device *xdev) static void oh_device_get_tracked_pose(struct xrt_device *xdev, + struct time_state *timekeeping, + int64_t *out_timestamp, struct xrt_space_relation *out_relation) { struct oh_device *ohd = oh_device(xdev); struct xrt_quat quat = {0.f, 0.f, 0.f, 1.f}; ohmd_ctx_update(ohd->ctx); + int64_t now = time_state_get_now(timekeeping); + //! @todo adjust for latency here + *out_timestamp = now; ohmd_device_getf(ohd->dev, OHMD_ROTATION_QUAT, &quat.x); out_relation->pose.orientation = quat; //! @todo assuming that orientation is actually currently tracked. diff --git a/src/xrt/include/xrt/xrt_device.h b/src/xrt/include/xrt/xrt_device.h index f501b7b5e..e19ed0c5a 100644 --- a/src/xrt/include/xrt/xrt_device.h +++ b/src/xrt/include/xrt/xrt_device.h @@ -15,6 +15,7 @@ extern "C" { #endif +struct time_state; /*! * A per-lens view information. @@ -153,6 +154,8 @@ struct xrt_device * This is very very WIP and will need to be made a lot more advanced. */ void (*get_tracked_pose)(struct xrt_device *xdev, + struct time_state *timekeeping, + int64_t *out_timestamp, struct xrt_space_relation *out_relation); /*! diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index 287b6275f..740ba6a00 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -135,7 +135,9 @@ oxr_session_get_view_pose_at(struct oxr_logger *log, struct xrt_device *xdev = sess->sys->device; struct xrt_space_relation relation; - xdev->get_tracked_pose(xdev, &relation); + int64_t timestamp; + xdev->get_tracked_pose(xdev, sess->sys->inst->timekeeping, ×tamp, + &relation); if ((relation.relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0) { pose->orientation = relation.pose.orientation;