Monado OpenXR Runtime
|
Misc helpers for device drivers. More...
#include "util/u_logging.h"
#include "util/u_device.h"
#include "util/u_misc.h"
#include "math/m_mathinclude.h"
#include "math/m_api.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
Macros | |
#define | PRINT_STR(name, val) U_LOG_RAW("\t%s = %s", name, val) |
#define | PRINT_INT(name, val) U_LOG_RAW("\t%s = %u", name, val) |
#define | PRINT_MM(name, val) U_LOG_RAW("\t%s = %f (%i.%02imm)", name, val, (int32_t)(val * 1000.f), abs((int32_t)(val * 100000.f)) % 100) |
#define | PRINT_ANGLE(name, val) U_LOG_RAW("\t%s = %f (%i°)", name, val, (int32_t)(val * (180 / M_PI))) |
#define | PRINT_MAT2X2(name, rot) U_LOG_RAW("\t%s = {%f, %f} {%f, %f}", name, rot.v[0], rot.v[1], rot.v[2], rot.v[3]) |
#define | E(FN) U_LOG_E("Function " #FN " is not implemented for '%s'", xdev->str) |
Functions | |
void | u_device_dump_config (struct xrt_device *xdev, const char *prefix, const char *prod) |
Dump the device config to stderr. 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... | |
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... | |
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... | |
static void | try_move_assignment (struct xrt_device **xdevs, int *hand, int *other_hand) |
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, int64_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... | |
xrt_result_t | 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, int64_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... | |
xrt_result_t | u_device_ni_get_battery_status (struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge) |
Not implemented function for xrt_device::get_battery_status. 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 |
Misc helpers for device drivers.
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.
eye_relation | 3D translation from left eye to right eye. |
view_index | 0 for left, 1 for right. |
out_pose | The output pose to populate. Will receive translation, with an identity rotation. |
References xrt_pose::XRT_POSE_IDENTITY.
Referenced by u_device_get_view_poses().
void u_device_get_view_poses | ( | struct xrt_device * | xdev, |
const struct xrt_vec3 * | default_eye_relation, | ||
int64_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.
The field xrt_device::hmd needs to be set and valid.
References ARRAY_SIZE, xrt_hmd_parts::distortion, xrt_hmd_parts::fov, xrt_device::hmd, u_device_get_view_pose(), xrt_hmd_parts::views, xrt_device::xrt_device_get_tracked_pose(), and XRT_INPUT_GENERIC_HEAD_POSE.
Referenced by svr_hmd_get_view_poses().
const struct xrt_matrix_2x2 u_device_rotation_180 |
const struct xrt_matrix_2x2 u_device_rotation_ident |
const struct xrt_matrix_2x2 u_device_rotation_left |
const struct xrt_matrix_2x2 u_device_rotation_right |