Monado OpenXR Runtime
ovrd_driver.cpp File Reference

Main driver code for SteamVR driver provider. More...

#include <cstring>
#include <thread>
#include "math/m_api.h"
#include "ovrd_log.hpp"
#include "openvr_driver.h"
#include "ovrd_interface.h"
#include <math.h>
#include <math/m_space.h>
#include "os/os_time.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_builders.h"
#include "util/u_hand_tracking.h"
#include "xrt/xrt_space.h"
#include "xrt/xrt_system.h"
#include "xrt/xrt_defines.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_instance.h"
#include "bindings/b_generated_bindings.h"
#include "math/m_vec3.h"
Include dependency graph for ovrd_driver.cpp:

Data Structures

struct  MonadoInputComponent
 
struct  SteamVRDriverControl
 
struct  SteamVRDriverControlInput
 
struct  SteamVRDriverControlOutput
 
class  CDeviceDriver_Monado_Controller
 
class  CDeviceDriver_Monado
 
class  CServerDriver_Monado
 
class  CWatchdogDriver_Monado
 

Macros

#define MODELNUM_LEN   (XRT_DEVICE_NAME_LEN + 9)
 When set, all controllers pretend to be Index controllers. More...
 
#define OPENVR_BONE_COUNT   31
 
#define OPENVR_BONE_COUNT   31
 
#define NUM_XDEVS   16
 

Functions

static void copy_vec3 (struct xrt_vec3 *from, double *to)
 
static void copy_quat (struct xrt_quat *from, vr::HmdQuaternion_t *to)
 
static void apply_pose (struct xrt_space_relation *rel, vr::DriverPose_t *m_pose)
 
template<class T , class U >
void convert_quaternion (const T &p_quatA, U &p_quatB)
 
xrt_quat apply_bone_hand_transform (xrt_quat p_rot, xrt_hand hand)
 
void metacarpal_joints_to_bone_transform (struct xrt_hand_joint_set *hand_joint_set, vr::VRBoneTransform_t *out_bone_transforms, xrt_hand hand)
 
void flexion_joints_to_bone_transform (struct xrt_hand_joint_set *hand_joint_set, vr::VRBoneTransform_t *out_bone_transforms, xrt_hand hand)
 
void hand_joint_set_to_bone_transform (struct xrt_hand_joint_set hand_joint_set, vr::VRBoneTransform_t *out_bone_transforms, xrt_hand hand)
 
static void create_translation_rotation_matrix (struct xrt_pose *pose, struct vr::HmdMatrix34_t *res)
 
static vr::HmdQuaternion_t HmdQuaternion_Init (double w, double x, double y, double z)
 
void WatchdogThreadFunction ()
 
void * ovrd_hmd_driver_impl (const char *pInterfaceName, int *pReturnCode)
 Implementation of the HmdDriverFactory function. More...
 

Variables

vr::VRBoneTransform_t rightOpenPose [31]
 
vr::VRBoneTransform_t leftOpenPose [31]
 
CServerDriver_Monado g_serverDriverMonado
 
CWatchdogDriver_Monado g_watchdogDriverMonado
 
bool g_bExiting = false
 

Detailed Description

Macro Definition Documentation

◆ MODELNUM_LEN

#define MODELNUM_LEN   (XRT_DEVICE_NAME_LEN + 9)

When set, all controllers pretend to be Index controllers.

Provides best compatibility with legacy games due to steamvr's legacy binding for Index controllers, but input mapping may be incomplete or not ideal.

Function Documentation

◆ metacarpal_joints_to_bone_transform()

void metacarpal_joints_to_bone_transform ( struct xrt_hand_joint_set hand_joint_set,
vr::VRBoneTransform_t *  out_bone_transforms,
xrt_hand  hand 
)
  • if you try applying the metacarpal transforms without the magic quaternion, everything from the metacarpals onwards is rotated 90 degrees. In the neutral pose sample, all the metacarpals have a rotation relatively close to {w=0.5, x=0.5, y=-0.5, z=0.5} which is an Important Quaternion because it probably represents some 90 degree rotation. Maybe, and this was just a random guess, if I took the regular metacarpal orientations and rotated them by that quat, everything would work.