Monado OpenXR Runtime
Loading...
Searching...
No Matches
vp2_hid.h
Go to the documentation of this file.
1// Copyright 2025, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of the Vive Pro 2 HID interface.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup drv_vp2
8 */
9
10#pragma once
11
12#include "xrt/xrt_defines.h"
13
14#include "os/os_hid.h"
15
16#include <assert.h>
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23
24#define VP2_VID 0x0bb4
25#define VP2_PID 0x0342
26
27enum vp2_resolution
28{
29 VP2_RESOLUTION_2448_1224_90_03 = 0,
30 VP2_RESOLUTION_2448_1224_120_05 = 1,
31 VP2_RESOLUTION_3264_1632_90_00 = 2,
32 VP2_RESOLUTION_3680_1836_90_02 = 3,
33 VP2_RESOLUTION_4896_2448_90_02 = 4,
34 VP2_RESOLUTION_4896_2448_120_02 = 5,
35};
36
37static inline void
38vp2_resolution_get_extents(enum vp2_resolution res, int *out_w, int *out_h)
39{
40 switch (res) {
41 case VP2_RESOLUTION_2448_1224_90_03:
42 case VP2_RESOLUTION_2448_1224_120_05:
43 *out_w = 2448;
44 *out_h = 1224;
45 break;
46 case VP2_RESOLUTION_3264_1632_90_00:
47 *out_w = 3264;
48 *out_h = 1632;
49 break;
50 case VP2_RESOLUTION_3680_1836_90_02:
51 *out_w = 3680;
52 *out_h = 1836;
53 break;
54 case VP2_RESOLUTION_4896_2448_90_02:
55 case VP2_RESOLUTION_4896_2448_120_02:
56 *out_w = 4896;
57 *out_h = 2448;
58 break;
59 default:
60 assert(!"unreachable: bad resolution");
61 *out_w = 0;
62 *out_h = 0;
63 break;
64 }
65}
66
67static inline double
68vp2_resolution_get_refresh_rate(enum vp2_resolution res)
69{
70 switch (res) {
71 case VP2_RESOLUTION_2448_1224_90_03: return 90.03;
72 case VP2_RESOLUTION_2448_1224_120_05: return 120.05;
73 case VP2_RESOLUTION_3264_1632_90_00: return 90.0;
74 case VP2_RESOLUTION_3680_1836_90_02:
75 case VP2_RESOLUTION_4896_2448_90_02: return 90.02;
76 case VP2_RESOLUTION_4896_2448_120_02: return 120.02;
77 default: assert(!"unreachable: bad resolution"); return 0.0;
78 }
79}
80
81struct vp2_hid;
82
83int
84vp2_hid_open(struct os_hid_device *hid_dev, struct vp2_hid **out_hid);
85
86enum vp2_resolution
87vp2_get_resolution(struct vp2_hid *vp2);
88
89struct vp2_config *
90vp2_get_config(struct vp2_hid *vpd);
91
92void
93vp2_hid_destroy(struct vp2_hid *vp2);
94
95const char *
96vp2_get_serial(struct vp2_hid *vp2);
97
98int
99vp2_set_noise_cancelling(struct vp2_hid *vp2, bool enabled);
100
101float
102vp2_get_brightness(struct vp2_hid *vp2);
103
104int
105vp2_set_brightness(struct vp2_hid *vp2, float brightness);
106
107/*!
108 * Prepares the display panels to have video terminated.
109 */
110int
111vp2_prepare_shutdown(struct vp2_hid *vp2);
112
113bool
114vp2_get_status(struct vp2_hid *vp2,
115 bool *out_proximity,
116 float *out_lens_separation_meters,
117 bool *out_system,
118 bool *out_volume_up,
119 bool *out_volume_down,
120 bool *out_mute_mic);
121
122
123#ifdef __cplusplus
124} // extern "C"
125#endif
Wrapper around OS native hid functions.
Representing a single hid interface on a device.
Definition os_hid.h:29
Definition vp2_config.h:23
Definition vp2_hid.c:45
int vp2_prepare_shutdown(struct vp2_hid *vp2)
Prepares the display panels to have video terminated.
Definition vp2_hid.c:955
Common defines and enums for XRT.