Monado OpenXR Runtime
hdk_device.cpp File Reference

Driver for an OSVR Hacker Dev Kit device. More...

#include "math/m_mathinclude.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <type_traits>
#include "xrt/xrt_device.h"
#include "os/os_hid.h"
#include "os/os_time.h"
#include "math/m_api.h"
#include "util/u_debug.h"
#include "util/u_misc.h"
#include "util/u_device.h"
#include "util/u_time.h"
#include "util/u_distortion_mesh.h"
#include "hdk_device.h"
Include dependency graph for hdk_device.cpp:

Macros

#define HDK_SIN_PI_OVER_4   0.7071068f
 
#define HDK_DEBUG_INT(hd, name, val)   HDK_DEBUG(hd, "\t%s = %u", name, val)
 
#define HDK_DEBUG_MM(hd, name, val)    HDK_DEBUG(hd, "\t%s = %i.%02imm", name, (int32_t)(val * 1000.f), abs((int32_t)(val * 100000.f)) % 100)
 
#define HDK_DEBUG_ANGLE(hd, name, val)   HDK_DEBUG(hd, "\t%s = %f (%i)", name, val, (int32_t)(val * (180 / M_PI)))
 
#define HDK_DEBUG_MAT2X2(hd, name, rot)    HDK_DEBUG(hd, "\t%s = {%f, %f} {%f, %f}", name, rot.v[0], rot.v[1], rot.v[2], rot.v[3])
 

Functions

template<size_t INT_BITS, size_t FRAC_BITS, typename IntegerType >
static float fromFixedPoint (IntegerType v)
 A fixed-point to float conversion function. More...
 
static uint16_t hdk_get_le_uint16 (uint8_t *&bufPtr)
 
static int16_t hdk_get_le_int16 (uint8_t *&bufPtr)
 
static void hdk_device_destroy (struct xrt_device *xdev)
 
static int hdk_device_update (struct hdk_device *hd)
 
static xrt_result_t hdk_device_get_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, int64_t requested_timestamp_ns, struct xrt_space_relation *out_relation)
 
static void * hdk_device_run_thread (void *ptr)
 
struct hdk_devicehdk_device_create (struct os_hid_device *dev, enum HDK_VARIANT variant)
 

Variables

static constexpr uint8_t BITS_PER_BYTE = 8
 
static constexpr uint8_t MSG_LEN_LARGE = 32
 
static constexpr uint8_t MSG_LEN_SMALL = 16
 

Detailed Description

Driver for an OSVR Hacker Dev Kit device.

Based in part on the corresponding VRPN driver, available under BSL-1.0.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com
Kevin M. Godby kevin.nosp@m.@god.nosp@m.by.or.nosp@m.g

Function Documentation

◆ fromFixedPoint()

template<size_t INT_BITS, size_t FRAC_BITS, typename IntegerType >
static float fromFixedPoint ( IntegerType  v)
inlinestatic

A fixed-point to float conversion function.

Values are signed, two's-complement, if the supplied integer is.

The conversion is effectively from the fixed-point arithmetic type known "unambiguously" as Q INT_BITS.FRAC_BITS - the number of integer bits is not inferred, though it is checked to ensure it adds up.

Template Parameters
INT_BITSThe number of bits devoted to the integer part.
FRAC_BITSThe number of bits devoted to the fractional part.
IntegerTypeThe input integer type, typically deduced (do not need to specify explicitly)
Parameters
vAn input "integer" that is actually a fixed-point value.

INT_BITS and FRAC_BITS must sum to 8 * sizeof(v), the bit width of the input integer, for unsigned values, or to one less than that (for the sign bit) for signed values.

Based in part on the VRPN header vrpn_FixedPoint.h, available under BSL-1.0.

◆ hdk_device_update()

static int hdk_device_update ( struct hdk_device hd)
static
Todo:
might not be accurate on some version 1 reports??