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