Monado OpenXR Runtime
psvr_device.h
Go to the documentation of this file.
1// Copyright 2016, Joey Ferwerda.
2// Copyright 2019, Collabora, Ltd.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief PSVR device header, imported from OpenHMD.
7 * @author Joey Ferwerda <joeyferweda@gmail.com>
8 * @author Philipp Zabel <philipp.zabel@gmail.com>
9 * @author Jakob Bornecrantz <jakob@collabora.com>
10 * @ingroup drv_psvr
11 */
12
13#pragma once
14
15#include "xrt/xrt_device.h"
16#include "xrt/xrt_prober.h"
17
18#include "util/u_logging.h"
19
20#include <hidapi.h>
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/*
29 *
30 * Defines
31 *
32 */
33
34#define PSVR_HANDLE_IFACE 4
35#define PSVR_CONTROL_IFACE 5
36
37enum psvr_status_bits
38{
39 // clang-format off
40 PSVR_STATUS_BIT_POWER = (1 << 0),
41 PSVR_STATUS_BIT_HMD_WORN = (1 << 1),
42 PSVR_STATUS_BIT_CINEMATIC_MODE = (1 << 2),
43 PSVR_STATUS_BIT_UNKNOWN_BIT_3 = (1 << 3),
44 PSVR_STATUS_BIT_HEADPHONES_CONNECTED = (1 << 4),
45 PSVR_STATUS_BIT_MUTE_ENABLED = (1 << 5),
46 PSVR_STATUS_BIT_UNKNOWN_BIT_6 = (1 << 6),
47 PSVR_STATUS_BIT_UNKNOWN_BIT_7 = (1 << 7),
48 // clang-format on
49};
50
51#define PSVR_STATUS_VR_MODE_OFF 0
52#define PSVR_STATUS_VR_MODE_ON 1
53
54#define PSVR_TICKS_PER_SECOND (1000000.0) // 1 MHz ticks
55#define PSVR_NS_PER_TICK (1000) // Each tick is a microsecond
56
57#define PSVR_PKG_STATUS 0xF0
58#define PSVR_PKG_DEVICE_NAME 0x80
59#define PSVR_PKG_CALIBRATION 0x86
60#define PSVR_PKG_0xA0 0xA0
61#define PSVR_PKG_0x82 0x82
62
63#define PSVR_GET_DATA_ID_DEVICE_NAME 0x80
64#define PSVR_GET_DATA_ID_CALIBRATION 0x86
65#define PSVR_GET_DATA_ID_0x82 0x82
66
67
68/*
69 *
70 * Structs
71 *
72 */
73
74struct xrt_tracked_psvr;
75
76/*!
77 * A parsed single gyro, accel and tick sample.
78 *
79 * @ingroup drv_psvr
80 */
82{
83 struct xrt_vec3_i32 accel;
84 struct xrt_vec3_i32 gyro;
85 uint32_t tick;
86};
87
88/*!
89 * Over the wire sensor packet from the headset.
90 *
91 * @ingroup drv_psvr
92 */
94{
95 uint8_t buttons;
96 uint8_t state;
97 uint16_t volume;
98 uint16_t button_raw;
99 uint16_t proximity;
100 uint8_t seq;
101
102 struct psvr_parsed_sample samples[2];
103};
104
105/*!
106 * A status packet from the headset in wire format.
107 *
108 * @ingroup drv_psvr
109 */
111{
112 uint8_t status;
113 uint8_t volume;
114 uint8_t display_time;
115 uint8_t vr_mode;
116};
117
118
119/*
120 *
121 * Functions
122 *
123 */
124
125struct xrt_device *
126psvr_device_create_auto_prober(struct hid_device_info *sensor_hid_info,
127 struct hid_device_info *control_hid_info,
128 struct xrt_tracked_psvr *tracker,
129 enum u_logging_level log_level);
130
131bool
132psvr_parse_sensor_packet(struct psvr_parsed_sensor *sensor, const uint8_t *buffer, int size);
133
134bool
135psvr_parse_status_packet(struct psvr_parsed_status *status, const uint8_t *buffer, int size);
136
137
138#ifdef __cplusplus
139}
140#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:43
A parsed single gyro, accel and tick sample.
Definition: psvr_device.h:82
Over the wire sensor packet from the headset.
Definition: psvr_device.h:94
A status packet from the headset in wire format.
Definition: psvr_device.h:111
A single HMD or input device.
Definition: xrt_device.h:241
A tracked PSVR headset.
Definition: xrt_tracking.h:260
A 3 element vector with 32 bit integers.
Definition: xrt_defines.h:336
Basic logging functionality.
Header defining an xrt display or controller device.
Common interface to probe for devices.