Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_suggested_profile_array.h
Go to the documentation of this file.
1// Copyright 2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Holds suggested profile array related functions.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup oxr_main
8 */
9
10#pragma once
11
12#include "xrt/xrt_compiler.h"
13#include "xrt/xrt_device.h"
14
15#include "oxr_extension_support.h"
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24
25/*!
26 * Manages an array of suggested profiles, does not have a init function
27 * but must be zero initialized where it is declared.
28 */
30{
31 struct oxr_suggested_profile **profiles;
32 size_t count;
33};
34
35/*!
36 * Frees all profiles on the suggested profile array.
37 *
38 * Frees all suggested profiles in the array and then frees the internal array.
39 * Does not free the struct passed in. After this call, the array structure is
40 * reset to an empty state.
41 *
42 * @param array Suggested profile array to destroy, must not be NULL
43 * @public @memberof oxr_suggested_profile_array
44 */
45XRT_NONNULL_ALL void
46oxr_suggested_profile_array_clear(struct oxr_suggested_profile_array *array);
47
48/*!
49 * Add a suggested profile to the array.
50 *
51 * The profile is added to the end of the array. The array takes ownership of
52 * the profile pointer.
53 *
54 * @param array Suggested profile array to add to, must not be NULL
55 * @param profile Suggested profile to add, must not be NULL
56 * @public @memberof oxr_suggested_profile_array
57 */
58XRT_NONNULL_ALL void
59oxr_suggested_profile_array_add(struct oxr_suggested_profile_array *array, struct oxr_suggested_profile *profile);
60
61/*!
62 * Clone a suggested profile array.
63 *
64 * Creates a deep copy of the source array, including cloning all suggested
65 * profiles it contains. The destination array is first cleared (destroying any
66 * existing profiles) before cloning. On failure the destination is left
67 * cleared (empty).
68 *
69 * @param src Source suggested profile array to clone, must not be NULL
70 * @param dst Destination suggested profile array, must not be NULL
71 * @return XR_SUCCESS on success, XR_ERROR_RUNTIME_FAILURE on allocation failure
72 * @public @memberof oxr_suggested_profile_array
73 */
74XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult
75oxr_suggested_profile_array_clone(const struct oxr_suggested_profile_array *src,
76 struct oxr_suggested_profile_array *dst);
77
78/*!
79 * Find a suggested profile in the array by its path.
80 *
81 * Searches the array for a suggested profile with the matching XrPath.
82 *
83 * @param array Suggested profile array to search, must not be NULL
84 * @param path XrPath to search for
85 * @param[out] out_p Found suggested profile; NULL if not found. Must not be NULL.
86 * @return true if a matching profile was found, false otherwise
87 * @public @memberof oxr_suggested_profile_array
88 */
89XRT_NONNULL_ALL bool
90oxr_suggested_profile_array_find_by_path(const struct oxr_suggested_profile_array *array,
91 XrPath path,
92 struct oxr_suggested_profile **out_p);
93
94/*!
95 * Find a suggested profile whose profile template has @p name and binds to the
96 * top-level @p subaction_path.
97 *
98 * This directly compares @p name against each suggested profile's generated
99 * template.
100 *
101 * @param array Suggested profile array to search, must not be NULL
102 * @param registry Binding registry the suggested profiles are looked up in, must not be NULL
103 * @param name XRT device name stored on the profile template
104 * @param subaction_path Top-level path the profile must bind to
105 * @param[out] out_p Found suggested profile; NULL if not found. Must not be NULL.
106 * @return true if a matching profile was found, false otherwise
107 */
108XRT_NONNULL_ALL bool
110 const struct oxr_binding_registry *registry,
111 enum xrt_device_name name,
112 XrPath subaction_path,
113 struct oxr_suggested_profile **out_p);
114
115/*!
116 * Find the first rebinding profile that targets @p target_device_name, whose
117 * target profile binds to the top-level @p subaction_path, and has a suggested
118 * source profile in @p array.
119 *
120 * The helper walks the registry's generated rebinding profiles in registry
121 * order. This lets template generation decide priority: higher-priority
122 * rebindings, such as generic controller rebindings, should be emitted earlier.
123 * For each matching rebinding target device, the helper looks for a suggested
124 * profile with the rebinding source profile path.
125 *
126 * @param array Suggested profile array to search, must not be NULL
127 * @param registry Binding registry whose rebinding profiles are walked, must not be NULL
128 * @param target_device_name Device name the rebinding profile must target
129 * @param subaction_path Top-level path the rebinding target profile must bind to
130 * @param[out] out_p Suggested source profile, or NULL if not found
131 * @param[out] out_rebinding Matching rebinding profile, or NULL if not found
132 * @return true if a matching rebinding and suggested profile were found
133 */
134XRT_NONNULL_ALL bool
136 const struct oxr_binding_registry *registry,
137 enum xrt_device_name target_device_name,
138 XrPath subaction_path,
139 struct oxr_suggested_profile **out_p,
140 const struct oxr_rebinding_profile **out_rebinding);
141
142#ifdef __cplusplus
143}
144#endif
Forward declarations for OpenXR state tracker structs.
Suggested interaction profile state.
XRT_NONNULL_ALL bool oxr_suggested_profile_array_find_by_device_name(const struct oxr_suggested_profile_array *array, const struct oxr_binding_registry *registry, enum xrt_device_name name, XrPath subaction_path, struct oxr_suggested_profile **out_p)
Find a suggested profile whose profile template has name and binds to the top-level subaction_path.
Definition oxr_suggested_profile_array.c:89
XRT_NONNULL_ALL bool oxr_suggested_profile_array_find_rebinding_for_device_name(const struct oxr_suggested_profile_array *array, const struct oxr_binding_registry *registry, enum xrt_device_name target_device_name, XrPath subaction_path, struct oxr_suggested_profile **out_p, const struct oxr_rebinding_profile **out_rebinding)
Find the first rebinding profile that targets target_device_name, whose target profile binds to the t...
Definition oxr_suggested_profile_array.c:126
Complete runtime binding registry for all action contexts of an XrInstance.
Definition oxr_binding_registry.h:35
Maps binding paths from one interaction profile onto another.
Definition oxr_rebinding_profile.h:41
Manages an array of suggested profiles, does not have a init function but must be zero initialized wh...
Definition oxr_suggested_profile_array.h:30
Client-suggested bindings for one OpenXR interaction profile.
Definition oxr_suggested_profile.h:58
XrPath path
Interaction profile path this suggestion set is for.
Definition oxr_suggested_profile.h:60
Header holding common defines.
xrt_device_name
A enum that is used to name devices so that the state trackers can reason about the devices easier.
Definition xrt_defines.h:767
Header defining an xrt display or controller device.