Monado OpenXR Runtime
Loading...
Searching...
No Matches
target_builder_helpers.h
Go to the documentation of this file.
1// Copyright 2022-2023, Collabora, Ltd.
2// Copyright 2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Helpers for @ref xrt_builder implementations.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup xrt_iface
9 */
10
11#pragma once
12
13#include "xrt/xrt_space.h"
14#include "xrt/xrt_prober.h"
15#include "xrt/xrt_system.h"
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
23
24
25/*!
26 * Argument to @ref t_builder_roles_helper_open_system and implemented by
27 * @ref t_builder::open_system_static_roles function.
28 *
29 * A builder implement this function is free to focus on only creating the
30 * devices and assigning them initial roles. With this implementation details
31 * of the @ref xrt_system_devices and @ref xrt_space_overseer is taken care of
32 * by the caller of this function.
33 *
34 * @todo `tbo` should be a true `out` parameter, rather than being a structure with defaults filled in.
35 *
36 * @ingroup xrt_iface
37 */
39 cJSON *config,
40 struct xrt_prober *xp,
41 struct xrt_tracking_origin *origin,
42 struct xrt_system_devices *xsysd,
43 struct xrt_frame_context *xfctx,
44 struct t_builder_options *tbo);
45
46/*!
47 * This small helper struct is for @ref t_builder_roles_helper_open_system,
48 * lets a builder focus on opening devices rather then dealing with Monado
49 * structs like @ref xrt_system_devices and the like.
50 *
51 * @ingroup xrt_iface
52 */
54{
55 //! The offset from stage -> local space, defaulting to a 1.6m height adjustment.
57
58 struct xrt_device *head;
59 struct xrt_device *eyes;
60 struct xrt_device *face;
61 struct xrt_device *left;
62 struct xrt_device *right;
63 struct xrt_device *gamepad;
64
65 struct
66 {
67 struct
68 {
69 struct xrt_device *left;
70 struct xrt_device *right;
71 } unobstructed;
72
73 struct
74 {
75 struct xrt_device *left;
76 struct xrt_device *right;
77 } conforming;
78 } hand_tracking;
79};
80
81/*!
82 * This helper struct makes it easier to implement the builder interface, but it
83 * also comes with a set of integration that may not be what all builders want.
84 * See the below functions for more information.
85 *
86 * * @ref t_builder_open_system_static_roles
87 * * @ref t_builder_roles_helper_open_system
88 *
89 * @ingroup xrt_iface
90 */
92{
93 //! Base for this struct.
95
96 /*!
97 * @copydoc t_builder_open_system_fn
98 */
100};
101
102
103/*
104 *
105 * Functions.
106 *
107 */
108
109/*!
110 * Create a legacy space overseer, most builders probably want to have a more
111 * advanced setup then this, especially stand alone ones. Uses
112 * @ref u_builder_setup_tracking_origins internally and
113 * @ref b_space_overseer_legacy_setup.
114 *
115 * @ingroup xrt_iface
116 */
117void
119 struct xrt_device *head,
120 struct xrt_device *eyes,
121 struct xrt_device *left,
122 struct xrt_device *right,
123 struct xrt_device *gamepad,
124 struct xrt_device **xdevs,
125 uint32_t xdev_count,
126 bool root_is_unbounded,
127 const struct xrt_pose *T_stage_local,
128 bool per_app_local_spaces,
129 struct xrt_space_overseer **out_xso);
130
131/*!
132 * Helper to create a system devices that has static roles and a appropriate
133 * space overseer. Currently uses the functions below to create a full system
134 * with the help of @p fn argument. But this might change in the future.
135 *
136 * * @ref b_system_devices_static_allocate
137 * * @ref b_system_devices_static_finalize
138 * * @ref t_builder_create_space_overseer_legacy
139 *
140 * @ingroup xrt_iface
141 */
144 cJSON *config,
145 struct xrt_prober *xp,
146 struct xrt_session_event_sink *broadcast,
147 struct xrt_system_devices **out_xsysd,
148 struct xrt_space_overseer **out_xso,
150
151/*!
152 * Implementation for xrt_builder::open_system to be used with @ref t_builder.
153 * Uses @ref t_builder_roles_helper_open_system internally, a builder that uses
154 * the @ref t_builder should use this function for xrt_builder::open_system.
155 *
156 * When using this function the builder must have @ref t_builder and implement
157 * the @ref t_builder::open_system_static_roles function, see documentation for
158 * @ref t_builder_open_system_fn about requirements.
159 *
160 * @ingroup xrt_iface
161 */
164 cJSON *config,
165 struct xrt_prober *xp,
166 struct xrt_session_event_sink *broadcast,
167 struct xrt_system_devices **out_xsysd,
168 struct xrt_space_overseer **out_xso);
169
170
171#ifdef __cplusplus
172}
173#endif
xrt_result_t t_builder_roles_helper_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso, t_builder_open_system_fn fn)
Helper to create a system devices that has static roles and a appropriate space overseer.
Definition target_builder_helpers.c:89
xrt_result_t(* t_builder_open_system_fn)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_tracking_origin *origin, struct xrt_system_devices *xsysd, struct xrt_frame_context *xfctx, struct t_builder_options *tbo)
Argument to t_builder_roles_helper_open_system and implemented by t_builder::open_system_static_roles...
Definition target_builder_helpers.h:38
void t_builder_create_space_overseer_legacy(struct xrt_session_event_sink *broadcast, struct xrt_device *head, struct xrt_device *eyes, struct xrt_device *left, struct xrt_device *right, struct xrt_device *gamepad, struct xrt_device **xdevs, uint32_t xdev_count, bool root_is_unbounded, const struct xrt_pose *T_stage_local, bool per_app_local_spaces, struct xrt_space_overseer **out_xso)
Create a legacy space overseer, most builders probably want to have a more advanced setup then this,...
Definition target_builder_helpers.c:37
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_result_t t_builder_open_system_static_roles(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
Implementation for xrt_builder::open_system to be used with t_builder.
Definition target_builder_helpers.c:174
This small helper struct is for t_builder_roles_helper_open_system, lets a builder focus on opening d...
Definition target_builder_helpers.h:54
struct xrt_pose T_stage_local
The offset from stage -> local space, defaulting to a 1.6m height adjustment.
Definition target_builder_helpers.h:56
This helper struct makes it easier to implement the builder interface, but it also comes with a set o...
Definition target_builder_helpers.h:92
struct xrt_builder base
Base for this struct.
Definition target_builder_helpers.h:94
t_builder_open_system_fn open_system_static_roles
Argument to t_builder_roles_helper_open_system and implemented by t_builder::open_system_static_roles...
Definition target_builder_helpers.h:99
Sets up a collection of devices and builds a system, a setter upper.
Definition xrt_prober.h:595
A single HMD or input device.
Definition xrt_device.h:341
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
A pose composed of a position and orientation.
Definition xrt_defines.h:492
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition xrt_prober.h:136
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition xrt_session.h:224
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:216
A tracking system or device origin.
Definition xrt_tracking.h:78
Common interface to probe for devices.
Header defining xrt space and space overseer.
Header for system objects.