Monado OpenXR Runtime
Data Structures | Macros | Enumerations | Functions
vive_controller_driver.c File Reference

Vive Controller prober and driver code. More...

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xrt/xrt_prober.h"
#include "math/m_api.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_json.h"
#include "util/u_misc.h"
#include "util/u_time.h"
#include "os/os_hid.h"
#include "os/os_threading.h"
#include "os/os_time.h"
#include "../vive/vive_protocol.h"
#include "vive_controller_interface.h"
#include "math/m_imu_3dof.h"
Include dependency graph for vive_controller_driver.c:

Data Structures

struct  vive_controller_device
 A Vive Controller device, representing just a single controller. More...
 

Macros

#define VIVE_CONTROLLER_SPEW(p, ...)
 
#define VIVE_CONTROLLER_DEBUG(p, ...)
 
#define VIVE_CONTROLLER_ERROR(p, ...)
 
#define VIVE_CLOCK_FREQ   48000000.0f
 
#define DEFAULT_HAPTIC_FREQ   150.0f
 
#define MIN_HAPTIC_DURATION   0.05f
 
#define FEATURE_BUFFER_SIZE   256
 
#define SET_WAND_INPUT(NAME, NAME2)
 
#define SET_INDEX_INPUT(NAME, NAME2)
 

Enumerations

enum  watchman_gen { WATCHMAN_GEN1, WATCHMAN_GEN2, WATCHMAN_GEN_UNKNOWN }
 
enum  controller_variant { CONTROLLER_VIVE_WAND, CONTROLLER_INDEX_LEFT, CONTROLLER_INDEX_RIGHT, CONTROLLER_UNKNOWN }
 

Functions

 DEBUG_GET_ONCE_BOOL_OPTION (vive_controller_spew, "VIVE_CONTROLLER_PRINT_SPEW", false)
 
int vive_controller_found (struct xrt_prober *xp, struct xrt_prober_device **devices, size_t num_devices, size_t index, cJSON *attached_data, struct xrt_device **out_xdevs)
 Probing function for HTC Vive and Valve Index devices. More...
 

Detailed Description

Vive Controller prober and driver code.

Author
Christoph Haag chris.nosp@m.toph.nosp@m..gaag.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Lubosz Sarnecki lubos.nosp@m.z.sa.nosp@m.rneck.nosp@m.i@co.nosp@m.llabo.nosp@m.ra.c.nosp@m.om
Ryan Pavlik ryan..nosp@m.pavl.nosp@m.ik@co.nosp@m.llab.nosp@m.ora.c.nosp@m.om
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Portions based on the VRPN Razer Hydra driver, originally written by Ryan Pavlik and available under the BSL-1.0.

Macro Definition Documentation

◆ DEFAULT_HAPTIC_FREQ

#define DEFAULT_HAPTIC_FREQ   150.0f

◆ FEATURE_BUFFER_SIZE

#define FEATURE_BUFFER_SIZE   256

◆ MIN_HAPTIC_DURATION

#define MIN_HAPTIC_DURATION   0.05f

◆ SET_INDEX_INPUT

#define SET_INDEX_INPUT (   NAME,
  NAME2 
)
Value:
do { \
(d->base.inputs[VIVE_CONTROLLER_INDEX_##NAME].name = \
XRT_INPUT_INDEX_##NAME2); \
} while (0)

◆ SET_WAND_INPUT

#define SET_WAND_INPUT (   NAME,
  NAME2 
)
Value:
do { \
(d->base.inputs[VIVE_CONTROLLER_INDEX_##NAME].name = \
XRT_INPUT_VIVE_##NAME2); \
} while (0)

◆ VIVE_CLOCK_FREQ

#define VIVE_CLOCK_FREQ   48000000.0f

◆ VIVE_CONTROLLER_DEBUG

#define VIVE_CONTROLLER_DEBUG (   p,
  ... 
)
Value:
do { \
if (p->print_debug) { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} \
} while (false)

Referenced by vive_controller_found().

◆ VIVE_CONTROLLER_ERROR

#define VIVE_CONTROLLER_ERROR (   p,
  ... 
)
Value:
do { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while (false)

Referenced by vive_controller_found().

◆ VIVE_CONTROLLER_SPEW

#define VIVE_CONTROLLER_SPEW (   p,
  ... 
)
Value:
do { \
if (p->print_spew) { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} \
} while (false)

Enumeration Type Documentation

◆ controller_variant

Enumerator
CONTROLLER_VIVE_WAND 
CONTROLLER_INDEX_LEFT 
CONTROLLER_INDEX_RIGHT 
CONTROLLER_UNKNOWN 

◆ watchman_gen

Enumerator
WATCHMAN_GEN1 
WATCHMAN_GEN2 
WATCHMAN_GEN_UNKNOWN 

Function Documentation

◆ DEBUG_GET_ONCE_BOOL_OPTION()

DEBUG_GET_ONCE_BOOL_OPTION ( vive_controller_spew  ,
"VIVE_CONTROLLER_PRINT_SPEW"  ,
false   
)

Referenced by oxr_sdl2_hack_stop().