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
13#include <assert.h>
14
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20
21#define VP2_VID 0x0bb4
22#define VP2_PID 0x0342
23
24enum vp2_resolution
25{
26 VP2_RESOLUTION_2448_1224_90_03 = 0,
27 VP2_RESOLUTION_2448_1224_120_05 = 1,
28 VP2_RESOLUTION_3264_1632_90_00 = 2,
29 VP2_RESOLUTION_3680_1836_90_02 = 3,
30 VP2_RESOLUTION_4896_2448_90_02 = 4,
31 VP2_RESOLUTION_4896_2448_120_02 = 5,
32};
33
34static inline void
35vp2_resolution_get_extents(enum vp2_resolution res, int *out_w, int *out_h)
36{
37 switch (res) {
38 case VP2_RESOLUTION_2448_1224_90_03:
39 case VP2_RESOLUTION_2448_1224_120_05:
40 *out_w = 2448;
41 *out_h = 1224;
42 break;
43 case VP2_RESOLUTION_3264_1632_90_00:
44 *out_w = 3264;
45 *out_h = 1632;
46 break;
47 case VP2_RESOLUTION_3680_1836_90_02:
48 *out_w = 3680;
49 *out_h = 1836;
50 break;
51 case VP2_RESOLUTION_4896_2448_90_02:
52 case VP2_RESOLUTION_4896_2448_120_02:
53 *out_w = 4896;
54 *out_h = 2448;
55 break;
56 default:
57 assert(!"unreachable: bad resolution");
58 *out_w = 0;
59 *out_h = 0;
60 break;
61 }
62}
63
64static inline double
65vp2_resolution_get_refresh_rate(enum vp2_resolution res)
66{
67 switch (res) {
68 case VP2_RESOLUTION_2448_1224_90_03: return 90.03;
69 case VP2_RESOLUTION_2448_1224_120_05: return 120.05;
70 case VP2_RESOLUTION_3264_1632_90_00: return 90.0;
71 case VP2_RESOLUTION_3680_1836_90_02:
72 case VP2_RESOLUTION_4896_2448_90_02: return 90.02;
73 case VP2_RESOLUTION_4896_2448_120_02: return 120.02;
74 default: assert(!"unreachable: bad resolution"); return 0.0;
75 }
76}
77
78struct vp2_hid;
79
80int
81vp2_hid_open(struct os_hid_device *hid_dev, struct vp2_hid **out_hid);
82
83enum vp2_resolution
84vp2_get_resolution(struct vp2_hid *vp2);
85
86struct vp2_config *
87vp2_get_config(struct vp2_hid *vpd);
88
89void
90vp2_hid_destroy(struct vp2_hid *vp2);
91
92const char *
93vp2_get_serial(struct vp2_hid *vp2);
94
95int
96vp2_set_noise_cancelling(struct vp2_hid *vp2, bool enabled);
97
98float
99vp2_get_brightness(struct vp2_hid *vp2);
100
101int
102vp2_set_brightness(struct vp2_hid *vp2, float brightness);
103
104
105#ifdef __cplusplus
106} // extern "C"
107#endif
Representing a single hid interface on a device.
Definition os_hid.h:29
Definition vp2_config.h:99
Definition vp2_hid.c:40