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