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 bool brightness_control;
268
269 bool planes;
270 enum xrt_plane_detection_capability_flags_ext plane_capability_flags;
271};
272
273/*!
274 * @interface xrt_device
275 *
276 * A single HMD or input device.
277 *
278 * @ingroup xrt_iface
279 */
281{
282 //! Enum identifier of the device.
284 enum xrt_device_type device_type;
285
286 //! A string describing the device.
287 char str[XRT_DEVICE_NAME_LEN];
288
289 //! A unique identifier. Persistent across configurations, if possible.
290 char serial[XRT_DEVICE_NAME_LEN];
291
292 //! Null if this device does not interface with the users head.
294
295 //! Always set, pointing to the tracking system for this device.
297
298 //! Number of bindings in xrt_device::binding_profiles
300 // Array of alternative binding profiles.
301 struct xrt_binding_profile *binding_profiles;
302
303 //! Number of inputs.
305 //! Array of input structs.
307
308 //! Number of outputs.
310 //! Array of output structs.
312
313 //! What features/functions/things does this device supports?
314 struct xrt_device_supported supported;
315
316
317 /*
318 *
319 * Functions.
320 *
321 */
322
323 /*!
324 * Update any attached inputs.
325 *
326 * @param[in] xdev The device.
327 */
328 xrt_result_t (*update_inputs)(struct xrt_device *xdev);
329
330 /*!
331 * @brief Get relationship of a tracked device to the tracking origin
332 * space as the base space.
333 *
334 * It is the responsibility of the device driver to do any prediction,
335 * there are helper functions available for this.
336 *
337 * The timestamps are system monotonic timestamps, such as returned by
338 * os_monotonic_get_ns().
339 *
340 * @param[in] xdev The device.
341 * @param[in] name Some devices may have multiple poses on
342 * them, select the one using this field. For
343 * HMDs use @p XRT_INPUT_GENERIC_HEAD_POSE.
344 * For Unbounded Reference Space you can use
345 * @p XRT_INPUT_GENERIC_UNBOUNDED_SPACE_POSE
346 * to get the origin of that space.
347 * @param[in] at_timestamp_ns If the device can predict or has a history
348 * of positions, this is when the caller
349 * wants the pose to be from.
350 * @param[out] out_relation The relation read from the device.
351 *
352 * @see xrt_input_name
353 */
355 enum xrt_input_name name,
356 int64_t at_timestamp_ns,
357 struct xrt_space_relation *out_relation);
358
359 /*!
360 * @brief Get relationship of hand joints to the tracking origin space as
361 * the base space.
362 *
363 * It is the responsibility of the device driver to either do prediction
364 * or return joints from a previous time and write that time out to
365 * @p out_timestamp_ns.
366 *
367 * The timestamps are system monotonic timestamps, such as returned by
368 * os_monotonic_get_ns().
369 *
370 * @param[in] xdev The device.
371 * @param[in] name Some devices may have multiple poses on
372 * them, select the one using this field. For
373 * hand tracking use @p XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET.
374 * @param[in] desired_timestamp_ns If the device can predict or has a history
375 * of positions, this is when the caller
376 * wants the pose to be from.
377 * @param[out] out_value The hand joint data read from the device.
378 * @param[out] out_timestamp_ns The timestamp of the data being returned.
379 *
380 * @see xrt_input_name
381 */
382 xrt_result_t (*get_hand_tracking)(struct xrt_device *xdev,
383 enum xrt_input_name name,
384 int64_t desired_timestamp_ns,
385 struct xrt_hand_joint_set *out_value,
386 int64_t *out_timestamp_ns);
387
388 /*!
389 * @brief Get the requested blend shape properties & weights for a face tracker
390 *
391 * @param[in] xdev The device.
392 * @param[in] facial_expression_type The facial expression data type (XR_FB_face_tracking,
393 * XR_HTC_facial_tracking, etc).
394 * @param[in] at_timestamp_ns Timestamp to be optionally used for prediction/history. For OXR extensions
395 * that do not pass a timestamp, the current timestamp is used.
396 * @param[in] out_value Set of requested expression weights & blend shape properties.
397 *
398 * @see xrt_input_name
399 */
400 xrt_result_t (*get_face_tracking)(struct xrt_device *xdev,
401 enum xrt_input_name facial_expression_type,
402 int64_t at_timestamp_ns,
403 struct xrt_facial_expression_set *out_value);
404
405 /*!
406 * @brief Get the body skeleton in T-pose, used to query the skeleton hierarchy, scale, proportions etc
407 *
408 * @param[in] xdev The device.
409 * @param[in] body_tracking_type The body joint set type (XR_FB_body_tracking,
410 * XR_META_body_tracking_full_body, etc).
411 * @param[in] out_value The body skeleton hierarchy/properties.
412 *
413 * @see xrt_input_name
414 */
415 xrt_result_t (*get_body_skeleton)(struct xrt_device *xdev,
416 enum xrt_input_name body_tracking_type,
417 struct xrt_body_skeleton *out_value);
418
419 /*!
420 * @brief Get the joint locations for a body tracker
421 *
422 * @param[in] xdev The device.
423 * @param[in] body_tracking_type The body joint set type (XR_FB_body_tracking,
424 * XR_META_body_tracking_full_body, etc).
425 * @param[in] desired_timestamp_ns If the device can predict or has a history
426 * of locations, this is when the caller
427 * @param[in] out_value Set of body joint locations & properties.
428 *
429 * @see xrt_input_name
430 */
431 xrt_result_t (*get_body_joints)(struct xrt_device *xdev,
432 enum xrt_input_name body_tracking_type,
433 int64_t desired_timestamp_ns,
434 struct xrt_body_joint_set *out_value);
435
436 /*!
437 * Set a output value.
438 *
439 * @param[in] xdev The device.
440 * @param[in] name The output component name to set.
441 * @param[in] value The value to set the output to.
442 * @see xrt_output_name
443 */
444 xrt_result_t (*set_output)(struct xrt_device *xdev,
446 const struct xrt_output_value *value);
447
448 /*!
449 * Gets limits of this devices outputs.
450 *
451 * @param[in] xdev The device.
452 * @param[out] limits The returned limits.
453 */
454 xrt_result_t (*get_output_limits)(struct xrt_device *xdev, struct xrt_output_limits *limits);
455
456 /*!
457 * @brief Get current presence status of the device.
458 *
459 * @param[in] xdev The device.
460 * @param[out] presence The returned presence status.
461 */
462 xrt_result_t (*get_presence)(struct xrt_device *xdev, bool *presence);
463
464 /*!
465 * Begin a plane detection request
466 *
467 * @param[in] xdev The device.
468 * @param[in] begin_info The query specifying what type of planes are requested.
469 * @param[in] plane_detection_id The id for a previous plane detection request to be replaced or 0.
470 * @param[out] out_plane_detection_id The id of the new plane detection request generated by the xdev.
471 * @return generally XRT_SUCCESS, except for internal runtime failures.
472 */
474 const struct xrt_plane_detector_begin_info_ext *begin_info,
475 uint64_t plane_detection_id,
476 uint64_t *out_plane_detection_id);
477
478 /*!
479 * Destroy internal resources associated with plane_detector_id.
480 *
481 * @param[in] xdev The device.
482 * @param[in] plane_detection_id An id generated by the xdev.
483 * @return generally XRT_SUCCESS, except for internal runtime failures.
484 */
485 enum xrt_result (*destroy_plane_detection_ext)(struct xrt_device *xdev, uint64_t plane_detection_id);
486
487 /*!
488 * Get the state of a plane detection request.
489 *
490 * @param[in] xdev The device.
491 * @param[in] plane_detector_id An id generated by the xdev.
492 * @param[out] out_state The state of the plane detection.
493 * @return generally XRT_SUCCESS, except for internal runtime failures.
494 */
496 uint64_t plane_detection_id,
497 enum xrt_plane_detector_state_ext *out_state);
498
499 /*!
500 * Get results of a plane detection request.
501 *
502 * @param[in] xdev The device.
503 * @param[in] plane_detector_id An id generated by the xdev.
504 * @param[out] detections The detected planes, if any.
505 * @return generally XRT_SUCCESS, except for internal runtime failures.
506 */
508 uint64_t plane_detection_id,
509 struct xrt_plane_detections_ext *out_detections);
510
511 /*!
512 * @brief Get the per-view pose in relation to the view space.
513 *
514 * On most devices with coplanar displays and no built-in eye tracking
515 * or IPD sensing, this just calls a helper to process the provided
516 * eye relation, but this may also handle canted displays as well as
517 * eye tracking.
518 *
519 * Incorporates a call to xrt_device::get_tracked_pose or a wrapper for it
520 *
521 * @param[in] xdev The device.
522 * @param[in] default_eye_relation
523 * The interpupillary relation as a 3D position.
524 * Most simple stereo devices would just want to
525 * set `out_pose->position.[x|y|z] = ipd.[x|y|z]
526 * / 2.0f` and adjust for left vs right view.
527 * Not to be confused with IPD that is absolute
528 * distance, this is a full 3D translation
529 * If a device has a more accurate/dynamic way of
530 * knowing the eye relation, it may ignore this
531 * input.
532 * @param[in] at_timestamp_ns This is when the caller wants the poses and FOVs to be from.
533 * @param[in] view_count Number of views.
534 * @param[out] out_head_relation
535 * The head pose in the device tracking space.
536 * Combine with @p out_poses to get the views in
537 * device tracking space.
538 * @param[out] out_fovs An array (of size @p view_count ) to populate
539 * with the device-suggested fields of view.
540 * @param[out] out_poses An array (of size @p view_count ) to populate
541 * with view output poses in head space. When
542 * implementing, be sure to also set orientation:
543 * most likely identity orientation unless you
544 * have canted screens.
545 * (Caution: Even if you have eye tracking, you
546 * won't use eye orientation here!)
547 */
548 xrt_result_t (*get_view_poses)(struct xrt_device *xdev,
549 const struct xrt_vec3 *default_eye_relation,
550 int64_t at_timestamp_ns,
551 uint32_t view_count,
552 struct xrt_space_relation *out_head_relation,
553 struct xrt_fov *out_fovs,
554 struct xrt_pose *out_poses);
555
556 /**
557 * Compute the distortion at a single point.
558 *
559 * The input is @p u @p v in screen/output space (that is, predistorted), you are to compute and return the u,v
560 * coordinates to sample the render texture. The compositor will step through a range of u,v parameters to build
561 * the lookup (vertex attribute or distortion texture) used to pre-distort the image as required by the device's
562 * optics.
563 *
564 * @param xdev the device
565 * @param view the view index
566 * @param u horizontal texture coordinate
567 * @param v vertical texture coordinate
568 * @param[out] out_result corresponding u,v pairs for all three color channels.
569 */
570 bool (*compute_distortion)(
571 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result);
572
573 /*!
574 * Get the visibility mask for this device.
575 *
576 * @param[in] xdev The device.
577 * @param[in] type The type of visibility mask.
578 * @param[in] view_index The index of the view to get the mask for.
579 * @param[out] out_mask Output mask, caller must free.
580 */
581 xrt_result_t (*get_visibility_mask)(struct xrt_device *xdev,
582 enum xrt_visibility_mask_type type,
583 uint32_t view_index,
584 struct xrt_visibility_mask **out_mask);
585
586 /*!
587 * Called by the @ref xrt_space_overseer when a reference space that is
588 * implemented by this device is first used, or when the last usage of
589 * the reference space stops.
590 *
591 * What is provided is both the @ref xrt_reference_space_type that
592 * triggered the usage change and the @ref xrt_input_name (if any) that
593 * is used to drive the space.
594 *
595 * @see xrt_space_overseer_ref_space_inc
596 * @see xrt_space_overseer_ref_space_dec
597 * @see xrt_input_name
598 * @see xrt_reference_space_type
599 */
600 xrt_result_t (*ref_space_usage)(struct xrt_device *xdev,
601 enum xrt_reference_space_type type,
602 enum xrt_input_name name,
603 bool used);
604
605 /*!
606 * @brief Check if given form factor is available or not.
607 *
608 * This should only be used in HMD device, if the device driver supports form factor check.
609 *
610 * @param[in] xdev The device.
611 * @param[in] form_factor Form factor to check.
612 *
613 * @return true if given form factor is available; otherwise false.
614 */
615 bool (*is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor);
616
617 /*!
618 * @brief Get battery status information.
619 *
620 * @param[in] xdev The device.
621 * @param[out] out_present Whether battery status information exist for this device.
622 * @param[out] out_charging Whether the device's battery is being charged.
623 * @param[out] out_charge Battery charge as a value between 0 and 1.
624 */
626 bool *out_present,
627 bool *out_charging,
628 float *out_charge);
629
630 /*!
631 * @brief Get the current display brightness.
632 *
633 * @param[in] xdev The device.
634 * @param[out] out_brightness Current display brightness. Usually between 0 and 1. Some devices may
635 * exceed 1 if the supported range exceeds 100%
636 */
637 xrt_result_t (*get_brightness)(struct xrt_device *xdev, float *out_brightness);
638
639 /*!
640 * @brief Set the display brightness.
641 *
642 * @param[in] xdev The device.
643 * @param[in] brightness Desired display brightness. Usually between 0 and 1. Some devices may
644 * allow exceeding 1 if the supported range exceeds 100%, but it will be clamped to
645 * the supported range.
646 * @param[in] relative Whether to add \a brightness to the current brightness, instead of overwriting
647 * the current brightness.
648 */
649 xrt_result_t (*set_brightness)(struct xrt_device *xdev, float brightness, bool relative);
650
651 /*!
652 * Enable the feature for this device.
653 *
654 * @param[in] xdev The device.
655 * @param[in] type The type of device feature.
656 */
658
659 /*!
660 * Disable the feature for this device.
661 *
662 * @param[in] xdev The device.
663 * @param[in] type The type of device feature.
664 */
666
667 /*!
668 * Destroy device.
669 */
670 void (*destroy)(struct xrt_device *xdev);
671
672 // Add new functions above destroy.
673};
674
675/*!
676 * Helper function for @ref xrt_device::update_inputs.
677 *
678 * @copydoc xrt_device::update_inputs
679 *
680 * @public @memberof xrt_device
681 */
682static inline xrt_result_t
684{
685 return xdev->update_inputs(xdev);
686}
687
688/*!
689 * Helper function for @ref xrt_device::get_tracked_pose.
690 *
691 * @copydoc xrt_device::get_tracked_pose
692 *
693 * @public @memberof xrt_device
694 */
695static inline xrt_result_t
697 enum xrt_input_name name,
698 int64_t at_timestamp_ns,
699 struct xrt_space_relation *out_relation)
700{
701 return xdev->get_tracked_pose(xdev, name, at_timestamp_ns, out_relation);
702}
703
704/*!
705 * Helper function for @ref xrt_device::get_hand_tracking.
706 *
707 * @copydoc xrt_device::get_hand_tracking
708 *
709 * @public @memberof xrt_device
710 */
711static inline xrt_result_t
713 enum xrt_input_name name,
714 int64_t desired_timestamp_ns,
715 struct xrt_hand_joint_set *out_value,
716 int64_t *out_timestamp_ns)
717{
718 return xdev->get_hand_tracking(xdev, name, desired_timestamp_ns, out_value, out_timestamp_ns);
719}
720
721/*!
722 * Helper function for @ref xrt_device::get_face_tracking.
723 *
724 * @copydoc xrt_device::get_face_tracking
725 *
726 * @public @memberof xrt_device
727 */
728static inline xrt_result_t
730 enum xrt_input_name facial_expression_type,
731 int64_t at_timestamp_ns,
732 struct xrt_facial_expression_set *out_value)
733{
734 return xdev->get_face_tracking(xdev, facial_expression_type, at_timestamp_ns, out_value);
735}
736
737/*!
738 * Helper function for @ref xrt_device::get_body_skeleton.
739 *
740 * @copydoc xrt_device::get_body_skeleton
741 *
742 * @public @memberof xrt_device
743 */
744static inline xrt_result_t
746 enum xrt_input_name body_tracking_type,
747 struct xrt_body_skeleton *out_value)
748{
749 return xdev->get_body_skeleton(xdev, body_tracking_type, out_value);
750}
751
752/*!
753 * Helper function for @ref xrt_device::get_body_joints.
754 *
755 * @copydoc xrt_device::get_body_joints
756 *
757 * @public @memberof xrt_device
758 */
759static inline xrt_result_t
761 enum xrt_input_name body_tracking_type,
762 int64_t desired_timestamp_ns,
763 struct xrt_body_joint_set *out_value)
764{
765 return xdev->get_body_joints(xdev, body_tracking_type, desired_timestamp_ns, out_value);
766}
767
768/*!
769 * Helper function for @ref xrt_device::set_output.
770 *
771 * @copydoc xrt_device::set_output
772 *
773 * @public @memberof xrt_device
774 */
775static inline xrt_result_t
777{
778 xdev->set_output(xdev, name, value);
779 return XRT_SUCCESS;
780}
781
782static inline xrt_result_t
783xrt_device_get_output_limits(struct xrt_device *xdev, struct xrt_output_limits *limits)
784{
785 if (xdev->get_output_limits) {
786 return xdev->get_output_limits(xdev, limits);
787 } else {
789 }
790}
791
792/*!
793 * Helper function for @ref xrt_device::get_presence.
794 *
795 * @copydoc xrt_device::get_presence
796 *
797 * @public @memberof xrt_device
798 */
799static inline xrt_result_t
800xrt_device_get_presence(struct xrt_device *xdev, bool *presence)
801{
802 if (xdev->get_presence) {
803 return xdev->get_presence(xdev, presence);
804 } else {
806 }
807}
808
809/*!
810 * Helper function for @ref xrt_device::begin_plane_detection.
811 *
812 * @public @memberof xrt_device
813 */
814static inline enum xrt_result
816 const struct xrt_plane_detector_begin_info_ext *begin_info,
817 uint64_t plane_detection_id,
818 uint64_t *out_plane_detection_id)
819{
820 return xdev->begin_plane_detection_ext(xdev, begin_info, plane_detection_id, out_plane_detection_id);
821}
822
823/*!
824 * Helper function for @ref xrt_device::destroy_plane_detection.
825 *
826 * @public @memberof xrt_device
827 */
828static inline enum xrt_result
829xrt_device_destroy_plane_detection_ext(struct xrt_device *xdev, uint64_t plane_detection_id)
830{
831 return xdev->destroy_plane_detection_ext(xdev, plane_detection_id);
832}
833
834/*!
835 * Helper function for @ref xrt_device::get_plane_detections.
836 *
837 * @public @memberof xrt_device
838 */
839static inline enum xrt_result
841 uint64_t plane_detection_id,
842 enum xrt_plane_detector_state_ext *out_state)
843{
844 return xdev->get_plane_detection_state_ext(xdev, plane_detection_id, out_state);
845}
846
847/*!
848 * Helper function for @ref xrt_device::get_plane_detections.
849 *
850 * @public @memberof xrt_device
851 */
852static inline enum xrt_result
854 uint64_t plane_detection_id,
855 struct xrt_plane_detections_ext *out_detections)
856{
857 return xdev->get_plane_detections_ext(xdev, plane_detection_id, out_detections);
858}
859
860/*!
861 * Helper function for @ref xrt_device::get_view_poses.
862 *
863 * @copydoc xrt_device::get_view_poses
864 * @public @memberof xrt_device
865 */
866static inline xrt_result_t
868 const struct xrt_vec3 *default_eye_relation,
869 int64_t at_timestamp_ns,
870 uint32_t view_count,
871 struct xrt_space_relation *out_head_relation,
872 struct xrt_fov *out_fovs,
873 struct xrt_pose *out_poses)
874{
875 return xdev->get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation,
876 out_fovs, out_poses);
877}
878
879/*!
880 * Helper function for @ref xrt_device::compute_distortion.
881 *
882 * @copydoc xrt_device::compute_distortion
883 *
884 * @public @memberof xrt_device
885 */
886static inline bool
888 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
889{
890 return xdev->compute_distortion(xdev, view, u, v, out_result);
891}
892
893/*!
894 * Helper function for @ref xrt_device::get_visibility_mask.
895 *
896 * @copydoc xrt_device::get_visibility_mask
897 *
898 * @public @memberof xrt_device
899 */
900static inline xrt_result_t
902 enum xrt_visibility_mask_type type,
903 uint32_t view_index,
904 struct xrt_visibility_mask **out_mask)
905{
906 return xdev->get_visibility_mask(xdev, type, view_index, out_mask);
907}
908
909/*!
910 * Helper function for @ref xrt_device::ref_space_usage.
911 *
912 * @copydoc xrt_device::ref_space_usage
913 *
914 * @public @memberof xrt_device
915 */
916static inline xrt_result_t
918 enum xrt_reference_space_type type,
919 enum xrt_input_name name,
920 bool used)
921{
922 return xdev->ref_space_usage(xdev, type, name, used);
923}
924
925/*!
926 * Helper function for @ref xrt_device::is_form_factor_available.
927 *
928 * @copydoc xrt_device::is_form_factor_available
929 *
930 * @public @memberof xrt_device
931 */
932static inline bool
934{
935 return xdev->is_form_factor_available(xdev, form_factor);
936}
937
938/*!
939 * Helper function for @ref xrt_device::get_battery_status.
940 *
941 * @copydoc xrt_device::get_battery_status
942 *
943 * @public @memberof xrt_device
944 */
945static inline xrt_result_t
946xrt_device_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
947{
948 return xdev->get_battery_status(xdev, out_present, out_charging, out_charge);
949}
950
951/*!
952 * Helper function for @ref xrt_device::get_brightness.
953 *
954 * @copydoc xrt_device::get_brightness
955 * @public @memberof xrt_device
956 */
957static inline xrt_result_t
958xrt_device_get_brightness(struct xrt_device *xdev, float *out_brightness)
959{
960 return xdev->get_brightness(xdev, out_brightness);
961}
962
963/*!
964 * Helper function for @ref xrt_device::set_brightness.
965 *
966 * @copydoc xrt_device::set_brightness
967 * @public @memberof xrt_device
968 */
969static inline xrt_result_t
970xrt_device_set_brightness(struct xrt_device *xdev, float brightness, bool relative)
971{
972 return xdev->set_brightness(xdev, brightness, relative);
973}
974
975/*!
976 * Helper function for @ref xrt_device::begin_feature.
977 *
978 * @copydoc xrt_device::begin_feature
979 *
980 * @public @memberof xrt_device
981 */
982static inline xrt_result_t
984{
985 return xdev->begin_feature(xdev, type);
986}
987
988/*!
989 * Helper function for @ref xrt_device::end_feature.
990 *
991 * @copydoc xrt_device::end_feature
992 *
993 * @public @memberof xrt_device
994 */
995static inline xrt_result_t
997{
998 return xdev->end_feature(xdev, type);
999}
1000
1001/*!
1002 * Helper function for @ref xrt_device::destroy.
1003 *
1004 * Handles nulls, sets your pointer to null.
1005 *
1006 * @public @memberof xrt_device
1007 */
1008static inline void
1010{
1011 struct xrt_device *xdev = *xdev_ptr;
1012 if (xdev == NULL) {
1013 return;
1014 }
1015
1016 xdev->destroy(xdev);
1017 *xdev_ptr = NULL;
1018}
1019
1020
1021#ifdef __cplusplus
1022} // extern "C"
1023#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:2115
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:2065
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition: xrt_defines.h:1313
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:1926
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:1909
Definition: xrt_defines.h:1872
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:281
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:696
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:485
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:853
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:415
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:983
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:867
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:712
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:431
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:600
xrt_result_t(* get_presence)(struct xrt_device *xdev, bool *presence)
Get current presence status of the device.
Definition: xrt_device.h:462
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:444
static xrt_result_t xrt_device_update_inputs(struct xrt_device *xdev)
Helper function for xrt_device::update_inputs.
Definition: xrt_device.h:683
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:829
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:454
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:917
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:382
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:729
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:581
struct xrt_hmd_parts * hmd
Null if this device does not interface with the users head.
Definition: xrt_device.h:293
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:400
struct xrt_output * outputs
Array of output structs.
Definition: xrt_device.h:311
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:657
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:800
size_t output_count
Number of outputs.
Definition: xrt_device.h:309
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:615
xrt_result_t(* set_brightness)(struct xrt_device *xdev, float brightness, bool relative)
Set the display brightness.
Definition: xrt_device.h:649
struct xrt_input * inputs
Array of input structs.
Definition: xrt_device.h:306
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:745
size_t input_count
Number of inputs.
Definition: xrt_device.h:304
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:625
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:507
void(* destroy)(struct xrt_device *xdev)
Destroy device.
Definition: xrt_device.h:670
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:548
xrt_result_t(* get_brightness)(struct xrt_device *xdev, float *out_brightness)
Get the current display brightness.
Definition: xrt_device.h:637
static xrt_result_t xrt_device_set_brightness(struct xrt_device *xdev, float brightness, bool relative)
Helper function for xrt_device::set_brightness.
Definition: xrt_device.h:970
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:996
xrt_result_t(* update_inputs)(struct xrt_device *xdev)
Update any attached inputs.
Definition: xrt_device.h:328
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:760
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:495
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:815
struct xrt_tracking_origin * tracking_origin
Always set, pointing to the tracking system for this device.
Definition: xrt_device.h:296
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:665
size_t binding_profile_count
Number of bindings in xrt_device::binding_profiles.
Definition: xrt_device.h:299
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:473
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:840
enum xrt_device_name name
Enum identifier of the device.
Definition: xrt_device.h:283
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:901
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:933
static xrt_result_t xrt_device_get_brightness(struct xrt_device *xdev, float *out_brightness)
Helper function for xrt_device::get_brightness.
Definition: xrt_device.h:958
static void xrt_device_destroy(struct xrt_device **xdev_ptr)
Helper function for xrt_device::destroy.
Definition: xrt_device.h:1009
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:354
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:570
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:887
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:946
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:776
Definition: xrt_defines.h:1661
Describes a projection matrix fov.
Definition: xrt_defines.h:483
Joint set type used for hand tracking.
Definition: xrt_defines.h:1412
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
struct xrt_hmd_parts::@242 screens[1]
The hmd screen as an unrotated display, like the HMD presents it to the OS.
uint32_t vertex_count
Number of vertices.
Definition: xrt_device.h:136
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
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
struct xrt_hmd_parts::@243 distortion
Distortion information.
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:2042
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_view::@241 display
Physical properties of this display (or the part of a display that covers this view).
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 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:1428
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.