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