Monado OpenXR Runtime
Loading...
Searching...
No Matches
rift_interface.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 Interface to Oculus Rift driver code.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup drv_rift
8 */
9
10#pragma once
11
12#include "xrt/xrt_device.h"
13#include "xrt/xrt_defines.h"
14#include "xrt/xrt_prober.h"
15#include "xrt/xrt_frame.h"
16
18
19#include "util/u_time.h"
20
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
29struct rift_hmd;
30
31enum rift_variant
32{
33 RIFT_VARIANT_DK1,
34 RIFT_VARIANT_DK2,
35 RIFT_VARIANT_CV1,
36};
37
38#define OCULUS_VR_VID 0x2833
39
40#define OCULUS_DK2_PID 0x0021
41#define OCULUS_DK2_SENSOR_PID 0x0201
42#define OCULUS_CV1_PID 0x0031
43#define OCULUS_CV1_SENSOR_PID 0x0211
44
45#define RIFT_DK2_PRODUCT_STRING "Rift DK2"
46#define RIFT_CV1_PRODUCT_STRING "Rift CV1"
47
48/*!
49 * Checks whether the given device is an Oculus device, by checking the manufacturer string.
50 *
51 * @ingroup drv_rift
52 * @param xp The prober to use for getting string descriptors.
53 * @param dev The device to check.
54 * @return true if the device is an Oculus device, false otherwise.
55 */
56bool
57rift_is_oculus(struct xrt_prober *xp, struct xrt_prober_device *dev);
58
59/*!
60 * Probing function for Oculus Rift devices.
61 *
62 * @ingroup drv_rift
63 * @see xrt_prober_found_func_t
64 */
65int
66rift_found(struct xrt_prober *xp,
67 struct xrt_prober_device **devices,
68 size_t device_count,
69 size_t index,
70 cJSON *attached_data,
71 struct xrt_device **out_xdev);
72
73/*!
74 * Creates Rift HMD and related devices.
75 *
76 * @param hmd_dev The HID device for the HMD.
77 * @param radio_dev The HID device for the radio, if present (CV1 only).
78 * @param variant The Rift variant (DK2 or CV1).
79 * @param serial_number The serial number of the device.
80 * @param xfctx The frame context to use for the timing source functions. This is optional if you do not plan to
81 * use the Rift as a timing source.
82 * @param out_hmd Output pointer for the created rift_hmd struct.
83 * @param out_xdevs Output array for the created xrt_device pointers. The array must have space for at least 4
84 * devices (HMD, left touch, right touch, remote).
85 *
86 * @return The number of devices created, or a negative value on error.
87 */
88int
90 struct os_hid_device *radio_dev,
91 enum rift_variant variant,
92 const char *serial_number,
93 struct xrt_frame_context *xfctx,
94 struct rift_hmd **out_hmd,
95 struct xrt_device **out_xdevs);
96
97bool
98rift_get_radio_id(struct rift_hmd *hmd, uint8_t out_radio_id[5]);
99
100bool
101rift_hmd_frame_timestamp_callback(void *user_data, timepoint_ns *timestamp, uint32_t pts);
102
103int
104rift_add_to_constellation_tracker(struct rift_hmd *hmd, struct t_constellation_tracker *tracker);
105
106/*!
107 * Gets the HMD's timing event source.
108 *
109 * @param hmd The rift_hmd to get the timing event source from.
110 *
111 * @return The timing event source for the HMD, or NULL if the timing source is not initialized.
112 */
115
116/*!
117 * @dir drivers/rift
118 *
119 * @brief @ref drv_rift files.
120 */
121
122#ifdef __cplusplus
123}
124#endif
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
struct t_timing_event_source * rift_hmd_get_timing_event_source(struct rift_hmd *hmd)
Gets the HMD's timing event source.
Definition rift_driver.c:1174
int rift_found(struct xrt_prober *xp, struct xrt_prober_device **devices, size_t device_count, size_t index, cJSON *attached_data, struct xrt_device **out_xdev)
Probing function for Oculus Rift devices.
Definition rift_prober.c:48
bool rift_is_oculus(struct xrt_prober *xp, struct xrt_prober_device *dev)
Checks whether the given device is an Oculus device, by checking the manufacturer string.
Definition rift_prober.c:29
int rift_devices_create(struct os_hid_device *hmd_dev, struct os_hid_device *radio_dev, enum rift_variant variant, const char *serial_number, struct xrt_frame_context *xfctx, struct rift_hmd **out_hmd, struct xrt_device **out_xdevs)
Creates Rift HMD and related devices.
Definition rift_driver.c:683
Representing a single hid interface on a device.
Definition os_hid.h:29
A rift HMD device.
Definition rift_internal.h:895
A time sync source is a component that generates timing events for an t_timing_event_sink to consume.
Definition t_time_sync.h:102
A single HMD or input device.
Definition xrt_device.h:311
struct xrt_hmd_parts * hmd
Null if this device does not interface with the users head.
Definition xrt_device.h:323
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
A probed device, may or may not be opened.
Definition xrt_prober.h:88
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition xrt_prober.h:135
Header defining the constellation tracker parameters and functions.
Header defining interfaces for time synchronization in Monado.
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
Common defines and enums for XRT.
Header defining an xrt display or controller device.
Data frame header.
Common interface to probe for devices.