Monado OpenXR Runtime
u_space_overseer.h
Go to the documentation of this file.
1// Copyright 2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief A implementation of the @ref xrt_space_overseer interface.
6 *
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup aux_util
9 */
10
11#include "xrt/xrt_space.h"
12
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18
19struct u_space_overseer;
21
22
23/*
24 *
25 * Main interface.
26 *
27 */
28
29/*!
30 * Create a default implementation of a space overseer.
31 *
32 * @param[in] broadcast Event sink that broadcasts events to all sessions.
33 * @ingroup aux_util
34 */
35struct u_space_overseer *
37
38/*!
39 * Sets up the space overseer and all semantic spaces in a way that works with
40 * the old @ref xrt_tracking_origin information. Will automatically create local
41 * and stage spaces. If another setup is needed the builder should manually set
42 * the space graph up using below functions.
43 *
44 * @ingroup aux_util
45 */
46void
48 struct xrt_device **xdevs,
49 uint32_t xdev_count,
50 struct xrt_device *head,
51 const struct xrt_pose *local_offset,
52 bool root_is_unbounded);
53
54/*!
55 * Creates a space without any offset, this is just for optimisation over a
56 * regular offset space.
57 *
58 * @ingroup aux_util
59 */
60void
62 struct xrt_space *parent,
63 struct xrt_space **out_space);
64
65/*!
66 * The space overseer internally keeps track the space that @ref xrt_device is
67 * in, and then uses that mapping when creating pose spaces. This function
68 * allows builders to create a much more bespoke setup. This function adds a
69 * reference to the space.
70 *
71 * @ingroup aux_util
72 */
73void
75
76
77/*
78 *
79 * Builder helpers.
80 *
81 */
82
83/*!
84 * @copydoc xrt_space_overseer::create_offset_space
85 *
86 * Convenience helper for builder code using @ref u_space_overseer directly.
87 *
88 * @public @memberof u_space_overseer
89 */
90static inline xrt_result_t
92 struct xrt_space *parent,
93 const struct xrt_pose *offset,
94 struct xrt_space **out_space)
95{
96 struct xrt_space_overseer *xso = (struct xrt_space_overseer *)uso;
97 return xrt_space_overseer_create_offset_space(xso, parent, offset, out_space);
98}
99
100/*!
101 * @copydoc xrt_space_overseer::create_pose_space
102 *
103 * Convenience helper for builder code using @ref u_space_overseer directly.
104 *
105 * @public @memberof u_space_overseer
106 */
107static inline xrt_result_t
109 struct xrt_device *xdev,
110 enum xrt_input_name name,
111 struct xrt_space **out_space)
112{
113 struct xrt_space_overseer *xso = (struct xrt_space_overseer *)uso;
114 return xrt_space_overseer_create_pose_space(xso, xdev, name, out_space);
115}
116
117
118#ifdef __cplusplus
119}
120#endif
void u_space_overseer_create_null_space(struct u_space_overseer *uso, struct xrt_space *parent, struct xrt_space **out_space)
Creates a space without any offset, this is just for optimisation over a regular offset space.
Definition: u_space_overseer.c:868
void u_space_overseer_legacy_setup(struct u_space_overseer *uso, struct xrt_device **xdevs, uint32_t xdev_count, struct xrt_device *head, const struct xrt_pose *local_offset, bool root_is_unbounded)
Sets up the space overseer and all semantic spaces in a way that works with the old xrt_tracking_orig...
Definition: u_space_overseer.c:786
struct u_space_overseer * u_space_overseer_create(struct xrt_session_event_sink *broadcast)
Create a default implementation of a space overseer.
Definition: u_space_overseer.c:759
void u_space_overseer_link_space_to_device(struct u_space_overseer *uso, struct xrt_space *xs, struct xrt_device *xdev)
The space overseer internally keeps track the space that xrt_device is in, and then uses that mapping...
Definition: u_space_overseer.c:881
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition: xrt_defines.h:1134
enum xrt_result xrt_result_t
Result type used across Monado.
Default implementation of the xrt_space_overseer object.
Definition: u_space_overseer.c:82
static xrt_result_t u_space_overseer_create_pose_space(struct u_space_overseer *uso, struct xrt_device *xdev, enum xrt_input_name name, struct xrt_space **out_space)
Create a space that wraps the xdev input pose described by input name, implicitly make the device's t...
Definition: u_space_overseer.h:108
static xrt_result_t u_space_overseer_create_offset_space(struct u_space_overseer *uso, struct xrt_space *parent, const struct xrt_pose *offset, struct xrt_space **out_space)
Create a space with a fixed offset to the parent space.
Definition: u_space_overseer.h:91
struct xrt_session_event_sink * broadcast
Event sink to broadcast events to all sessions.
Definition: u_space_overseer.c:95
A single HMD or input device.
Definition: xrt_device.h:230
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
Used internally from producers of events to push events into session, some sinks might mutliplex even...
Definition: xrt_session.h:193
Object that oversees and manages spaces, one created for each XR system.
Definition: xrt_space.h:95
static xrt_result_t xrt_space_overseer_create_offset_space(struct xrt_space_overseer *xso, struct xrt_space *parent, const struct xrt_pose *offset, struct xrt_space **out_space)
Create a space with a fixed offset to the parent space.
Definition: xrt_space.h:232
static xrt_result_t xrt_space_overseer_create_pose_space(struct xrt_space_overseer *xso, struct xrt_device *xdev, enum xrt_input_name name, struct xrt_space **out_space)
Create a space that wraps the xdev input pose described by input name, implicitly make the device's t...
Definition: xrt_space.h:248
A space very similar to a OpenXR XrSpace but not a full one-to-one mapping, but used to power XrSpace...
Definition: xrt_space.h:30
Header defining xrt space and space overseer.