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 by the XRT device name stored on its profile template.
96 *
97 * This directly compares @p name against each suggested profile's generated
98 * template.
99 *
100 * @param array Suggested profile array to search, must not be NULL
101 * @param name XRT device name stored on the profile template
102 * @param[out] out_p Found suggested profile; NULL if not found. Must not be NULL.
103 * @return true if a matching profile was found, false otherwise
104 */
105XRT_NONNULL_ALL bool
107 enum xrt_device_name name,
108 struct oxr_suggested_profile **out_p);
109
110/*!
111 * Find the first rebinding profile that targets @p target_device_name and has a
112 * suggested source profile in @p array.
113 *
114 * The helper walks the registry's generated rebinding profiles in registry
115 * order. This lets template generation decide priority: higher-priority
116 * rebindings, such as generic controller rebindings, should be emitted earlier.
117 * For each matching rebinding target device, the helper looks for a suggested
118 * profile with the rebinding source profile path.
119 *
120 * @param array Suggested profile array to search, must not be NULL
121 * @param registry Binding registry whose rebinding profiles are walked, must not be NULL
122 * @param target_device_name Device name the rebinding profile must target
123 * @param[out] out_p Suggested source profile, or NULL if not found
124 * @param[out] out_rebinding Matching rebinding profile, or NULL if not found
125 * @return true if a matching rebinding and suggested profile were found
126 */
127XRT_NONNULL_ALL bool
129 const struct oxr_binding_registry *registry,
130 enum xrt_device_name target_device_name,
131 struct oxr_suggested_profile **out_p,
132 const struct oxr_rebinding_profile **out_rebinding);
133
134#ifdef __cplusplus
135}
136#endif
Forward declarations for OpenXR state tracker structs.
Suggested interaction profile state.
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, struct oxr_suggested_profile **out_p, const struct oxr_rebinding_profile **out_rebinding)
Find the first rebinding profile that targets target_device_name and has a suggested source profile i...
Definition oxr_suggested_profile_array.c:114
XRT_NONNULL_ALL bool oxr_suggested_profile_array_find_by_device_name(const struct oxr_suggested_profile_array *array, enum xrt_device_name name, struct oxr_suggested_profile **out_p)
Find a suggested profile by the XRT device name stored on its profile template.
Definition oxr_suggested_profile_array.c:89
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:758
Header defining an xrt display or controller device.