Monado OpenXR Runtime
u_device.h File Reference

Misc helpers for device drivers. More...

#include "xrt/xrt_compiler.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_tracking.h"
Include dependency graph for u_device.h:

Go to the source code of this file.

Data Structures

struct  u_extents_2d
 Info to describe 2D extents of a device's screen. More...
 
struct  u_device_simple_info
 Info to describe a very simple headset with diffractive lens optics. More...
 

Macros

#define U_DEVICE_ALLOCATE(type, flags, input_count, output_count)    ((type *)u_device_allocate(flags, sizeof(type), input_count, output_count))
 
#define XRT_DEVICE_ROLE_UNASSIGNED   (-1)
 

Enumerations

enum  u_device_alloc_flags { U_DEVICE_ALLOC_NO_FLAGS = 0 , U_DEVICE_ALLOC_HMD = 1u << 0u , U_DEVICE_ALLOC_TRACKING_NONE = 1u << 1u }
 

Functions

bool u_device_setup_one_eye (struct xrt_device *xdev, const struct u_device_simple_info *info)
 Setup the device information given a very simple info struct. More...
 
bool u_device_setup_split_side_by_side (struct xrt_device *xdev, const struct u_device_simple_info *info)
 Setup the device information given a very simple info struct. More...
 
bool u_extents_2d_split_side_by_side (struct xrt_device *xdev, const struct u_extents_2d *extents)
 Setup the device's display's 2D extents. More...
 
void u_device_dump_config (struct xrt_device *xdev, const char *prefix, const char *prod)
 Dump the device config to stderr. More...
 
void * u_device_allocate (enum u_device_alloc_flags flags, size_t size, size_t input_count, size_t output_count)
 Helper function to allocate a device plus inputs in the same allocation placed after the device in memory. More...
 
void u_device_free (struct xrt_device *xdev)
 Helper function to free a device and any data hanging of it. More...
 
void u_device_assign_xdev_roles (struct xrt_device **xdevs, size_t xdev_count, int *head, int *left, int *right)
 Helper function to assign head, left hand and right hand roles. More...
 
void u_device_get_view_pose (const struct xrt_vec3 *eye_relation, uint32_t view_index, struct xrt_pose *out_pose)
 Helper function for get_view_pose in an HMD driver. More...
 
void u_device_get_view_poses (struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, uint64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
 Helper function to implement xrt_device::get_view_poses in a HMD driver. More...
 
void u_device_noop_update_inputs (struct xrt_device *xdev)
 Noop function for xrt_device::update_inputs, should only be used from a device with any inputs. More...
 
void u_device_ni_get_hand_tracking (struct xrt_device *xdev, enum xrt_input_name name, uint64_t desired_timestamp_ns, struct xrt_hand_joint_set *out_value, uint64_t *out_timestamp_ns)
 Not implemented function for xrt_device::get_hand_tracking. More...
 
void u_device_ni_set_output (struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value)
 Not implemented function for xrt_device::set_output. More...
 
void u_device_ni_get_view_poses (struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, uint64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
 Not implemented function for xrt_device::get_view_poses. More...
 
bool u_device_ni_compute_distortion (struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
 Not implemented function for xrt_device::compute_distortion. More...
 
xrt_result_t u_device_ni_get_visibility_mask (struct xrt_device *xdev, enum xrt_visibility_mask_type type, uint32_t view_index, struct xrt_visibility_mask **out_mask)
 Not implemented function for xrt_device::get_visibility_mask. More...
 
bool u_device_ni_is_form_factor_available (struct xrt_device *xdev, enum xrt_form_factor form_factor)
 Not implemented function for xrt_device::is_form_factor_available. More...
 

Variables

const struct xrt_matrix_2x2 u_device_rotation_right
 
const struct xrt_matrix_2x2 u_device_rotation_left
 
const struct xrt_matrix_2x2 u_device_rotation_ident
 
const struct xrt_matrix_2x2 u_device_rotation_180
 

Detailed Description

Function Documentation

◆ u_device_get_view_pose()

void u_device_get_view_pose ( const struct xrt_vec3 eye_relation,
uint32_t  view_index,
struct xrt_pose out_pose 
)

Helper function for get_view_pose in an HMD driver.

Takes in a translation from the left to right eye, and returns a center to left or right eye transform that assumes the eye relation is symmetrical around the tracked point ("center eye"). Knowing IPD is a subset of this: If you know IPD better than the overall Monado system, copy eye_relation and put your known IPD in real_eye_relation->x

If you have rotation, apply it after calling this function.

Parameters
eye_relation3D translation from left eye to right eye.
view_index0 for left, 1 for right.
out_poseThe output pose to populate. Will receive translation, with an identity rotation.

References xrt_pose::XRT_POSE_IDENTITY.

Referenced by u_device_get_view_poses().

◆ u_device_get_view_poses()

void u_device_get_view_poses ( struct xrt_device xdev,
const struct xrt_vec3 default_eye_relation,
uint64_t  at_timestamp_ns,
uint32_t  view_count,
struct xrt_space_relation out_head_relation,
struct xrt_fov out_fovs,
struct xrt_pose out_poses 
)