Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_hand_tracker.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 Header defining xrt hand tracker.
6 * @ingroup xrt_iface
7 */
8
9#pragma once
10
11#include "xrt/xrt_defines.h"
12#include "xrt/xrt_results.h"
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct xrt_device;
20struct xrt_hand_tracker;
21struct xrt_space;
23
24/*!
25 * Creation parameters for @ref xrt_hand_tracker.
26 *
27 * If @ref locked_xdev is non-NULL the tracker is created in device-locked
28 * mode, in which the hand-tracker will only get the hand-tracking data from the
29 * provided xrt_device. Otherwise it follows the system hand-tracking role
30 * selection policy.
31 *
32 * @ingroup xrt_iface
33 */
35{
36 //! Which hand this tracker represents.
38
39 //! Optional ordered list of requested hand-tracking input names.
41
42 //! Number of entries in @ref requested_sources, zero means all sources.
44
45 //! Optional device to lock the tracker to.
47};
48
49/*!
50 * Result of locating a hand tracker.
51 *
52 * Joint relations are expressed in the base space supplied to
53 * @ref xrt_hand_tracker::locate. @ref source is the backing input that produced
54 * active data.
55 *
56 * @ingroup xrt_iface
57 */
59{
60 //! Located joints in the requested base space.
62
63 //! Input source that produced active data.
65
66 //! Set if the hand tracker found active hand data.
68};
69
70/*!
71 * A hand tracker that owns device/source selection policy.
72 *
73 * @ingroup xrt_iface
74 */
76{
77 /*!
78 * Locate hand joints in the supplied base space.
79 *
80 * @param xht Pointer to self.
81 * @param xso Space overseer used to resolve device spaces.
82 * @param base_space Space to locate joints in.
83 * @param base_offset Offset from @p base_space.
84 *
85 * @note The @p base_offset argument can be removed if this offset is
86 * folded into the OpenXR XrSpace, but we do not want to change that
87 * behavior just yet.
88 *
89 * @param at_timestamp_ns Time to locate at.
90 * @param out_location Resulting hand-tracking location.
91 */
93 struct xrt_space_overseer *xso,
94 struct xrt_space *base_space,
95 const struct xrt_pose *base_offset,
96 int64_t at_timestamp_ns,
97 struct xrt_hand_tracker_location *out_location);
98
99 /*!
100 * Apply output to the selected backing source device(s).
101 */
103 enum xrt_output_name name,
104 const struct xrt_output_value *value);
105
106 /*!
107 * Destroy this hand tracker.
108 *
109 * Code consuming this interface should use @ref xrt_hand_tracker_destroy.
110 */
111 void (*destroy)(struct xrt_hand_tracker *xht);
112};
113
114/*!
115 * @copydoc xrt_hand_tracker::locate
116 *
117 * @public @memberof xrt_hand_tracker
118 */
119static inline xrt_result_t
121 struct xrt_space_overseer *xso,
122 struct xrt_space *base_space,
123 const struct xrt_pose *base_offset,
124 int64_t at_timestamp_ns,
125 struct xrt_hand_tracker_location *out_location)
126{
127 return xht->locate(xht, xso, base_space, base_offset, at_timestamp_ns, out_location);
128}
129
130/*!
131 * @copydoc xrt_hand_tracker::set_output
132 *
133 * @public @memberof xrt_hand_tracker
134 */
135XRT_NONNULL_ALL static inline xrt_result_t
137 enum xrt_output_name name,
138 const struct xrt_output_value *value)
139{
140 return xht->set_output(xht, name, value);
141}
142
143/*!
144 * Destroy an xrt_hand_tracker - helper function.
145 *
146 * @param[in,out] xht_ptr A pointer to the xrt_hand_tracker struct pointer.
147 *
148 * Will destroy the tracker if `*xht_ptr` is not NULL. Will then set
149 * `*xht_ptr` to NULL.
150 *
151 * @public @memberof xrt_hand_tracker
152 */
153XRT_NONNULL_ALL static inline void
155{
156 struct xrt_hand_tracker *xht = *xht_ptr;
157 if (xht == NULL) {
158 return;
159 }
160
161 *xht_ptr = NULL;
162 xht->destroy(xht);
163}
164
165#ifdef __cplusplus
166}
167#endif
xrt_hand
Enumeration for left and right hand.
Definition xrt_defines.h:1478
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition xrt_defines.h:930
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_output_name
Name of a output with a baked in type.
Definition xrt_defines.h:1612
A single HMD or input device.
Definition xrt_device.h:311
Joint set type used for hand tracking.
Definition xrt_defines.h:1521
Creation parameters for xrt_hand_tracker.
Definition xrt_hand_tracker.h:35
enum xrt_hand hand
Which hand this tracker represents.
Definition xrt_hand_tracker.h:37
struct xrt_device * locked_xdev
Optional device to lock the tracker to.
Definition xrt_hand_tracker.h:46
uint32_t requested_source_count
Number of entries in requested_sources, zero means all sources.
Definition xrt_hand_tracker.h:43
enum xrt_input_name requested_sources[2]
Optional ordered list of requested hand-tracking input names.
Definition xrt_hand_tracker.h:40
Result of locating a hand tracker.
Definition xrt_hand_tracker.h:59
bool is_active
Set if the hand tracker found active hand data.
Definition xrt_hand_tracker.h:67
struct xrt_hand_joint_set hand_joint_set
Located joints in the requested base space.
Definition xrt_hand_tracker.h:61
enum xrt_input_name source
Input source that produced active data.
Definition xrt_hand_tracker.h:64
A hand tracker that owns device/source selection policy.
Definition xrt_hand_tracker.h:76
void(* destroy)(struct xrt_hand_tracker *xht)
Destroy this hand tracker.
Definition xrt_hand_tracker.h:111
static XRT_NONNULL_ALL xrt_result_t xrt_hand_tracker_set_output(struct xrt_hand_tracker *xht, enum xrt_output_name name, const struct xrt_output_value *value)
Apply output to the selected backing source device(s).
Definition xrt_hand_tracker.h:136
xrt_result_t(* set_output)(struct xrt_hand_tracker *xht, enum xrt_output_name name, const struct xrt_output_value *value)
Apply output to the selected backing source device(s).
Definition xrt_hand_tracker.h:102
static XRT_NONNULL_ALL void xrt_hand_tracker_destroy(struct xrt_hand_tracker **xht_ptr)
Destroy an xrt_hand_tracker - helper function.
Definition xrt_hand_tracker.h:154
xrt_result_t(* locate)(struct xrt_hand_tracker *xht, struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_hand_tracker_location *out_location)
Locate hand joints in the supplied base space.
Definition xrt_hand_tracker.h:92
static xrt_result_t xrt_hand_tracker_locate(struct xrt_hand_tracker *xht, struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_hand_tracker_location *out_location)
Locate hand joints in the supplied base space.
Definition xrt_hand_tracker.h:120
A union of all output types.
Definition xrt_defines.h:2386
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
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:32
Common defines and enums for XRT.
Internal result type for XRT.