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 * @ingroup xrt_iface
35 */
37 cJSON *config,
38 struct xrt_prober *xp,
39 struct xrt_tracking_origin *origin,
40 struct xrt_system_devices *xsysd,
41 struct xrt_frame_context *xfctx,
42 struct t_builder_roles_helper *tbrh);
43
44/*!
45 * This small helper struct is for @ref t_builder_roles_helper_open_system,
46 * lets a builder focus on opening devices rather then dealing with Monado
47 * structs like @ref xrt_system_devices and the like.
48 *
49 * @ingroup xrt_iface
50 */
52{
53 struct xrt_device *head;
54 struct xrt_device *eyes;
55 struct xrt_device *face;
56 struct xrt_device *left;
57 struct xrt_device *right;
58 struct xrt_device *gamepad;
59
60 struct
61 {
62 struct
63 {
64 struct xrt_device *left;
65 struct xrt_device *right;
66 } unobstructed;
67
68 struct
69 {
70 struct xrt_device *left;
71 struct xrt_device *right;
72 } conforming;
73 } hand_tracking;
74};
75
76/*!
77 * This helper struct makes it easier to implement the builder interface, but it
78 * also comes with a set of integration that may not be what all builders want.
79 * See the below functions for more information.
80 *
81 * * @ref t_builder_open_system_static_roles
82 * * @ref t_builder_roles_helper_open_system
83 *
84 * @ingroup xrt_iface
85 */
87{
88 //! Base for this struct.
90
91 /*!
92 * @copydoc t_builder_open_system_fn
93 */
95};
96
97
98/*
99 *
100 * Functions.
101 *
102 */
103
104/*!
105 * Create a legacy space overseer, most builders probably want to have a more
106 * advanced setup then this, especially stand alone ones. Uses
107 * @ref u_builder_setup_tracking_origins internally and
108 * @ref b_space_overseer_legacy_setup.
109 *
110 * @ingroup xrt_iface
111 */
112void
114 struct xrt_device *head,
115 struct xrt_device *eyes,
116 struct xrt_device *left,
117 struct xrt_device *right,
118 struct xrt_device *gamepad,
119 struct xrt_device **xdevs,
120 uint32_t xdev_count,
121 bool root_is_unbounded,
122 bool per_app_local_spaces,
123 struct xrt_space_overseer **out_xso);
124
125/*!
126 * Helper to create a system devices that has static roles and a appropriate
127 * space overseer. Currently uses the functions below to create a full system
128 * with the help of @p fn argument. But this might change in the future.
129 *
130 * * @ref b_system_devices_static_allocate
131 * * @ref b_system_devices_static_finalize
132 * * @ref t_builder_create_space_overseer_legacy
133 *
134 * @ingroup xrt_iface
135 */
138 cJSON *config,
139 struct xrt_prober *xp,
140 struct xrt_session_event_sink *broadcast,
141 struct xrt_system_devices **out_xsysd,
142 struct xrt_space_overseer **out_xso,
144
145/*!
146 * Implementation for xrt_builder::open_system to be used with @ref t_builder.
147 * Uses @ref t_builder_roles_helper_open_system internally, a builder that uses
148 * the @ref t_builder should use this function for xrt_builder::open_system.
149 *
150 * When using this function the builder must have @ref t_builder and implement
151 * the @ref t_builder::open_system_static_roles function, see documentation for
152 * @ref t_builder_open_system_fn about requirements.
153 *
154 * @ingroup xrt_iface
155 */
158 cJSON *config,
159 struct xrt_prober *xp,
160 struct xrt_session_event_sink *broadcast,
161 struct xrt_system_devices **out_xsysd,
162 struct xrt_space_overseer **out_xso);
163
164
165#ifdef __cplusplus
166}
167#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:91
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, 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:165
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_roles_helper *tbrh)
Argument to t_builder_roles_helper_open_system and implemented by t_builder::open_system_static_roles...
Definition target_builder_helpers.h:36
This small helper struct is for t_builder_roles_helper_open_system, lets a builder focus on opening d...
Definition target_builder_helpers.h:52
This helper struct makes it easier to implement the builder interface, but it also comes with a set o...
Definition target_builder_helpers.h:87
struct xrt_builder base
Base for this struct.
Definition target_builder_helpers.h:89
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:94
Sets up a collection of devices and builds a system, a setter upper.
Definition xrt_prober.h:594
A single HMD or input device.
Definition xrt_device.h:310
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition xrt_prober.h:135
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition xrt_session.h:237
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:214
A tracking system or device origin.
Definition xrt_tracking.h:75
Common interface to probe for devices.
Header defining xrt space and space overseer.
Header for system objects.