Monado OpenXR Runtime
vive_protocol.h
Go to the documentation of this file.
1// Copyright 2016-2019, Philipp Zabel
2// Copyright 2019, Collabora, Ltd.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Vive USB HID reports
7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
8 * @ingroup drv_vive
9 */
10
11#pragma once
12
13#include "os/os_hid.h"
14#include "xrt/xrt_byte_order.h"
15
16#include <stdint.h>
17
18#define VIVE_CONTROLLER_BUTTON_REPORT_ID 0x01
19
20#define VIVE_CONTROLLER_USB_BUTTON_TRIGGER (1 << 0)
21#define VIVE_CONTROLLER_USB_BUTTON_GRIP (1 << 2)
22#define VIVE_CONTROLLER_USB_BUTTON_MENU (1 << 12)
23#define VIVE_CONTROLLER_USB_BUTTON_SYSTEM (1 << 13)
24#define VIVE_CONTROLLER_USB_BUTTON_THUMB (1 << 18)
25#define VIVE_CONTROLLER_USB_BUTTON_TOUCH (1 << 20)
26
28{
29 uint8_t id;
30 uint8_t unknown1;
31 uint16_t maybe_type;
32 uint32_t sequence;
33 uint32_t buttons;
34 union {
35 uint16_t trigger;
36 uint16_t battery_voltage;
37 };
38 uint8_t battery;
39 uint8_t unknown2;
40 uint32_t hardware_id;
41 uint16_t touch[2];
42 uint16_t unknown3;
43 uint16_t trigger_hires;
44 uint8_t unknown4[24];
45 uint16_t trigger_raw;
46 uint8_t unknown5[8];
47 uint8_t maybe_bitfield;
48 uint8_t unknown6;
49} __attribute__((packed));
50
52{
53 uint16_t touch[2];
54} __attribute__((packed));
55
57{
58 uint8_t trigger;
59} __attribute__((packed));
60
62{
63 uint8_t buttons;
64} __attribute__((packed));
65
67{
68 uint8_t battery;
69} __attribute__((packed));
70
71#define VIVE_IMU_RANGE_MODES_REPORT_ID 0x01
72
74{
75 uint8_t id;
76 uint8_t gyro_range;
77 uint8_t accel_range;
78 uint8_t unknown[61];
79} __attribute__((packed));
80
81#define VIVE_MAINBOARD_STATUS_REPORT_ID 0x03
82
84{
85 uint8_t id;
86 uint16_t unknown;
87 uint8_t len;
88 uint16_t lens_separation;
89 uint16_t reserved1;
90 uint8_t button;
91 uint8_t audio_button;
92 uint8_t reserved2[2];
93 uint8_t proximity_change;
94 uint8_t reserved3;
95 uint16_t proximity;
96 uint16_t ipd;
97 uint8_t reserved4[46];
98} __attribute__((packed));
99
100#define VIVE_HEADSET_POWER_REPORT_ID 0x04
101
102#define VIVE_HEADSET_POWER_REPORT_TYPE 0x2978
103
105{
106 uint8_t id;
107 uint16_t type;
108 uint8_t len;
109 uint8_t unknown1[9];
110 uint8_t reserved1[32];
111 uint8_t unknown2;
112 uint8_t reserved2[18];
113} __attribute__((packed));
114
115#define VIVE_HEADSET_MAINBOARD_DEVICE_INFO_REPORT_ID 0x04
116
117#define VIVE_HEADSET_MAINBOARD_DEVICE_INFO_REPORT_TYPE 0x2987
118
120{
121 uint8_t id;
122 uint16_t type;
123 uint8_t len;
124 uint16_t edid_vid;
125 uint16_t edid_pid;
126 uint8_t unknown1[4];
127 uint32_t display_firmware_version;
128 uint8_t unknown2[48];
129} __attribute__((packed));
130
131#define VIVE_FIRMWARE_VERSION_REPORT_ID 0x05
132
134{
135 uint8_t id;
136 uint32_t firmware_version;
137 uint32_t unknown1;
138 uint8_t string1[16];
139 uint8_t string2[16];
140 uint8_t hardware_version_micro;
141 uint8_t hardware_version_minor;
142 uint8_t hardware_version_major;
143 uint8_t hardware_revision;
144 uint32_t unknown2;
145 uint8_t fpga_version_minor;
146 uint8_t fpga_version_major;
147 uint8_t reserved[13];
148} __attribute__((packed));
149
150#define VIVE_CONFIG_START_REPORT_ID 0x10
151
153{
154 uint8_t id;
155 uint8_t unused[63];
156} __attribute__((packed));
157
158#define VIVE_CONFIG_READ_REPORT_ID 0x11
159
161{
162 uint8_t id;
163 uint8_t len;
164 uint8_t payload[62];
165} __attribute__((packed));
166
167#define VIVE_IMU_REPORT_ID 0x20
168
170{
171 uint16_t acc[3];
172 uint16_t gyro[3];
173 uint32_t time;
174 uint8_t seq;
175} __attribute__((packed));
176
178{
179 uint8_t id;
180 struct vive_imu_sample sample[3];
181} __attribute__((packed));
182
184{
185 /* ouvrt: "Time in 48 MHz ticks, but we are missing the low byte."
186 *
187 * The full timestamp is 4 bytes, formed by
188 * first byte : vive_controller_message.timestamp_hi
189 * second byte: vive_controller_message.timestamp_lo
190 * third byte: watchman_imu_sample.timestamp_hi
191 * fourth byte: remains zero */
192 uint8_t timestamp_hi;
193 uint16_t acc[3];
194 uint16_t gyro[3];
195} __attribute__((packed));
196
197
198#define TYPE_FLAG_TOUCH_FORCE 161
200{
201 uint8_t type_flag;
202
203 uint8_t touch; // bitmask of touched buttons
204
205 // "distance" from hardware
206 uint8_t middle_finger_handle;
207 uint8_t ring_finger_handle;
208 uint8_t pinky_finger_handle;
209 uint8_t index_finger_trigger;
210
211 uint8_t squeeze_force;
212 uint8_t trackpad_force;
213} __attribute__((packed));
214
215#define VIVE_CONTROLLER_LIGHTHOUSE_PULSE_REPORT_ID 0x21
216
218{
219 uint16_t id;
220 uint16_t duration;
221 uint32_t timestamp;
222} __attribute__((packed));
223
225{
226 uint8_t id;
227 struct vive_controller_lighthouse_pulse pulse[7];
228 uint8_t reserved;
229} __attribute__((packed));
230
231#define VIVE_CONTROLLER_REPORT1_ID 0x23
232
233#define VIVE_CONTROLLER_BATTERY_CHARGING 0x80
234#define VIVE_CONTROLLER_BATTERY_CHARGE_MASK 0x7f
235
236#define VIVE_CONTROLLER_BUTTON_TRIGGER 0x01
237#define VIVE_CONTROLLER_BUTTON_TOUCH 0x02
238#define VIVE_CONTROLLER_BUTTON_THUMB 0x04
239#define VIVE_CONTROLLER_BUTTON_SYSTEM 0x08
240#define VIVE_CONTROLLER_BUTTON_GRIP 0x10
241#define VIVE_CONTROLLER_BUTTON_MENU 0x20
242
244{
245 uint8_t timestamp_hi;
246 uint8_t len;
247 uint8_t timestamp_lo;
248 uint8_t payload[26];
249} __attribute__((packed));
250
252{
253 uint8_t id;
254 struct vive_controller_message message;
255} __attribute__((packed));
256
257#define VIVE_CONTROLLER_REPORT2_ID 0x24
258
260{
261 uint8_t id;
262 struct vive_controller_message message[2];
263} __attribute__((packed));
264
265#define VIVE_HEADSET_LIGHTHOUSE_PULSE_REPORT_ID 0x25
266
268{
269 uint8_t sensor_id;
270 uint32_t timestamp;
271 uint32_t data;
272 uint32_t mask;
273} __attribute__((packed));
274
275#define VIVE_HEADSET_LIGHTHOUSE_V2_PULSE_REPORT_ID 0x27
276
278{
279 uint8_t id;
280 struct vive_headset_lighthouse_v2_pulse pulse[4];
281 /* Seen to be all values in range [0 - 53], related to triggered sensor (and
282 * imu?). */
283 uint8_t unknown1;
284 /* Always 0 */
285 uint8_t unknown2;
286 /* Always 0xde40daa */
287 uint32_t unknown3;
288
289} __attribute__((packed));
290
291#define VIVE_HEADSET_LIGHTHOUSE_V2_PULSE_RAW_REPORT_ID 0x28
292
294{
295 uint8_t unknown[64];
296} __attribute__((packed));
297
299{
300 uint8_t id;
301 uint16_t duration;
302 uint32_t timestamp;
303} __attribute__((packed));
304
306{
307 uint8_t id;
308 struct vive_headset_lighthouse_pulse pulse[9];
309} __attribute__((packed));
310
311#define VIVE_CONTROLLER_DISCONNECT_REPORT_ID 0x26
312
313#define VIVE_CONTROLLER_COMMAND_REPORT_ID 0xff
314
315#define VIVE_CONTROLLER_HAPTIC_PULSE_COMMAND 0x8f
316
318{
319 uint8_t id;
320 uint8_t command;
321 uint8_t len;
322 uint8_t zero;
323 uint16_t pulse_high;
324 uint16_t pulse_low;
325 uint16_t repeat_count;
326} __attribute__((packed));
327
328#define VIVE_CONTROLLER_POWEROFF_COMMAND 0x9f
329
331{
332 uint8_t id;
333 uint8_t command;
334 uint8_t len;
335 uint8_t magic[4];
336} __attribute__((packed));
337
338extern const struct vive_headset_power_report power_on_report;
339extern const struct vive_headset_power_report power_off_report;
340
341char *
342vive_read_config(struct os_hid_device *hid_dev);
343
344int
345vive_get_imu_range_report(struct os_hid_device *hid_dev, double *gyro_range, double *acc_range);
346
347int
348vive_read_firmware(struct os_hid_device *hid_dev,
349 uint32_t *firmware_version,
350 uint8_t *hardware_revision,
351 uint8_t *hardware_version_micro,
352 uint8_t *hardware_version_minor,
353 uint8_t *hardware_version_major);
Wrapper around OS native hid functions.
Representing a single hid interface on a device.
Definition: os_hid.h:29
Definition: vive_protocol.h:161
Definition: vive_protocol.h:153
Definition: vive_protocol.h:67
Definition: vive_protocol.h:28
Definition: vive_protocol.h:62
Definition: vive_protocol.h:318
Definition: vive_protocol.h:225
Definition: vive_protocol.h:218
Definition: vive_protocol.h:244
Definition: vive_protocol.h:331
Definition: vive_protocol.h:252
Definition: vive_protocol.h:260
Definition: vive_protocol.h:52
Definition: vive_protocol.h:57
Definition: vive_protocol.h:134
Definition: vive_protocol.h:306
Definition: vive_protocol.h:299
Definition: vive_protocol.h:294
Definition: vive_protocol.h:278
Definition: vive_protocol.h:268
Definition: vive_protocol.h:120
Definition: vive_protocol.h:105
Definition: vive_protocol.h:74
Definition: vive_protocol.h:178
Definition: vive_protocol.h:170
Definition: vive_protocol.h:84
Definition: vive_protocol.h:184
Definition: vive_protocol.h:200
Endian-specific byte order defines.