Monado OpenXR Runtime
vive_controller.h
Go to the documentation of this file.
1// Copyright 2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Interface to @ref drv_vive
6 * @author Christoph Haag <christoph.haag@collabora.com>
7 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @ingroup drv_vive
9 */
10
11#pragma once
12
13#include <stdlib.h>
14#include <stdint.h>
15
16#include "xrt/xrt_device.h"
17#include "os/os_threading.h"
18#include "math/m_imu_3dof.h"
19#include "util/u_logging.h"
21#include "vive/vive_config.h"
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27/*!
28 * @ingroup drv_vive
29 *
30 * @brief Driver for the HTC Vive and Valve Index controllers.
31 */
32
34{
35 WATCHMAN_GEN1,
36 WATCHMAN_GEN2,
37 WATCHMAN_GEN_UNKNOWN
38};
39
40/*!
41 * A Vive Controller device, representing just a single controller.
42 *
43 * @ingroup drv_vive
44 * @implements xrt_device
45 */
47{
48 struct xrt_device base;
49
50 struct os_hid_device *controller_hid;
51 struct os_thread_helper controller_thread;
52 struct os_mutex lock;
53
54 struct
55 {
56 timepoint_ns last_sample_ts_ns;
57 uint32_t last_sample_ticks;
58 } imu;
59
60 struct
61 {
62 struct u_var_button reset_pose_btn;
63 } gui;
64
65 // struct m_imu_3dof fusion;
66 struct
67 {
68 //! Protects all members of the `fusion` substruct.
70
71 //! Main fusion calculator.
73
74 //! Prediction
76 } fusion;
77
78 struct
79 {
80 struct xrt_vec3 acc;
81 struct xrt_vec3 gyro;
82 } last;
83
84 enum u_logging_level log_level;
85
86 uint32_t last_ticks;
87
88 //! Which vive controller in the system are we?
89 size_t index;
90
91 struct
92 {
93 struct xrt_vec2 trackpad;
94 float trigger;
95 uint8_t buttons;
96 uint8_t last_buttons;
97
98 uint8_t touch;
99 uint8_t last_touch;
100
101 uint8_t middle_finger_handle;
102 uint8_t ring_finger_handle;
103 uint8_t pinky_finger_handle;
104 uint8_t index_finger_trigger;
105
106 uint8_t squeeze_force;
107 uint8_t trackpad_force;
108
109 bool charging;
110 uint8_t battery;
111 } state;
112
114
115 struct u_hand_tracking hand_tracking;
116
117 struct vive_controller_config config;
118
119 //! Last tracked pose
121
122 //! Additional offset to apply to `pose`
124};
125
127vive_controller_create(struct os_hid_device *controller_hid, enum watchman_gen watchman_gen, int controller_num);
128
129#ifdef __cplusplus
130}
131#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:43
int64_t timepoint_ns
Integer timestamp type.
Definition: u_time.h:70
watchman_gen
Driver for the HTC Vive and Valve Index controllers.
Definition: vive_controller.h:34
A IMU fusion specially made for 3dof devices.
Wrapper around OS threading native functions.
Definition: m_imu_3dof.h:35
Definition: m_relation_history.cpp:46
Representing a single hid interface on a device.
Definition: os_hid.h:29
A wrapper around a native mutex.
Definition: os_threading.h:55
All in one helper that handles locking, waiting for change and starting a thread.
Definition: os_threading.h:453
Main struct drivers can use to implement hand and finger tracking.
Definition: u_hand_tracking.h:93
Simple pushable button.
Definition: u_var.h:79
Controller config.
Definition: vive_config.h:220
A Vive Controller device, representing just a single controller.
Definition: vive_controller.h:47
size_t index
Which vive controller in the system are we?
Definition: vive_controller.h:89
struct os_mutex mutex
Protects all members of the fusion substruct.
Definition: vive_controller.h:69
struct m_relation_history * relation_hist
Prediction.
Definition: vive_controller.h:75
struct xrt_pose offset
Additional offset to apply to pose
Definition: vive_controller.h:123
struct m_imu_3dof i3dof
Main fusion calculator.
Definition: vive_controller.h:72
struct xrt_pose pose
Last tracked pose.
Definition: vive_controller.h:120
A single HMD or input device.
Definition: xrt_device.h:241
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
A 2 element vector with single floats.
Definition: xrt_defines.h:250
A 3 element vector with single floats.
Definition: xrt_defines.h:271
Hand Tracking API interface.
Basic logging functionality.
vive json header
Header defining an xrt display or controller device.