mirror of
https://github.com/lbgos/rift-s-linux.git
synced 2026-10-29 04:02:05 +01:00
xrt: Devices get a timekeeping object, must return a timestamp.
Updates drivers to match.
This commit is contained in:
1 parent
294be21392
commit
9004ea80bb
4 files changed
+18
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
/*!
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user