Monado OpenXR Runtime
ht_ctrl_emu.cpp File Reference

Driver to emulate controllers from hand-tracking input. More...

#include "xrt/xrt_defines.h"
#include "xrt/xrt_device.h"
#include "os/os_time.h"
#include "math/m_api.h"
#include "math/m_space.h"
#include "math/m_vec3.h"
#include "util/u_var.h"
#include "util/u_time.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_distortion_mesh.h"
#include "util/u_config_json.h"
#include "ht_ctrl_emu_interface.h"
#include <assert.h>
#include <stdio.h>
Include dependency graph for ht_ctrl_emu.cpp:

Data Structures

struct  cemu_system
 
struct  cemu_device
 

Macros

#define CEMU_TRACE(d, ...)   U_LOG_XDEV_IFL_T(&d->base, d->sys->log_level, __VA_ARGS__)
 
#define CEMU_DEBUG(d, ...)   U_LOG_XDEV_IFL_D(&d->base, d->sys->log_level, __VA_ARGS__)
 
#define CEMU_INFO(d, ...)   U_LOG_XDEV_IFL_I(&d->base, d->sys->log_level, __VA_ARGS__)
 
#define CEMU_WARN(d, ...)   U_LOG_XDEV_IFL_W(&d->base, d->sys->log_level, __VA_ARGS__)
 
#define CEMU_ERROR(d, ...)   U_LOG_XDEV_IFL_E(&d->base, d->sys->log_level, __VA_ARGS__)
 

Enumerations

enum  cemu_input_index {
  CEMU_INDEX_HAND_TRACKING , CEMU_INDEX_SELECT , CEMU_INDEX_MENU , CEMU_INDEX_GRIP ,
  CEMU_INDEX_AIM , CEMU_NUM_INPUTS
}
 

Functions

xrt_quat wct_to_quat (float waggle, float curl, float twist)
 
static struct cemu_devicecemu_device (struct xrt_device *xdev)
 
static void cemu_device_destroy (struct xrt_device *xdev)
 
static void cemu_device_get_hand_tracking (struct xrt_device *xdev, enum xrt_input_name name, uint64_t requested_timestamp_ns, struct xrt_hand_joint_set *out_value, uint64_t *out_timestamp_ns)
 
static xrt_vec3 joint_position_global (xrt_hand_joint_set *joint_set, xrt_hand_joint joint)
 
static xrt_pose joint_pose_global (xrt_hand_joint_set *joint_set, xrt_hand_joint joint)
 
static void do_grip_pose (struct xrt_hand_joint_set *joint_set, struct xrt_space_relation *out_relation, float grip_offset_from_palm, bool is_right)
 
static void get_other_two (struct cemu_device *dev, uint64_t head_timestamp_ns, uint64_t hand_timestamp_ns, xrt_pose *out_head, xrt_hand_joint_set *out_secondary)
 
static void do_aim_pose (struct cemu_device *dev, struct xrt_hand_joint_set *joint_set_primary, uint64_t head_timestamp_ns, uint64_t hand_timestamp_ns, struct xrt_space_relation *out_relation)
 
static void cemu_device_get_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, uint64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
 
static void cemu_device_set_output (struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value)
 
static void decide (xrt_vec3 one, xrt_vec3 two, bool *out)
 
static void cemu_device_update_inputs (struct xrt_device *xdev)
 
int cemu_devices_create (struct xrt_device *head, struct xrt_device *hands, struct xrt_device **out_xdevs)
 

Variables

static const float cm2m = 0.01f
 
static enum xrt_space_relation_flags valid_flags
 

Detailed Description

Driver to emulate controllers from hand-tracking input.

Author
Moses Turner moses.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Nick Klingensmith progr.nosp@m.amme.nosp@m.rpich.nosp@m.u@gm.nosp@m.ail.c.nosp@m.om

Function Documentation

◆ decide()

static void decide ( xrt_vec3  one,
xrt_vec3  two,
bool *  out 
)
static
Todo:
This is flickery; investigate once we get better hand tracking

Variable Documentation

◆ valid_flags

enum xrt_space_relation_flags valid_flags
static
Initial value:
XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT |
XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT)
xrt_space_relation_flags
Flags of which components of a xrt_space_relation is valid.
Definition: xrt_defines.h:629