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_DK2,
34 RIFT_VARIANT_CV1,
35};
36
37#define OCULUS_VR_VID 0x2833
38
39#define OCULUS_DK2_PID 0x0021
40#define OCULUS_DK2_SENSOR_PID 0x0201
41#define OCULUS_CV1_PID 0x0031
42#define OCULUS_CV1_SENSOR_PID 0x0211
43
44#define RIFT_DK2_PRODUCT_STRING "Rift DK2"
45#define RIFT_CV1_PRODUCT_STRING "Rift CV1"
46
47/*!
48 * Creates Rift HMD and related devices.
49 *
50 * @param hmd_dev The HID device for the HMD.
51 * @param radio_dev The HID device for the radio, if present (CV1 only).
52 * @param variant The Rift variant (DK2 or CV1).
53 * @param serial_number The serial number of the device.
54 * @param xfctx The frame context to use for the timing source functions. Non-optional.
55 * @param out_hmd Output pointer for the created rift_hmd struct.
56 * @param out_xdevs Output array for the created xrt_device pointers. The array must have space for at least 4
57 * devices (HMD, left touch, right touch, remote).
58 *
59 * @return The number of devices created, or a negative value on error.
60 */
61int
63 struct os_hid_device *radio_dev,
64 enum rift_variant variant,
65 const char *serial_number,
66 struct xrt_frame_context *xfctx,
67 struct rift_hmd **out_hmd,
68 struct xrt_device **out_xdevs);
69
70bool
71rift_get_radio_id(struct rift_hmd *hmd, uint8_t out_radio_id[5]);
72
73/*!
74 * Timestamps a camera frame with the time of the exposure that produced it, which is taken to be the exposure whose
75 * IN report arrived within half a frame interval of one whole frame interval before the frame's first packet.
76 *
77 * @param user_data The @ref rift_hmd whose exposures the frame is matched against.
78 * @param[out] timestamp Where the exposure time is written, only touched when this returns true.
79 * @param frame_start_ns When the frame's first payload packet arrived, in local monotonic time.
80 * @param pts The PTS of the frame, in the camera's own clock. Only used for logging.
81 *
82 * @return True when an exposure time was written. False when no exposure lines up with the frame, in which case the
83 * caller should keep whatever timestamp it already had.
84 */
85bool
86rift_hmd_frame_timestamp_callback(void *user_data, timepoint_ns *timestamp, timepoint_ns frame_start_ns, uint32_t pts);
87
88int
89rift_add_to_constellation_tracker(struct rift_hmd *hmd, struct t_constellation_tracker *tracker);
90
91/*!
92 * Gets the HMD's timing event source.
93 *
94 * @param hmd The rift_hmd to get the timing event source from.
95 *
96 * @return The timing event source for the HMD, or NULL if the timing source is not initialized.
97 */
100
101/*!
102 * @dir drivers/rift
103 *
104 * @brief @ref drv_rift files.
105 */
106
107#ifdef __cplusplus
108}
109#endif
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
bool rift_hmd_frame_timestamp_callback(void *user_data, timepoint_ns *timestamp, timepoint_ns frame_start_ns, uint32_t pts)
Timestamps a camera frame with the time of the exposure that produced it, which is taken to be the ex...
Definition rift_driver.c:1315
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:1403
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:849
Representing a single hid interface on a device.
Definition os_hid.h:29
A rift HMD device.
Definition rift_internal.h:918
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:341
struct xrt_hmd_parts * hmd
Null if this device does not interface with the users head.
Definition xrt_device.h:356
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
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.