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 
50 #define VIVE_IMU_RANGE_MODES_REPORT_ID 0x01
51 
53 {
54  uint8_t id;
55  uint8_t gyro_range;
56  uint8_t accel_range;
57  uint8_t unknown[61];
58 } __attribute__((packed));
59 
60 #define VIVE_MAINBOARD_STATUS_REPORT_ID 0x03
61 
63 {
64  uint8_t id;
65  uint16_t unknown;
66  uint8_t len;
67  uint16_t lens_separation;
68  uint16_t reserved1;
69  uint8_t button;
70  uint8_t reserved2[3];
72  uint8_t reserved3;
73  uint16_t proximity;
74  uint16_t ipd;
75  uint8_t reserved4[46];
76 } __attribute__((packed));
77 
78 #define VIVE_HEADSET_POWER_REPORT_ID 0x04
79 
80 #define VIVE_HEADSET_POWER_REPORT_TYPE 0x2978
81 
83 {
84  uint8_t id;
85  uint16_t type;
86  uint8_t len;
87  uint8_t unknown1[9];
88  uint8_t reserved1[32];
89  uint8_t unknown2;
90  uint8_t reserved2[18];
91 } __attribute__((packed));
92 
93 #define VIVE_HEADSET_MAINBOARD_DEVICE_INFO_REPORT_ID 0x04
94 
95 #define VIVE_HEADSET_MAINBOARD_DEVICE_INFO_REPORT_TYPE 0x2987
96 
98 {
99  uint8_t id;
100  uint16_t type;
101  uint8_t len;
102  uint16_t edid_vid;
103  uint16_t edid_pid;
104  uint8_t unknown1[4];
106  uint8_t unknown2[48];
107 } __attribute__((packed));
108 
109 #define VIVE_FIRMWARE_VERSION_REPORT_ID 0x05
110 
112 {
113  uint8_t id;
115  uint32_t unknown1;
116  uint8_t string1[16];
117  uint8_t string2[16];
122  uint32_t unknown2;
125  uint8_t reserved[13];
126 } __attribute__((packed));
127 
128 #define VIVE_CONFIG_START_REPORT_ID 0x10
129 
131 {
132  uint8_t id;
133  uint8_t unused[63];
134 } __attribute__((packed));
135 
136 #define VIVE_CONFIG_READ_REPORT_ID 0x11
137 
139 {
140  uint8_t id;
141  uint8_t len;
142  uint8_t payload[62];
143 } __attribute__((packed));
144 
145 #define VIVE_IMU_REPORT_ID 0x20
146 
148 {
149  uint16_t acc[3];
150  uint16_t gyro[3];
151  uint32_t time;
152  uint8_t seq;
153 } __attribute__((packed));
154 
156 {
157  uint8_t id;
159 } __attribute__((packed));
160 
161 #define VIVE_CONTROLLER_LIGHTHOUSE_PULSE_REPORT_ID 0x21
162 
164 {
165  uint16_t id;
166  uint16_t duration;
167  uint32_t timestamp;
168 } __attribute__((packed));
169 
171 {
172  uint8_t id;
174  uint8_t reserved;
175 } __attribute__((packed));
176 
177 #define VIVE_CONTROLLER_REPORT1_ID 0x23
178 
179 #define VIVE_CONTROLLER_BATTERY_CHARGING 0x80
180 #define VIVE_CONTROLLER_BATTERY_CHARGE_MASK 0x7f
181 
182 #define VIVE_CONTROLLER_BUTTON_TRIGGER 0x01
183 #define VIVE_CONTROLLER_BUTTON_TOUCH 0x02
184 #define VIVE_CONTROLLER_BUTTON_THUMB 0x04
185 #define VIVE_CONTROLLER_BUTTON_SYSTEM 0x08
186 #define VIVE_CONTROLLER_BUTTON_GRIP 0x10
187 #define VIVE_CONTROLLER_BUTTON_MENU 0x20
188 
190 {
191  uint8_t timestamp_hi;
192  uint8_t len;
193  uint8_t timestamp_lo;
194  uint8_t payload[26];
195 } __attribute__((packed));
196 
198 {
199  uint8_t id;
201 } __attribute__((packed));
202 
203 #define VIVE_CONTROLLER_REPORT2_ID 0x24
204 
206 {
207  uint8_t id;
209 } __attribute__((packed));
211 #define VIVE_HEADSET_LIGHTHOUSE_PULSE_REPORT_ID 0x25
214 {
215  uint8_t id;
216  uint16_t duration;
217  uint32_t timestamp;
218 } __attribute__((packed));
221 {
222  uint8_t id;
224 } __attribute__((packed));
226 #define VIVE_CONTROLLER_DISCONNECT_REPORT_ID 0x26
228 #define VIVE_CONTROLLER_COMMAND_REPORT_ID 0xff
229 
230 #define VIVE_CONTROLLER_HAPTIC_PULSE_COMMAND 0x8f
231 
233 {
234  uint8_t id;
235  uint8_t command;
236  uint8_t len;
237  uint8_t zero;
238  uint16_t pulse_high;
239  uint16_t pulse_low;
240  uint16_t repeat_count;
241 } __attribute__((packed));
242 
243 #define VIVE_CONTROLLER_POWEROFF_COMMAND 0x9f
244 
246 {
247  uint8_t id;
248  uint8_t command;
249  uint8_t len;
250  uint8_t magic[4];
251 } __attribute__((packed));
252 
255 
256 char *
257 vive_read_config(struct os_hid_device *hid_dev);
258 
259 int
261  double *gyro_range,
262  double *acc_range);
263 
264 int
265 vive_read_firmware(struct os_hid_device *hid_dev,
266  uint32_t *firmware_version,
267  uint8_t *hardware_revision,
268  uint8_t *hardware_version_micro,
269  uint8_t *hardware_version_minor,
270  uint8_t *hardware_version_major);
const struct vive_headset_power_report power_off_report
Definition: vive_protocol.h:254
uint8_t command
Definition: vive_protocol.h:248
uint16_t reserved1
Definition: vive_protocol.h:213
uint8_t id
Definition: vive_protocol.h:157
uint8_t reserved3
Definition: vive_protocol.h:72
uint16_t lens_separation
Definition: vive_protocol.h:67
uint8_t id
Definition: vive_protocol.h:64
int vive_read_firmware(struct os_hid_device *hid_dev, uint32_t *firmware_version, uint8_t *hardware_revision, uint8_t *hardware_version_micro, uint8_t *hardware_version_minor, uint8_t *hardware_version_major)
Definition: vive_protocol.c:208
uint16_t trigger
Definition: vive_protocol.h:34
uint8_t gyro_range
Definition: vive_protocol.h:210
Definition: vive_protocol.h:163
uint8_t hardware_version_micro
Definition: vive_protocol.h:118
Definition: vive_protocol.h:111
uint8_t len
Definition: vive_protocol.h:101
uint16_t reserved1
Definition: vive_protocol.h:68
uint16_t maybe_type
Definition: vive_protocol.h:30
Definition: vive_protocol.h:205
uint16_t unknown
Definition: vive_protocol.h:65
uint16_t touch[2]
Definition: vive_protocol.h:40
uint8_t fpga_version_major
Definition: vive_protocol.h:124
uint8_t hardware_version_minor
Definition: vive_protocol.h:119
int vive_get_imu_range_report(struct os_hid_device *hid_dev, double *gyro_range, double *acc_range)
Definition: vive_protocol.c:150
uint8_t id
Definition: vive_protocol.h:28
Definition: vive_protocol.h:245
uint32_t time
Definition: vive_protocol.h:151
Definition: vive_protocol.h:170
uint8_t command
Definition: vive_protocol.h:235
uint8_t timestamp_hi
Definition: vive_protocol.h:191
uint8_t hardware_version_major
Definition: vive_protocol.h:216
uint32_t timestamp
Definition: vive_protocol.h:167
uint8_t zero
Definition: vive_protocol.h:237
uint8_t id
Definition: vive_protocol.h:172
Definition: vive_protocol.h:130
Definition: vive_protocol.h:52
uint8_t unknown5[8]
Definition: vive_protocol.h:45
uint8_t accel_range
Definition: vive_protocol.h:56
uint8_t proximity_change
Definition: vive_protocol.h:71
uint8_t id
Definition: vive_protocol.h:132
uint8_t reserved[13]
Definition: vive_protocol.h:221
Definition: vive_protocol.h:97
uint8_t hardware_revision
Definition: vive_protocol.h:121
uint8_t unused[63]
Definition: vive_protocol.h:210
uint8_t reserved2[3]
Definition: vive_protocol.h:215
uint8_t id
Definition: vive_protocol.h:247
uint32_t firmware_version
Definition: vive_protocol.h:210
Definition: vive_protocol.h:138
Definition: vive_protocol.h:197
uint8_t id
Definition: vive_protocol.h:234
uint32_t unknown1
Definition: vive_protocol.h:115
Definition: vive_protocol.h:26
uint16_t id
Definition: vive_protocol.h:165
uint32_t timestamp
Definition: vive_protocol.h:211
uint8_t id
Definition: vive_protocol.h:140
uint8_t id
Definition: vive_protocol.h:54
Definition: vive_protocol.h:82
char * vive_read_config(struct os_hid_device *hid_dev)
Definition: vive_protocol.c:70
Definition: vive_protocol.h:147
uint32_t sequence
Definition: vive_protocol.h:31
uint8_t len
Definition: vive_protocol.h:86
uint8_t string1[16]
Definition: vive_protocol.h:212
uint8_t fpga_version_minor
Definition: vive_protocol.h:123
uint16_t repeat_count
Definition: vive_protocol.h:240
Definition: vive_protocol.h:213
uint8_t unknown[61]
Definition: vive_protocol.h:212
uint16_t pulse_high
Definition: vive_protocol.h:238
uint8_t timestamp_lo
Definition: vive_protocol.h:193
uint8_t maybe_bitfield
Definition: vive_protocol.h:46
uint8_t id
Definition: vive_protocol.h:113
Definition: vive_protocol.h:232
uint8_t len
Definition: vive_protocol.h:141
uint8_t unknown4[24]
Definition: vive_protocol.h:43
Definition: vive_protocol.h:220
uint8_t string2[16]
Definition: vive_protocol.h:213
uint8_t len
Definition: vive_protocol.h:249
uint8_t hardware_version_micro
Definition: vive_protocol.h:214
uint16_t type
Definition: vive_protocol.h:85
uint8_t unknown2
Definition: vive_protocol.h:89
uint8_t id
Definition: vive_protocol.h:99
uint8_t reserved
Definition: vive_protocol.h:174
uint16_t duration
Definition: vive_protocol.h:166
uint16_t gyro[3]
Definition: vive_protocol.h:210
uint16_t trigger_raw
Definition: vive_protocol.h:44
uint16_t edid_pid
Definition: vive_protocol.h:103
uint16_t ipd
Definition: vive_protocol.h:74
Representing a single hid interface on a device.
Definition: os_hid.h:26
uint16_t pulse_low
Definition: vive_protocol.h:239
uint8_t button
Definition: vive_protocol.h:69
uint32_t firmware_version
Definition: vive_protocol.h:114
struct vive_imu_sample sample[3]
Definition: vive_protocol.h:210
uint32_t hardware_id
Definition: vive_protocol.h:39
const struct vive_headset_power_report power_on_report
Definition: vive_protocol.h:253
struct vive_controller_lighthouse_pulse pulse[7]
Definition: vive_protocol.h:210
uint8_t battery
Definition: vive_protocol.h:37
uint16_t duration
Definition: vive_protocol.h:210
uint8_t magic[4]
Definition: vive_protocol.h:212
uint8_t len
Definition: vive_protocol.h:66
uint16_t type
Definition: vive_protocol.h:100
uint8_t id
Definition: vive_protocol.h:199
uint32_t display_firmware_version
Definition: vive_protocol.h:105
uint8_t hardware_version_minor
Definition: vive_protocol.h:215
uint8_t gyro_range
Definition: vive_protocol.h:55
Definition: vive_protocol.h:189
uint8_t len
Definition: vive_protocol.h:236
uint8_t id
Definition: vive_protocol.h:207
Definition: vive_protocol.h:155
uint8_t seq
Definition: vive_protocol.h:152
uint8_t payload[62]
Definition: vive_protocol.h:211
uint16_t proximity
Definition: vive_protocol.h:73
uint8_t unknown2
Definition: vive_protocol.h:38
uint16_t acc[3]
Definition: vive_protocol.h:209
uint8_t hardware_version_major
Definition: vive_protocol.h:120
struct vive_controller_message message
Definition: vive_protocol.h:210
uint32_t buttons
Definition: vive_protocol.h:32
uint16_t trigger_hires
Definition: vive_protocol.h:42
uint8_t hardware_revision
Definition: vive_protocol.h:217
uint8_t unknown1
Definition: vive_protocol.h:29
Wrapper around OS native hid functions.
uint8_t len
Definition: vive_protocol.h:192
uint16_t edid_vid
Definition: vive_protocol.h:102
uint8_t unknown6
Definition: vive_protocol.h:47
uint16_t unknown3
Definition: vive_protocol.h:41
uint8_t id
Definition: vive_protocol.h:84
uint16_t battery_voltage
Definition: vive_protocol.h:35
union vive_controller_button_report::@79 __attribute__
uint32_t unknown2
Definition: vive_protocol.h:122
Definition: vive_protocol.h:62
uint8_t reserved4[46]
Definition: vive_protocol.h:220