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

Razer Hydra 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_misc.h"
#include "util/u_time.h"
#include "os/os_hid.h"
#include "hydra_interface.h"
Include dependency graph for hydra_driver.c:

Data Structures

struct  hydra_controller_state
 
struct  hydra_state_machine
 The details of the Hydra state machine in a convenient package. More...
 
struct  hydra_system
 A Razer Hydra system containing two controllers. More...
 
struct  hydra_device
 A Razer Hydra device, representing just a single controller. More...
 

Macros

#define HYDRA_SPEW(p, ...)
 
#define HYDRA_DEBUG(p, ...)
 
#define HYDRA_ERROR(p, ...)
 
#define SET_INPUT(NAME)
 

Enumerations

enum  hydra_input_index {
  HYDRA_INDEX_1_CLICK, HYDRA_INDEX_2_CLICK, HYDRA_INDEX_3_CLICK, HYDRA_INDEX_4_CLICK,
  HYDRA_INDEX_MIDDLE_CLICK, HYDRA_INDEX_BUMPER_CLICK, HYDRA_INDEX_JOYSTICK_CLICK, HYDRA_INDEX_JOYSTICK_VALUE,
  HYDRA_INDEX_TRIGGER_VALUE, HYDRA_INDEX_POSE, HYDRA_MAX_CONTROLLER_INDEX
}
 
enum  hydra_button_bit {
  HYDRA_BUTTON_BIT_BUMPER = (1 << 0), HYDRA_BUTTON_BIT_3 = (1 << 1), HYDRA_BUTTON_BIT_1 = (1 << 2), HYDRA_BUTTON_BIT_2 = (1 << 3),
  HYDRA_BUTTON_BIT_4 = (1 << 4), HYDRA_BUTTON_BIT_MIDDLE = (1 << 5), HYDRA_BUTTON_BIT_JOYSTICK = (1 << 6)
}
 
enum  hydra_sm_state { HYDRA_SM_LISTENING_AFTER_CONNECT = 0, HYDRA_SM_LISTENING_AFTER_SET_FEATURE, HYDRA_SM_REPORTING }
 The states of the finite-state machine controlling the Hydra. More...
 

Functions

int hydra_found (struct xrt_prober *xp, struct xrt_prober_device **devices, size_t num_devices, size_t index, struct xrt_device **out_xdevs)
 Probing function for Razer Hydra devices. More...
 

Detailed Description

Razer Hydra prober and driver code.

Author
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

◆ HYDRA_DEBUG

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

◆ HYDRA_ERROR

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

◆ HYDRA_SPEW

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

◆ SET_INPUT

#define SET_INPUT (   NAME)
Value:
do { \
(hd->base.inputs[HYDRA_INDEX_##NAME].name = \
XRT_INPUT_HYDRA_##NAME); \
} while (0)

Enumeration Type Documentation

◆ hydra_sm_state

The states of the finite-state machine controlling the Hydra.