Monado OpenXR Runtime
xrt_device.h
Go to the documentation of this file.
1// Copyright 2019-2024, Collabora, Ltd.
2// Copyright 2024-2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Header defining an xrt display or controller device.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Moshi Turner <moshiturner@protonmail.com>
9 * @author Korcan Hussein <korcan.hussein@collabora.com>
10 * @ingroup xrt_iface
11 */
12
13#pragma once
14
15#include "xrt/xrt_defines.h"
18#include "xrt/xrt_limits.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24struct xrt_tracking;
25
26#define XRT_DEVICE_NAME_LEN 256
27
28
29/*!
30 * A per-lens/display view information.
31 *
32 * @ingroup xrt_iface
33 */
35{
36 /*!
37 * @brief Viewport position on the screen.
38 *
39 * In absolute screen coordinates on an unrotated display, like the
40 * HMD presents it to the OS.
41 *
42 * This field is only used by @ref comp to setup the device rendering.
43 *
44 * If the view is being rotated by xrt_view.rot 90° right in the
45 * distortion shader then `display.w_pixels == viewport.h_pixels` and
46 * `display.h_pixels == viewport.w_pixels`.
47 */
48 struct
49 {
50 uint32_t x_pixels;
51 uint32_t y_pixels;
52 uint32_t w_pixels;
53 uint32_t h_pixels;
55
56 /*!
57 * @brief Physical properties of this display (or the part of a display
58 * that covers this view).
59 *
60 * Not in absolute screen coordinates but like the clients see them i.e.
61 * after rotation is applied by xrt_view::rot.
62 * This field is only used for the clients' swapchain setup.
63 *
64 * The xrt_view::display::w_pixels and xrt_view::display::h_pixels
65 * become the recommended image size for this view, after being scaled
66 * by the debug environment variable `XRT_COMPOSITOR_SCALE_PERCENTAGE`.
67 */
68 struct
69 {
70 uint32_t w_pixels;
71 uint32_t h_pixels;
73
74 /*!
75 * @brief Rotation 2d matrix used to rotate the position of the output
76 * of the distortion shaders onto the screen.
77 *
78 * If the distortion shader is based on a mesh, then this matrix rotates
79 * the vertex positions.
80 */
82};
83
84/*!
85 * All of the device components that deals with interfacing to a users head.
86 *
87 * HMD is probably a bad name for the future but for now will have to do.
88 *
89 * @ingroup xrt_iface
90 */
92{
93 /*!
94 * @brief The hmd screen as an unrotated display, like the HMD presents
95 * it to the OS.
96 *
97 * This field is used by @ref comp to setup the extended mode window.
98 */
99 struct
100 {
101 int w_pixels;
102 int h_pixels;
103 //! Nominal frame interval
106
107 /*!
108 * Display information.
109 *
110 * For now hardcoded display to two.
111 */
112 struct xrt_view views[XRT_MAX_VIEWS];
113
114 size_t view_count;
115 /*!
116 * Array of supported blend modes.
117 */
118 enum xrt_blend_mode blend_modes[XRT_MAX_DEVICE_BLEND_MODES];
119 size_t blend_mode_count;
120
121 /*!
122 * Distortion information.
123 */
124 struct
125 {
126 //! Supported distortion models, a bitfield.
128 //! Preferred disortion model, single value.
130
131 struct
132 {
133 //! Data.
134 float *vertices;
135 //! Number of vertices.
136 uint32_t vertex_count;
137 //! Stride of vertices
138 uint32_t stride;
139 //! 1 or 3 for (chromatic aberration).
141
142 //! Indices, for triangle strip.
144 //! Number of indices for the triangle strips (one per view).
145 uint32_t index_counts[XRT_MAX_VIEWS];
146 //! Offsets for the indices (one offset per view).
147 uint32_t index_offsets[XRT_MAX_VIEWS];
148 //! Total number of elements in mesh::indices array.
150 } mesh;
151
152 //! distortion is subject to the field of view
153 struct xrt_fov fov[XRT_MAX_VIEWS];
155};
156
157/*!
158 * A single named input, that sits on a @ref xrt_device.
159 *
160 * @ingroup xrt_iface
161 */
163{
164 //! Is this input active.
165 bool active;
166
167 //! alignas for 32 bit client support, see @ref ipc-design
168 XRT_ALIGNAS(8) int64_t timestamp;
169
170 enum xrt_input_name name;
171
172 union xrt_input_value value;
173};
174
175/*!
176 * A single named output, that sits on a @ref xrt_device.
177 *
178 * @ingroup xrt_iface
179 */
181{
182 enum xrt_output_name name;
183};
184
185
186/*!
187 * A binding pair, going @p from a binding point to a @p device input.
188 *
189 * @ingroup xrt_iface
190 */
192{
193 enum xrt_input_name from; //!< From which name.
194 enum xrt_input_name device; //!< To input on the device.
195};
196
197/*!
198 * A binding pair, going @p from a binding point to a @p device output.
199 *
200 * @ingroup xrt_iface
201 */
203{
204 enum xrt_output_name from; //!< From which name.
205 enum xrt_output_name device; //!< To output on the device.
206};
207
208/*!
209 * A binding profile, has lists of binding pairs to goes from device in @p name
210 * to the device it hangs off on.
211 *
212 * @ingroup xrt_iface
213 */
215{
216 //! Device this binding emulates.
218
219 struct xrt_binding_input_pair *inputs;
220 size_t input_count;
221 struct xrt_binding_output_pair *outputs;
222 size_t output_count;
223};
224
225/*!
226 * Higher level features for devices.
227 */
229{
230 XRT_DEVICE_FEATURE_HAND_TRACKING_LEFT = 0,
231 XRT_DEVICE_FEATURE_HAND_TRACKING_RIGHT,
232 XRT_DEVICE_FEATURE_EYE_TRACKING,
233 XRT_DEVICE_FEATURE_MAX_ENUM,
234};
235
236/*!
237 * Output limits of a particular device
238 */
240{
241 //! The sample rate of the device's haptic PCM support, 0 if haptic PCM is not supported.
243};
244
245/*!
246 * Static data of supported features of the @ref xrt_device this struct sits on.
247 *
248 * This struct needs to always be a piece of data as it sits inside of the
249 * shared memory area in the IPC layer, so no pointers please.
250 *
251 * @ingroup xrt_iface
252 */
254{
255 bool orientation_tracking;
256 bool position_tracking;
257 bool hand_tracking;
258 bool eye_gaze;
259 bool presence;
260 bool force_feedback;
261 bool ref_space_usage;
262 bool form_factor_check;
263 bool stage;
264 bool face_tracking;
265 bool body_tracking;
266 bool battery_status;
267
268 bool planes;
269 enum xrt_plane_detection_capability_flags_ext plane_capability_flags;
270};
271
272/*!
273 * @interface xrt_device
274 *
275 * A single HMD or input device.
276 *
277 * @ingroup xrt_iface
278 */
280{
281 //! Enum identifier of the device.
283 enum xrt_device_type device_type;
284
285 //! A string describing the device.
286 char str[XRT_DEVICE_NAME_LEN];
287
288 //! A unique identifier. Persistent across configurations, if possible.
289 char serial[XRT_DEVICE_NAME_LEN];
290
291 //! Null if this device does not interface with the users head.
293
294 //! Always set, pointing to the tracking system for this device.
296
297 //! Number of bindings in xrt_device::binding_profiles
299 // Array of alternative binding profiles.
300 struct xrt_binding_profile *binding_profiles;
301
302 //! Number of inputs.
304 //! Array of input structs.
306
307 //! Number of outputs.
309 //! Array of output structs.
311
312 //! What features/functions/things does this device supports?
313 struct xrt_device_supported supported;
314
315
316 /*
317 *
318 * Functions.
319 *
320 */
321
322 /*!
323 * Update any attached inputs.
324 *
325 * @param[in] xdev The device.
326 */
327 xrt_result_t (*update_inputs)(struct xrt_device *xdev);
328
329 /*!
330 * @brief Get relationship of a tracked device to the tracking origin
331 * space as the base space.
332 *
333 * It is the responsibility of the device driver to do any prediction,
334 * there are helper functions available for this.
335 *
336 * The timestamps are system monotonic timestamps, such as returned by
337 * os_monotonic_get_ns().
338 *
339 * @param[in] xdev The device.
340 * @param[in] name Some devices may have multiple poses on
341 * them, select the one using this field. For
342 * HMDs use @p XRT_INPUT_GENERIC_HEAD_POSE.
343 * For Unbounded Reference Space you can use
344 * @p XRT_INPUT_GENERIC_UNBOUNDED_SPACE_POSE
345 * to get the origin of that space.
346 * @param[in] at_timestamp_ns If the device can predict or has a history
347 * of positions, this is when the caller
348 * wants the pose to be from.
349 * @param[out] out_relation The relation read from the device.
350 *
351 * @see xrt_input_name
352 */
354 enum xrt_input_name name,
355 int64_t at_timestamp_ns,
356 struct xrt_space_relation *out_relation);
357
358 /*!
359 * @brief Get relationship of hand joints to the tracking origin space as
360 * the base space.
361 *
362 * It is the responsibility of the device driver to either do prediction
363 * or return joints from a previous time and write that time out to
364 * @p out_timestamp_ns.
365 *
366 * The timestamps are system monotonic timestamps, such as returned by
367 * os_monotonic_get_ns().
368 *
369 * @param[in] xdev The device.
370 * @param[in] name Some devices may have multiple poses on
371 * them, select the one using this field. For
372 * hand tracking use @p XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET.
373 * @param[in] desired_timestamp_ns If the device can predict or has a history
374 * of positions, this is when the caller
375 * wants the pose to be from.
376 * @param[out] out_value The hand joint data read from the device.
377 * @param[out] out_timestamp_ns The timestamp of the data being returned.
378 *
379 * @see xrt_input_name
380 */
381 xrt_result_t (*get_hand_tracking)(struct xrt_device *xdev,
382 enum xrt_input_name name,
383 int64_t desired_timestamp_ns,
384 struct xrt_hand_joint_set *out_value,
385 int64_t *out_timestamp_ns);
386
387 /*!
388 * @brief Get the requested blend shape properties & weights for a face tracker
389 *
390 * @param[in] xdev The device.
391 * @param[in] facial_expression_type The facial expression data type (XR_FB_face_tracking,
392 * XR_HTC_facial_tracking, etc).
393 * @param[in] at_timestamp_ns Timestamp to be optionally used for prediction/history. For OXR extensions
394 * that do not pass a timestamp, the current timestamp is used.
395 * @param[in] out_value Set of requested expression weights & blend shape properties.
396 *
397 * @see xrt_input_name
398 */
399 xrt_result_t (*get_face_tracking)(struct xrt_device *xdev,
400 enum xrt_input_name facial_expression_type,
401 int64_t at_timestamp_ns,
402 struct xrt_facial_expression_set *out_value);
403
404 /*!
405 * @brief Get the body skeleton in T-pose, used to query the skeleton hierarchy, scale, proportions etc
406 *
407 * @param[in] xdev The device.
408 * @param[in] body_tracking_type The body joint set type (XR_FB_body_tracking,
409 * XR_META_body_tracking_full_body, etc).
410 * @param[in] out_value The body skeleton hierarchy/properties.
411 *
412 * @see xrt_input_name
413 */
414 xrt_result_t (*get_body_skeleton)(struct xrt_device *xdev,
415 enum xrt_input_name body_tracking_type,
416 struct xrt_body_skeleton *out_value);
417
418 /*!
419 * @brief Get the joint locations for a body tracker
420 *
421 * @param[in] xdev The device.
422 * @param[in] body_tracking_type The body joint set type (XR_FB_body_tracking,
423 * XR_META_body_tracking_full_body, etc).
424 * @param[in] desired_timestamp_ns If the device can predict or has a history
425 * of locations, this is when the caller
426 * @param[in] out_value Set of body joint locations & properties.
427 *
428 * @see xrt_input_name
429 */
430 xrt_result_t (*get_body_joints)(struct xrt_device *xdev,
431 enum xrt_input_name body_tracking_type,
432 int64_t desired_timestamp_ns,
433 struct xrt_body_joint_set *out_value);
434
435 /*!
436 * Set a output value.
437 *
438 * @param[in] xdev The device.
439 * @param[in] name The output component name to set.
440 * @param[in] value The value to set the output to.
441 * @see xrt_output_name
442 */
443 xrt_result_t (*set_output)(struct xrt_device *xdev,
445 const struct xrt_output_value *value);
446
447 /*!
448 * Gets limits of this devices outputs.
449 *
450 * @param[in] xdev The device.
451 * @param[out] limits The returned limits.
452 */
453 xrt_result_t (*get_output_limits)(struct xrt_device *xdev, struct xrt_output_limits *limits);
454
455 /*!
456 * @brief Get current presence status of the device.
457 *
458 * @param[in] xdev The device.
459 * @param[out] presence The returned presence status.
460 */
461 xrt_result_t (*get_presence)(struct xrt_device *xdev, bool *presence);
462
463 /*!
464 * Begin a plane detection request
465 *
466 * @param[in] xdev The device.
467 * @param[in] begin_info The query specifying what type of planes are requested.
468 * @param[in] plane_detection_id The id for a previous plane detection request to be replaced or 0.
469 * @param[out] out_plane_detection_id The id of the new plane detection request generated by the xdev.
470 * @return generally XRT_SUCCESS, except for internal runtime failures.
471 */
473 const struct xrt_plane_detector_begin_info_ext *begin_info,
474 uint64_t plane_detection_id,
475 uint64_t *out_plane_detection_id);
476
477 /*!
478 * Destroy internal resources associated with plane_detector_id.
479 *
480 * @param[in] xdev The device.
481 * @param[in] plane_detection_id An id generated by the xdev.
482 * @return generally XRT_SUCCESS, except for internal runtime failures.
483 */
484 enum xrt_result (*destroy_plane_detection_ext)(struct xrt_device *xdev, uint64_t plane_detection_id);
485
486 /*!
487 * Get the state of a plane detection request.
488 *
489 * @param[in] xdev The device.
490 * @param[in] plane_detector_id An id generated by the xdev.
491 * @param[out] out_state The state of the plane detection.
492 * @return generally XRT_SUCCESS, except for internal runtime failures.
493 */
495 uint64_t plane_detection_id,
496 enum xrt_plane_detector_state_ext *out_state);
497
498 /*!
499 * Get results of a plane detection request.
500 *
501 * @param[in] xdev The device.
502 * @param[in] plane_detector_id An id generated by the xdev.
503 * @param[out] detections The detected planes, if any.
504 * @return generally XRT_SUCCESS, except for internal runtime failures.
505 */
507 uint64_t plane_detection_id,
508 struct xrt_plane_detections_ext *out_detections);
509
510 /*!
511 * @brief Get the per-view pose in relation to the view space.
512 *
513 * On most devices with coplanar displays and no built-in eye tracking
514 * or IPD sensing, this just calls a helper to process the provided
515 * eye relation, but this may also handle canted displays as well as
516 * eye tracking.
517 *
518 * Incorporates a call to xrt_device::get_tracked_pose or a wrapper for it
519 *
520 * @param[in] xdev The device.
521 * @param[in] default_eye_relation
522 * The interpupillary relation as a 3D position.
523 * Most simple stereo devices would just want to
524 * set `out_pose->position.[x|y|z] = ipd.[x|y|z]
525 * / 2.0f` and adjust for left vs right view.
526 * Not to be confused with IPD that is absolute
527 * distance, this is a full 3D translation
528 * If a device has a more accurate/dynamic way of
529 * knowing the eye relation, it may ignore this
530 * input.
531 * @param[in] at_timestamp_ns This is when the caller wants the poses and FOVs to be from.
532 * @param[in] view_count Number of views.
533 * @param[out] out_head_relation
534 * The head pose in the device tracking space.
535 * Combine with @p out_poses to get the views in
536 * device tracking space.
537 * @param[out] out_fovs An array (of size @p view_count ) to populate
538 * with the device-suggested fields of view.
539 * @param[out] out_poses An array (of size @p view_count ) to populate
540 * with view output poses in head space. When
541 * implementing, be sure to also set orientation:
542 * most likely identity orientation unless you
543 * have canted screens.
544 * (Caution: Even if you have eye tracking, you
545 * won't use eye orientation here!)
546 */
547 xrt_result_t (*get_view_poses)(struct xrt_device *xdev,
548 const struct xrt_vec3 *default_eye_relation,
549 int64_t at_timestamp_ns,
550 uint32_t view_count,
551 struct xrt_space_relation *out_head_relation,
552 struct xrt_fov *out_fovs,
553 struct xrt_pose *out_poses);
554
555 /**
556 * Compute the distortion at a single point.
557 *
558 * The input is @p u @p v in screen/output space (that is, predistorted), you are to compute and return the u,v
559 * coordinates to sample the render texture. The compositor will step through a range of u,v parameters to build
560 * the lookup (vertex attribute or distortion texture) used to pre-distort the image as required by the device's
561 * optics.
562 *
563 * @param xdev the device
564 * @param view the view index
565 * @param u horizontal texture coordinate
566 * @param v vertical texture coordinate
567 * @param[out] out_result corresponding u,v pairs for all three color channels.
568 */
569 bool (*compute_distortion)(
570 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result);
571
572 /*!
573 * Get the visibility mask for this device.
574 *
575 * @param[in] xdev The device.
576 * @param[in] type The type of visibility mask.
577 * @param[in] view_index The index of the view to get the mask for.
578 * @param[out] out_mask Output mask, caller must free.
579 */
580 xrt_result_t (*get_visibility_mask)(struct xrt_device *xdev,
581 enum xrt_visibility_mask_type type,
582 uint32_t view_index,
583 struct xrt_visibility_mask **out_mask);
584
585 /*!
586 * Called by the @ref xrt_space_overseer when a reference space that is
587 * implemented by this device is first used, or when the last usage of
588 * the reference space stops.
589 *
590 * What is provided is both the @ref xrt_reference_space_type that
591 * triggered the usage change and the @ref xrt_input_name (if any) that
592 * is used to drive the space.
593 *
594 * @see xrt_space_overseer_ref_space_inc
595 * @see xrt_space_overseer_ref_space_dec
596 * @see xrt_input_name
597 * @see xrt_reference_space_type
598 */
599 xrt_result_t (*ref_space_usage)(struct xrt_device *xdev,
600 enum xrt_reference_space_type type,
601 enum xrt_input_name name,
602 bool used);
603
604 /*!
605 * @brief Check if given form factor is available or not.
606 *
607 * This should only be used in HMD device, if the device driver supports form factor check.
608 *
609 * @param[in] xdev The device.
610 * @param[in] form_factor Form factor to check.
611 *
612 * @return true if given form factor is available; otherwise false.
613 */
614 bool (*is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor);
615
616 /*!
617 * @brief Get battery status information.
618 *
619 * @param[in] xdev The device.
620 * @param[out] out_present Whether battery status information exist for this device.
621 * @param[out] out_charging Whether the device's battery is being charged.
622 * @param[out] out_charge Battery charge as a value between 0 and 1.
623 */
625 bool *out_present,
626 bool *out_charging,
627 float *out_charge);
628
629 /*!
630 * Enable the feature for this device.
631 *
632 * @param[in] xdev The device.
633 * @param[in] type The type of device feature.
634 */
636
637 /*!
638 * Disable the feature for this device.
639 *
640 * @param[in] xdev The device.
641 * @param[in] type The type of device feature.
642 */
644
645 /*!
646 * Destroy device.
647 */
648 void (*destroy)(struct xrt_device *xdev);
649
650 // Add new functions above destroy.
651};
652
653/*!
654 * Helper function for @ref xrt_device::update_inputs.
655 *
656 * @copydoc xrt_device::update_inputs
657 *
658 * @public @memberof xrt_device
659 */
660static inline xrt_result_t
662{
663 return xdev->update_inputs(xdev);
664}
665
666/*!
667 * Helper function for @ref xrt_device::get_tracked_pose.
668 *
669 * @copydoc xrt_device::get_tracked_pose
670 *
671 * @public @memberof xrt_device
672 */
673static inline xrt_result_t
675 enum xrt_input_name name,
676 int64_t at_timestamp_ns,
677 struct xrt_space_relation *out_relation)
678{
679 return xdev->get_tracked_pose(xdev, name, at_timestamp_ns, out_relation);
680}
681
682/*!
683 * Helper function for @ref xrt_device::get_hand_tracking.
684 *
685 * @copydoc xrt_device::get_hand_tracking
686 *
687 * @public @memberof xrt_device
688 */
689static inline xrt_result_t
691 enum xrt_input_name name,
692 int64_t desired_timestamp_ns,
693 struct xrt_hand_joint_set *out_value,
694 int64_t *out_timestamp_ns)
695{
696 return xdev->get_hand_tracking(xdev, name, desired_timestamp_ns, out_value, out_timestamp_ns);
697}
698
699/*!
700 * Helper function for @ref xrt_device::get_face_tracking.
701 *
702 * @copydoc xrt_device::get_face_tracking
703 *
704 * @public @memberof xrt_device
705 */
706static inline xrt_result_t
708 enum xrt_input_name facial_expression_type,
709 int64_t at_timestamp_ns,
710 struct xrt_facial_expression_set *out_value)
711{
712 return xdev->get_face_tracking(xdev, facial_expression_type, at_timestamp_ns, out_value);
713}
714
715/*!
716 * Helper function for @ref xrt_device::get_body_skeleton.
717 *
718 * @copydoc xrt_device::get_body_skeleton
719 *
720 * @public @memberof xrt_device
721 */
722static inline xrt_result_t
724 enum xrt_input_name body_tracking_type,
725 struct xrt_body_skeleton *out_value)
726{
727 return xdev->get_body_skeleton(xdev, body_tracking_type, out_value);
728}
729
730/*!
731 * Helper function for @ref xrt_device::get_body_joints.
732 *
733 * @copydoc xrt_device::get_body_joints
734 *
735 * @public @memberof xrt_device
736 */
737static inline xrt_result_t
739 enum xrt_input_name body_tracking_type,
740 int64_t desired_timestamp_ns,
741 struct xrt_body_joint_set *out_value)
742{
743 return xdev->get_body_joints(xdev, body_tracking_type, desired_timestamp_ns, out_value);
744}
745
746/*!
747 * Helper function for @ref xrt_device::set_output.
748 *
749 * @copydoc xrt_device::set_output
750 *
751 * @public @memberof xrt_device
752 */
753static inline xrt_result_t
755{
756 xdev->set_output(xdev, name, value);
757 return XRT_SUCCESS;
758}
759
760static inline xrt_result_t
761xrt_device_get_output_limits(struct xrt_device *xdev, struct xrt_output_limits *limits)
762{
763 if (xdev->get_output_limits) {
764 return xdev->get_output_limits(xdev, limits);
765 } else {
767 }
768}
769
770/*!
771 * Helper function for @ref xrt_device::get_presence.
772 *
773 * @copydoc xrt_device::get_presence
774 *
775 * @public @memberof xrt_device
776 */
777static inline xrt_result_t
778xrt_device_get_presence(struct xrt_device *xdev, bool *presence)
779{
780 if (xdev->get_presence) {
781 return xdev->get_presence(xdev, presence);
782 } else {
784 }
785}
786
787/*!
788 * Helper function for @ref xrt_device::begin_plane_detection.
789 *
790 * @public @memberof xrt_device
791 */
792static inline enum xrt_result
794 const struct xrt_plane_detector_begin_info_ext *begin_info,
795 uint64_t plane_detection_id,
796 uint64_t *out_plane_detection_id)
797{
798 return xdev->begin_plane_detection_ext(xdev, begin_info, plane_detection_id, out_plane_detection_id);
799}
800
801/*!
802 * Helper function for @ref xrt_device::destroy_plane_detection.
803 *
804 * @public @memberof xrt_device
805 */
806static inline enum xrt_result
807xrt_device_destroy_plane_detection_ext(struct xrt_device *xdev, uint64_t plane_detection_id)
808{
809 return xdev->destroy_plane_detection_ext(xdev, plane_detection_id);
810}
811
812/*!
813 * Helper function for @ref xrt_device::get_plane_detections.
814 *
815 * @public @memberof xrt_device
816 */
817static inline enum xrt_result
819 uint64_t plane_detection_id,
820 enum xrt_plane_detector_state_ext *out_state)
821{
822 return xdev->get_plane_detection_state_ext(xdev, plane_detection_id, out_state);
823}
824
825/*!
826 * Helper function for @ref xrt_device::get_plane_detections.
827 *
828 * @public @memberof xrt_device
829 */
830static inline enum xrt_result
832 uint64_t plane_detection_id,
833 struct xrt_plane_detections_ext *out_detections)
834{
835 return xdev->get_plane_detections_ext(xdev, plane_detection_id, out_detections);
836}
837
838/*!
839 * Helper function for @ref xrt_device::get_view_poses.
840 *
841 * @copydoc xrt_device::get_view_poses
842 * @public @memberof xrt_device
843 */
844static inline xrt_result_t
846 const struct xrt_vec3 *default_eye_relation,
847 int64_t at_timestamp_ns,
848 uint32_t view_count,
849 struct xrt_space_relation *out_head_relation,
850 struct xrt_fov *out_fovs,
851 struct xrt_pose *out_poses)
852{
853 return xdev->get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation,
854 out_fovs, out_poses);
855}
856
857/*!
858 * Helper function for @ref xrt_device::compute_distortion.
859 *
860 * @copydoc xrt_device::compute_distortion
861 *
862 * @public @memberof xrt_device
863 */
864static inline bool
866 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
867{
868 return xdev->compute_distortion(xdev, view, u, v, out_result);
869}
870
871/*!
872 * Helper function for @ref xrt_device::get_visibility_mask.
873 *
874 * @copydoc xrt_device::get_visibility_mask
875 *
876 * @public @memberof xrt_device
877 */
878static inline xrt_result_t
880 enum xrt_visibility_mask_type type,
881 uint32_t view_index,
882 struct xrt_visibility_mask **out_mask)
883{
884 return xdev->get_visibility_mask(xdev, type, view_index, out_mask);
885}
886
887/*!
888 * Helper function for @ref xrt_device::ref_space_usage.
889 *
890 * @copydoc xrt_device::ref_space_usage
891 *
892 * @public @memberof xrt_device
893 */
894static inline xrt_result_t
896 enum xrt_reference_space_type type,
897 enum xrt_input_name name,
898 bool used)
899{
900 return xdev->ref_space_usage(xdev, type, name, used);
901}
902
903/*!
904 * Helper function for @ref xrt_device::is_form_factor_available.
905 *
906 * @copydoc xrt_device::is_form_factor_available
907 *
908 * @public @memberof xrt_device
909 */
910static inline bool
912{
913 return xdev->is_form_factor_available(xdev, form_factor);
914}
915
916/*!
917 * Helper function for @ref xrt_device::get_battery_status.
918 *
919 * @copydoc xrt_device::get_battery_status
920 *
921 * @public @memberof xrt_device
922 */
923static inline xrt_result_t
924xrt_device_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
925{
926 return xdev->get_battery_status(xdev, out_present, out_charging, out_charge);
927}
928
929/*!
930 * Helper function for @ref xrt_device::begin_feature.
931 *
932 * @copydoc xrt_device::begin_feature
933 *
934 * @public @memberof xrt_device
935 */
936static inline xrt_result_t
938{
939 return xdev->begin_feature(xdev, type);
940}
941
942/*!
943 * Helper function for @ref xrt_device::end_feature.
944 *
945 * @copydoc xrt_device::end_feature
946 *
947 * @public @memberof xrt_device
948 */
949static inline xrt_result_t
951{
952 return xdev->end_feature(xdev, type);
953}
954
955/*!
956 * Helper function for @ref xrt_device::destroy.
957 *
958 * Handles nulls, sets your pointer to null.
959 *
960 * @public @memberof xrt_device
961 */
962static inline void
964{
965 struct xrt_device *xdev = *xdev_ptr;
966 if (xdev == NULL) {
967 return;
968 }
969
970 xdev->destroy(xdev);
971 *xdev_ptr = NULL;
972}
973
974
975#ifdef __cplusplus
976} // extern "C"
977#endif
xrt_plane_detection_capability_flags_ext
Caps for a plane detector, see xrt_device.
Definition: xrt_plane_detector.h:30
xrt_visibility_mask_type
Visibility mask, mirror of XrVisibilityMaskKHR.
Definition: xrt_defines.h:2113
xrt_blend_mode
Blend mode that the device supports, exact mirror of XrEnvironmentBlendMode.
Definition: xrt_defines.h:110
xrt_form_factor
What form factor is this device, mostly maps onto OpenXR's XrFormFactor.
Definition: xrt_defines.h:2063
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition: xrt_defines.h:1311
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_reference_space_type
Type of a OpenXR mapped reference space, maps to the semantic spaces on the xrt_space_overseer struct...
Definition: xrt_defines.h:596
xrt_output_name
Name of a output with a baked in type.
Definition: xrt_defines.h:1924
xrt_result
Result type used across Monado.
Definition: xrt_results.h:22
xrt_plane_detector_state_ext
State of a plane detector, see xrt_device.
Definition: xrt_plane_detector.h:83
xrt_device_type
How an xrt_device can be used.
Definition: xrt_defines.h:783
@ XRT_SUCCESS
The operation succeeded.
Definition: xrt_results.h:26
@ XRT_ERROR_NOT_IMPLEMENTED
The interface function called is not implemented by its interface.
Definition: xrt_results.h:186
A binding pair, going from a binding point to a device input.
Definition: xrt_device.h:192
enum xrt_input_name device
To input on the device.
Definition: xrt_device.h:194
enum xrt_input_name from
From which name.
Definition: xrt_device.h:193
A binding pair, going from a binding point to a device output.
Definition: xrt_device.h:203
enum xrt_output_name device
To output on the device.
Definition: xrt_device.h:205
enum xrt_output_name from
From which name.
Definition: xrt_device.h:204
A binding profile, has lists of binding pairs to goes from device in name to the device it hangs off ...
Definition: xrt_device.h:215
enum xrt_device_name name
Device this binding emulates.
Definition: xrt_device.h:217
Definition: xrt_defines.h:1907
Definition: xrt_defines.h:1870
Static data of supported features of the xrt_device this struct sits on.
Definition: xrt_device.h:254
A single HMD or input device.
Definition: xrt_device.h:280
static xrt_result_t xrt_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
Helper function for xrt_device::get_tracked_pose.
Definition: xrt_device.h:674
enum xrt_result(* destroy_plane_detection_ext)(struct xrt_device *xdev, uint64_t plane_detection_id)
Destroy internal resources associated with plane_detector_id.
Definition: xrt_device.h:484
static enum xrt_result xrt_device_get_plane_detections_ext(struct xrt_device *xdev, uint64_t plane_detection_id, struct xrt_plane_detections_ext *out_detections)
Helper function for xrt_device::get_plane_detections.
Definition: xrt_device.h:831
xrt_result_t(* get_body_skeleton)(struct xrt_device *xdev, enum xrt_input_name body_tracking_type, struct xrt_body_skeleton *out_value)
Get the body skeleton in T-pose, used to query the skeleton hierarchy, scale, proportions etc.
Definition: xrt_device.h:414
static xrt_result_t xrt_device_begin_feature(struct xrt_device *xdev, enum xrt_device_feature_type type)
Helper function for xrt_device::begin_feature.
Definition: xrt_device.h:937
static xrt_result_t xrt_device_get_view_poses(struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, int64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
Helper function for xrt_device::get_view_poses.
Definition: xrt_device.h:845
static xrt_result_t xrt_device_get_hand_tracking(struct xrt_device *xdev, enum xrt_input_name name, int64_t desired_timestamp_ns, struct xrt_hand_joint_set *out_value, int64_t *out_timestamp_ns)
Helper function for xrt_device::get_hand_tracking.
Definition: xrt_device.h:690
xrt_result_t(* get_body_joints)(struct xrt_device *xdev, enum xrt_input_name body_tracking_type, int64_t desired_timestamp_ns, struct xrt_body_joint_set *out_value)
Get the joint locations for a body tracker.
Definition: xrt_device.h:430
xrt_result_t(* ref_space_usage)(struct xrt_device *xdev, enum xrt_reference_space_type type, enum xrt_input_name name, bool used)
Called by the xrt_space_overseer when a reference space that is implemented by this device is first u...
Definition: xrt_device.h:599
xrt_result_t(* get_presence)(struct xrt_device *xdev, bool *presence)
Get current presence status of the device.
Definition: xrt_device.h:461
xrt_result_t(* set_output)(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value)
Set a output value.
Definition: xrt_device.h:443
static xrt_result_t xrt_device_update_inputs(struct xrt_device *xdev)
Helper function for xrt_device::update_inputs.
Definition: xrt_device.h:661
static enum xrt_result xrt_device_destroy_plane_detection_ext(struct xrt_device *xdev, uint64_t plane_detection_id)
Helper function for xrt_device::destroy_plane_detection.
Definition: xrt_device.h:807
xrt_result_t(* get_output_limits)(struct xrt_device *xdev, struct xrt_output_limits *limits)
Gets limits of this devices outputs.
Definition: xrt_device.h:453
static xrt_result_t xrt_device_ref_space_usage(struct xrt_device *xdev, enum xrt_reference_space_type type, enum xrt_input_name name, bool used)
Helper function for xrt_device::ref_space_usage.
Definition: xrt_device.h:895
xrt_result_t(* get_hand_tracking)(struct xrt_device *xdev, enum xrt_input_name name, int64_t desired_timestamp_ns, struct xrt_hand_joint_set *out_value, int64_t *out_timestamp_ns)
Get relationship of hand joints to the tracking origin space as the base space.
Definition: xrt_device.h:381
static xrt_result_t xrt_device_get_face_tracking(struct xrt_device *xdev, enum xrt_input_name facial_expression_type, int64_t at_timestamp_ns, struct xrt_facial_expression_set *out_value)
Helper function for xrt_device::get_face_tracking.
Definition: xrt_device.h:707
xrt_result_t(* get_visibility_mask)(struct xrt_device *xdev, enum xrt_visibility_mask_type type, uint32_t view_index, struct xrt_visibility_mask **out_mask)
Get the visibility mask for this device.
Definition: xrt_device.h:580
struct xrt_hmd_parts * hmd
Null if this device does not interface with the users head.
Definition: xrt_device.h:292
xrt_result_t(* get_face_tracking)(struct xrt_device *xdev, enum xrt_input_name facial_expression_type, int64_t at_timestamp_ns, struct xrt_facial_expression_set *out_value)
Get the requested blend shape properties & weights for a face tracker.
Definition: xrt_device.h:399
struct xrt_output * outputs
Array of output structs.
Definition: xrt_device.h:310
xrt_result_t(* begin_feature)(struct xrt_device *xdev, enum xrt_device_feature_type type)
Enable the feature for this device.
Definition: xrt_device.h:635
static xrt_result_t xrt_device_get_presence(struct xrt_device *xdev, bool *presence)
Helper function for xrt_device::get_presence.
Definition: xrt_device.h:778
size_t output_count
Number of outputs.
Definition: xrt_device.h:308
bool(* is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor)
Check if given form factor is available or not.
Definition: xrt_device.h:614
struct xrt_input * inputs
Array of input structs.
Definition: xrt_device.h:305
static xrt_result_t xrt_device_get_body_skeleton(struct xrt_device *xdev, enum xrt_input_name body_tracking_type, struct xrt_body_skeleton *out_value)
Helper function for xrt_device::get_body_skeleton.
Definition: xrt_device.h:723
size_t input_count
Number of inputs.
Definition: xrt_device.h:303
xrt_result_t(* get_battery_status)(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
Get battery status information.
Definition: xrt_device.h:624
enum xrt_result(* get_plane_detections_ext)(struct xrt_device *xdev, uint64_t plane_detection_id, struct xrt_plane_detections_ext *out_detections)
Get results of a plane detection request.
Definition: xrt_device.h:506
void(* destroy)(struct xrt_device *xdev)
Destroy device.
Definition: xrt_device.h:648
xrt_result_t(* get_view_poses)(struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, int64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
Get the per-view pose in relation to the view space.
Definition: xrt_device.h:547
static xrt_result_t xrt_device_end_feature(struct xrt_device *xdev, enum xrt_device_feature_type type)
Helper function for xrt_device::end_feature.
Definition: xrt_device.h:950
xrt_result_t(* update_inputs)(struct xrt_device *xdev)
Update any attached inputs.
Definition: xrt_device.h:327
static xrt_result_t xrt_device_get_body_joints(struct xrt_device *xdev, enum xrt_input_name body_tracking_type, int64_t desired_timestamp_ns, struct xrt_body_joint_set *out_value)
Helper function for xrt_device::get_body_joints.
Definition: xrt_device.h:738
enum xrt_result(* get_plane_detection_state_ext)(struct xrt_device *xdev, uint64_t plane_detection_id, enum xrt_plane_detector_state_ext *out_state)
Get the state of a plane detection request.
Definition: xrt_device.h:494
static enum xrt_result xrt_device_begin_plane_detection_ext(struct xrt_device *xdev, const struct xrt_plane_detector_begin_info_ext *begin_info, uint64_t plane_detection_id, uint64_t *out_plane_detection_id)
Helper function for xrt_device::begin_plane_detection.
Definition: xrt_device.h:793
struct xrt_tracking_origin * tracking_origin
Always set, pointing to the tracking system for this device.
Definition: xrt_device.h:295
xrt_result_t(* end_feature)(struct xrt_device *xdev, enum xrt_device_feature_type type)
Disable the feature for this device.
Definition: xrt_device.h:643
size_t binding_profile_count
Number of bindings in xrt_device::binding_profiles.
Definition: xrt_device.h:298
enum xrt_result(* begin_plane_detection_ext)(struct xrt_device *xdev, const struct xrt_plane_detector_begin_info_ext *begin_info, uint64_t plane_detection_id, uint64_t *out_plane_detection_id)
Begin a plane detection request.
Definition: xrt_device.h:472
static enum xrt_result xrt_device_get_plane_detection_state_ext(struct xrt_device *xdev, uint64_t plane_detection_id, enum xrt_plane_detector_state_ext *out_state)
Helper function for xrt_device::get_plane_detections.
Definition: xrt_device.h:818
enum xrt_device_name name
Enum identifier of the device.
Definition: xrt_device.h:282
static xrt_result_t xrt_device_get_visibility_mask(struct xrt_device *xdev, enum xrt_visibility_mask_type type, uint32_t view_index, struct xrt_visibility_mask **out_mask)
Helper function for xrt_device::get_visibility_mask.
Definition: xrt_device.h:879
static bool xrt_device_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor)
Helper function for xrt_device::is_form_factor_available.
Definition: xrt_device.h:911
static void xrt_device_destroy(struct xrt_device **xdev_ptr)
Helper function for xrt_device::destroy.
Definition: xrt_device.h:963
xrt_result_t(* get_tracked_pose)(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
Get relationship of a tracked device to the tracking origin space as the base space.
Definition: xrt_device.h:353
bool(* compute_distortion)(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
Compute the distortion at a single point.
Definition: xrt_device.h:569
static bool xrt_device_compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
Helper function for xrt_device::compute_distortion.
Definition: xrt_device.h:865
static xrt_result_t xrt_device_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
Helper function for xrt_device::get_battery_status.
Definition: xrt_device.h:924
static xrt_result_t xrt_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value)
Helper function for xrt_device::set_output.
Definition: xrt_device.h:754
Definition: xrt_defines.h:1659
Describes a projection matrix fov.
Definition: xrt_defines.h:483
Joint set type used for hand tracking.
Definition: xrt_defines.h:1410
All of the device components that deals with interfacing to a users head.
Definition: xrt_device.h:92
float * vertices
Data.
Definition: xrt_device.h:134
struct xrt_fov fov[XRT_MAX_VIEWS]
distortion is subject to the field of view
Definition: xrt_device.h:153
uint32_t vertex_count
Number of vertices.
Definition: xrt_device.h:136
struct xrt_hmd_parts::@242 distortion
Distortion information.
struct xrt_view views[XRT_MAX_VIEWS]
Display information.
Definition: xrt_device.h:112
uint64_t nominal_frame_interval_ns
Nominal frame interval.
Definition: xrt_device.h:104
uint32_t stride
Stride of vertices.
Definition: xrt_device.h:138
enum xrt_blend_mode blend_modes[XRT_MAX_DEVICE_BLEND_MODES]
Array of supported blend modes.
Definition: xrt_device.h:118
int * indices
Indices, for triangle strip.
Definition: xrt_device.h:143
enum xrt_distortion_model models
Supported distortion models, a bitfield.
Definition: xrt_device.h:127
struct xrt_hmd_parts::@241 screens[1]
The hmd screen as an unrotated display, like the HMD presents it to the OS.
uint32_t index_count_total
Total number of elements in mesh::indices array.
Definition: xrt_device.h:149
uint32_t index_offsets[XRT_MAX_VIEWS]
Offsets for the indices (one offset per view).
Definition: xrt_device.h:147
uint32_t uv_channels_count
1 or 3 for (chromatic aberration).
Definition: xrt_device.h:140
enum xrt_distortion_model preferred
Preferred disortion model, single value.
Definition: xrt_device.h:129
uint32_t index_counts[XRT_MAX_VIEWS]
Number of indices for the triangle strips (one per view).
Definition: xrt_device.h:145
A single named input, that sits on a xrt_device.
Definition: xrt_device.h:163
XRT_ALIGNAS(8) int64_t timestamp
alignas for 32 bit client support, see IPC Design and Implementation
bool active
Is this input active.
Definition: xrt_device.h:165
A tightly packed 2x2 matrix of floats.
Definition: xrt_defines.h:510
Output limits of a particular device.
Definition: xrt_device.h:240
float haptic_pcm_sample_rate
The sample rate of the device's haptic PCM support, 0 if haptic PCM is not supported.
Definition: xrt_device.h:242
A union of all output types.
Definition: xrt_defines.h:2040
A single named output, that sits on a xrt_device.
Definition: xrt_device.h:181
Each plane has n polygons; ultimately plane metadata from locations and vetices is reconstructed.
Definition: xrt_plane_detector.h:171
A query for a plane.
Definition: xrt_plane_detector.h:97
A pose composed of a position and orientation.
Definition: xrt_defines.h:463
A relation with two spaces, includes velocity and acceleration.
Definition: xrt_defines.h:654
A tracking system or device origin.
Definition: xrt_tracking.h:71
Represents a uv triplet for distortion, basically just three xrt_vec2.
Definition: xrt_defines.h:263
A 3 element vector with single floats.
Definition: xrt_defines.h:273
A per-lens/display view information.
Definition: xrt_device.h:35
struct xrt_matrix_2x2 rot
Rotation 2d matrix used to rotate the position of the output of the distortion shaders onto the scree...
Definition: xrt_device.h:81
struct xrt_view::@240 display
Physical properties of this display (or the part of a display that covers this view).
struct xrt_view::@239 viewport
Viewport position on the screen.
Visibility mask helper, the indices and vertices are tightly packed after this struct.
Definition: xrt_visibility_mask.h:25
A union of all input types.
Definition: xrt_defines.h:1426
Common defines and enums for XRT.
xrt_distortion_model
Which distortion model does the device expose, used both as a bitfield and value.
Definition: xrt_defines.h:165
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:708
xrt_device_feature_type
Higher level features for devices.
Definition: xrt_device.h:229
Header for limits of the XRT interfaces.
Header defining planes detector enum and structs.
Header defining visibility mask helper struct.