Monado OpenXR Runtime
xrt_prober.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Common interface to probe for devices.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup xrt_iface
9 */
10
11#pragma once
12
13#include "xrt/xrt_device.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
20/*
21 *
22 * Prober and device manager.
23 *
24 */
25
26struct cJSON;
27typedef struct cJSON cJSON;
28
29struct xrt_fs;
31struct xrt_prober;
32struct xrt_prober_entry;
35struct xrt_auto_prober;
37struct xrt_builder;
41struct os_hid_device;
42
43/*!
44 * The maximum number of devices that a single
45 * @ref xrt_prober_entry::found or
46 * @ref xrt_auto_prober::lelo_dallas_autoprobe
47 * function called by the prober can create per-call.
48 *
49 * @ingroup xrt_iface
50 */
51#define XRT_MAX_DEVICES_PER_PROBE 16
52
53/*!
54 * The maximum number of @ref xrt_auto_prober instances that can be handled.
55 *
56 * @ingroup xrt_iface
57 */
58#define XRT_MAX_AUTO_PROBERS 16
59
60/*!
61 * Bus type of a device.
62 */
64{
65 XRT_BUS_TYPE_UNKNOWN,
66 XRT_BUS_TYPE_USB,
67 XRT_BUS_TYPE_BLUETOOTH,
68};
69
70/*!
71 * String descriptor types
72 */
74{
75 XRT_PROBER_STRING_MANUFACTURER,
76 XRT_PROBER_STRING_PRODUCT,
77 XRT_PROBER_STRING_SERIAL_NUMBER,
78};
79
80/*!
81 * A probed device, may or may not be opened.
82 *
83 * @ingroup xrt_iface
84 */
86{
87 /*!
88 * USB/Bluetooth vendor ID (VID)
89 */
90 uint16_t vendor_id;
91
92 /*!
93 * USB/Bluetooth product ID (PID)
94 */
95 uint16_t product_id;
96
97 /*!
98 * Device bus type
99 */
101
102 /*!
103 * USB device class
104 */
106};
107
108/*!
109 * Callback for listing video devices.
110 *
111 * @param xp Prober
112 * @param pdev Prober device being iterated
113 * @param product Product string, if available
114 * @param manufacturer Manufacturer string, if available
115 * @param serial Serial number string, if available
116 * @param ptr Your opaque userdata pointer as provided to @ref xrt_prober_list_video_devices
117 * @ingroup xrt_iface
118 */
119typedef void (*xrt_prober_list_video_func_t)(struct xrt_prober *xp,
120 struct xrt_prober_device *pdev,
121 const char *product,
122 const char *manufacturer,
123 const char *serial,
124 void *ptr);
125
126/*!
127 * The main prober that probes and manages found but not opened HMD devices
128 * that are connected to the system.
129 *
130 * @ingroup xrt_iface
131 */
133{
134 //! Factory for producing tracked objects.
136
137 /*!
138 * Enumerate all connected devices, whether or not we have an associated
139 * driver. Cannot be called with the device list is locked
140 * @ref xrt_prober::lock_list and @ref xrt_prober::unlock_list.
141 *
142 * This function along with lock/unlock allows a @ref xrt_builder to
143 * re-probe the devices after having opened another device. A bit more
144 * detailed: It can get a list of devices, search it, open the enabling
145 * one, release the list, do a probe, get the list again and re-scan
146 * to detect any additional devices that may show up once the first
147 * device has been been started.
148 *
149 * @see xrt_prober::lock_list, xrt_prober::unlock_list
150 */
152
153 /*!
154 * Locks the prober list of probed devices and returns it.
155 * While locked, calling @ref xrt_prober::probe is forbidden. Not thread safe.
156 *
157 * See @ref xrt_prober::probe for more detailed expected usage.
158 *
159 * @see xrt_prober::probe, xrt_prober::unlock_list
160 */
162 struct xrt_prober_device ***out_devices,
163 size_t *out_device_count);
164
165 /*!
166 * Unlocks the list, allowing for @ref xrt_prober::probe to be called.
167 * Takes a pointer to the list pointer and clears it. Not thread safe.
168 * See @ref xrt_prober::probe for more detailed expected usage.
169 *
170 * @see xrt_prober::probe, xrt_prober::lock_list
171 */
172 xrt_result_t (*unlock_list)(struct xrt_prober *xp, struct xrt_prober_device ***devices);
173
174 /*!
175 * Dump a listing of all devices found on the system to logging system
176 * or platform dependent output (stdout).
177 *
178 * @param[in] xp Prober self parameter.
179 * @param[in] use_stdout If true uses stdout instead of logging code.
180 *
181 * @note Code consuming this interface should use xrt_prober_dump()
182 */
183 int (*dump)(struct xrt_prober *xp, bool use_stdout);
184
185 /*!
186 * Create system devices.
187 *
188 * @param[in] xp Prober self parameter.
189 * @param[in] broadcast Event sink that broadcasts events to all sessions.
190 * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
191 * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
192 *
193 * @note Code consuming this interface should use xrt_prober_create_system()
194 */
196 struct xrt_session_event_sink *broadcast,
197 struct xrt_system_devices **out_xsysd,
198 struct xrt_space_overseer **out_xso);
199
200 /*!
201 * Iterate through drivers (by ID and auto-probers) checking to see if
202 * they can handle any connected devices from the last xrt_prober::probe
203 * call, opening those devices to create instances of xrt_device
204 * implementations.
205 *
206 * If no HMD (not even a simulated HMD) is found, then no devices will be
207 * returned (all xdevs will be NULL). Otherwise, xdevs will be populated
208 * with the HMD in xdevs[0], and any subsequent non-NULL values
209 * referring to additional non-HMD devices.
210 *
211 * @param xp Pointer to self
212 * @param[in,out] xdevs Pointer to xrt_device array. Array elements will
213 * be populated.
214 * @param[in] xdev_capacity The capacity of the @p xdevs array.
215 *
216 * @return 0 on success (including "no HMD found"), <0 on error.
217 *
218 * Returned devices have their ownership transferred to the caller: all
219 * should be cleaned up with xrt_device_destroy().
220 *
221 * @note Code consuming this interface should use
222 * xrt_prober_select(). Typically used through an xrt_instance and the
223 * xrt_instance_select() method which usually calls xrt_prober_probe()
224 * and xrt_prober_select().
225 */
226 int (*select)(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity);
227
228 /*!
229 * Open a HID (Human Interface Device) interface using native HID support.
230 *
231 * @param xp Pointer to self
232 * @param xpdev prober device
233 * @param iface HID interface number
234 * @param[out] out_hid_dev instance of @ref os_hid_device for the given interface
235 *
236 * @return 0 on success, <0 on error.
237 */
239 struct xrt_prober_device *xpdev,
240 int iface,
241 struct os_hid_device **out_hid_dev);
242
243 /*!
244 * Opens the selected video device and returns a @ref xrt_fs, does not
245 * start it.
246 */
247 int (*open_video_device)(struct xrt_prober *xp,
248 struct xrt_prober_device *xpdev,
249 struct xrt_frame_context *xfctx,
250 struct xrt_fs **out_xfs);
251
252 /*!
253 * Iterate through available video devices, calling your callback @p cb with your userdata @p ptr.
254 *
255 * @param xp Pointer to self
256 * @param cb Callback function
257 * @param ptr Opaque pointer for your userdata, passed through to the callback.
258 *
259 * @see xrt_prober_list_video_func_t
260 * @return 0 on success, <0 on error.
261 */
263
264 /*!
265 * Retrieve the raw @ref xrt_builder, @ref xrt_prober_entry and @ref xrt_auto_prober arrays.
266 *
267 * @param xp Pointer to self
268 * @param[out] out_builder_count The size of @p out_builders
269 * @param[out] out_builders An array of builders.
270 * @param[out] out_entry_count The size of @p out_entries
271 * @param[out] out_entries An array of prober entries
272 * @param[out] out_auto_probers An array of up to @ref XRT_MAX_AUTO_PROBERS auto-probers
273 *
274 * @return 0 on success, <0 on error.
275 */
276 int (*get_builders)(struct xrt_prober *xp,
277 size_t *out_builder_count,
278 struct xrt_builder ***out_builders,
279 size_t *out_entry_count,
280 struct xrt_prober_entry ***out_entries,
281 struct xrt_auto_prober ***out_auto_probers);
282
283 /*!
284 * Returns a string property on the device of the given type
285 * @p which_string in @p out_buffer.
286 *
287 * @param[in] xp Prober.
288 * @param[in] xpdev Device to get string property from.
289 * @param[in] which_string Which string property to query.
290 * @param[in,out] out_buffer Target buffer.
291 * @param[in] max_length Max length of the target buffer.
292 *
293 * @return The length of the string, or negative on error.
294 *
295 */
297 struct xrt_prober_device *xpdev,
298 enum xrt_prober_string which_string,
299 unsigned char *out_buffer,
300 size_t max_length);
301
302 /*!
303 * Determine whether a prober device can be opened.
304 *
305 * @param xp Pointer to self
306 * @param xpdev prober device
307 *
308 * @return true if @p xpdev can be opened.
309 */
310 bool (*can_open)(struct xrt_prober *xp, struct xrt_prober_device *xpdev);
311
312 /*!
313 * Destroy the prober and set the pointer to null.
314 *
315 * Code consuming this interface should use xrt_prober_destroy().
316 *
317 * @param xp_ptr pointer to self-pointer
318 */
319 void (*destroy)(struct xrt_prober **xp_ptr);
320};
321
322/*!
323 * @copydoc xrt_prober::probe
324 *
325 * Helper function for @ref xrt_prober::probe.
326 *
327 * @public @memberof xrt_prober
328 */
329XRT_NONNULL_ALL static inline xrt_result_t
331{
332 return xp->probe(xp);
333}
334
335/*!
336 * @copydoc xrt_prober::lock_list
337 *
338 * Helper function for @ref xrt_prober::lock_list.
339 *
340 * @public @memberof xrt_prober
341 */
342XRT_NONNULL_ALL static inline xrt_result_t
343xrt_prober_lock_list(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
344{
345 return xp->lock_list(xp, out_devices, out_device_count);
346}
347
348/*!
349 * @copydoc xrt_prober::unlock_list
350 *
351 * Helper function for @ref xrt_prober::unlock_list.
352 *
353 * @public @memberof xrt_prober
354 */
355XRT_NONNULL_ALL static inline xrt_result_t
357{
358 return xp->unlock_list(xp, devices);
359}
360
361/*!
362 * @copydoc xrt_prober::dump
363 *
364 * Helper function for @ref xrt_prober::dump.
365 *
366 * @public @memberof xrt_prober
367 */
368XRT_NONNULL_ALL static inline int
369xrt_prober_dump(struct xrt_prober *xp, bool use_stdout)
370{
371 return xp->dump(xp, use_stdout);
372}
373
374/*!
375 * @copydoc xrt_prober::create_system
376 *
377 * Helper function for @ref xrt_prober::create_system.
378 *
379 * @public @memberof xrt_prober
380 */
381XRT_NONNULL_ALL static inline xrt_result_t
383 struct xrt_session_event_sink *broadcast,
384 struct xrt_system_devices **out_xsysd,
385 struct xrt_space_overseer **out_xso)
386{
387 return xp->create_system(xp, broadcast, out_xsysd, out_xso);
388}
389
390/*!
391 * @copydoc xrt_prober::select
392 *
393 * Helper function for @ref xrt_prober::select.
394 *
395 * @public @memberof xrt_prober
396 */
397XRT_NONNULL_ALL static inline int
398xrt_prober_select(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
399{
400 return xp->select(xp, xdevs, xdev_capacity);
401}
402
403/*!
404 * @copydoc xrt_prober::open_hid_interface
405 *
406 * Helper function for @ref xrt_prober::open_hid_interface.
407 *
408 * @public @memberof xrt_prober
409 */
410XRT_NONNULL_ALL static inline int
412 struct xrt_prober_device *xpdev,
413 int iface,
414 struct os_hid_device **out_hid_dev)
415{
416 return xp->open_hid_interface(xp, xpdev, iface, out_hid_dev);
417}
418
419/*!
420 * @copydoc xrt_prober::get_string_descriptor
421 *
422 * Helper function for @ref xrt_prober::get_string_descriptor.
423 *
424 * @public @memberof xrt_prober
425 */
426XRT_NONNULL_ALL static inline int
428 struct xrt_prober_device *xpdev,
429 enum xrt_prober_string which_string,
430 unsigned char *out_buffer,
431 size_t max_length)
432{
433 return xp->get_string_descriptor(xp, xpdev, which_string, out_buffer, max_length);
434}
435
436/*!
437 * @copydoc xrt_prober::can_open
438 *
439 * Helper function for @ref xrt_prober::can_open.
440 *
441 * @public @memberof xrt_prober
442 */
443XRT_NONNULL_ALL static inline bool
445{
446 return xp->can_open(xp, xpdev);
447}
448
449
450/*!
451 * @copydoc xrt_prober::open_video_device
452 *
453 * Helper function for @ref xrt_prober::xrt_prober_open_video_device.
454 *
455 * @public @memberof xrt_prober
456 */
457XRT_NONNULL_FIRST static inline int
459 struct xrt_prober_device *xpdev,
460 struct xrt_frame_context *xfctx,
461 struct xrt_fs **out_xfs)
462{
463 return xp->open_video_device(xp, xpdev, xfctx, out_xfs);
464}
465
466/*!
467 * @copydoc xrt_prober::list_video_devices
468 *
469 * Helper function for @ref xrt_prober::list_video_devices.
470 *
471 * @public @memberof xrt_prober
472 */
473static inline int
475{
476 return xp->list_video_devices(xp, cb, ptr);
477}
478
479/*!
480 * @copydoc xrt_prober::get_builders
481 *
482 * Helper function for @ref xrt_prober::get_builders.
483 *
484 * @public @memberof xrt_prober
485 */
486XRT_NONNULL_ALL static inline int
488 size_t *out_builder_count,
489 struct xrt_builder ***out_builders,
490 size_t *out_entry_count,
491 struct xrt_prober_entry ***out_entries,
492 struct xrt_auto_prober ***out_auto_probers)
493{
494 return xp->get_builders(xp, out_builder_count, out_builders, out_entry_count, out_entries, out_auto_probers);
495}
496
497/*!
498 * @copydoc xrt_prober::destroy
499 *
500 * Helper for calling through the function pointer: does a null check and sets
501 * xp_ptr to null if freed.
502 *
503 * @public @memberof xrt_prober
504 */
505XRT_NONNULL_ALL static inline void
507{
508 struct xrt_prober *xp = *xp_ptr;
509 if (xp == NULL) {
510 return;
511 }
512
513 xp->destroy(xp_ptr);
514 *xp_ptr = NULL;
515}
516
517
518/*
519 *
520 * Builder interface.
521 *
522 */
523
524/*!
525 * A estimate from a setter upper about how many devices they can open.
526 *
527 * @ingroup xrt_iface
528 */
530{
531 struct
532 {
533 bool head;
534 bool left;
535 bool right;
536 bool dof6;
537 uint32_t extra_device_count;
538 } certain, maybe;
539
540 /*!
541 * A setter upper defined priority, mostly for vive vs survive.
542 *
543 * 0 normal priority, positive value higher, negative lower.
544 */
545 int32_t priority;
546};
547
548/*!
549 * Function pointer type for creating a @ref xrt_builder.
550 *
551 * @ingroup xrt_iface
552 */
553typedef struct xrt_builder *(*xrt_builder_create_func_t)(void);
554
555/*!
556 * Sets up a collection of devices and builds a system, a setter upper.
557 *
558 * @ingroup xrt_iface
559 */
561{
562 //! Short identifier, like "vive", "north_star", "rgb_tracking".
563 const char *identifier;
564
565 //! "Localized" pretty name.
566 const char *name;
567
568 //! List of identifiers for drivers this setter-upper uses/supports.
569 const char **driver_identifiers;
570
571 //! Number of driver identifiers.
573
574 //! Should this builder be excluded from automatic discovery.
576
577 /*!
578 * From the devices found, estimate without opening the devices how
579 * good the system will be.
580 *
581 * @param[in] xb Builder self parameter.
582 * @param[in] xp Prober
583 * @param[in] config JSON config object if found for this setter upper.
584 * @param[out] out_estimate Estimate to be filled out.
585 *
586 * @note Code consuming this interface should use xrt_builder_estimate_system()
587 */
589 cJSON *config,
590 struct xrt_prober *xp,
591 struct xrt_builder_estimate *out_estimate);
592
593 /*!
594 * We are now committed to opening these devices.
595 *
596 * @param[in] xb Builder self parameter.
597 * @param[in] xp Prober
598 * @param[in] config JSON config object if found for this setter upper.
599 * @param[in] broadcast Event sink that broadcasts events to all sessions.
600 * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
601 * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
602 *
603 * @note Code consuming this interface should use xrt_builder_open_system()
604 */
606 cJSON *config,
607 struct xrt_prober *xp,
608 struct xrt_session_event_sink *broadcast,
609 struct xrt_system_devices **out_xsysd,
610 struct xrt_space_overseer **out_xso);
611
612 /*!
613 * Destroy this setter upper.
614 *
615 * @note Code consuming this interface should use xrt_builder_destroy()
616 */
617 void (*destroy)(struct xrt_builder *xb);
618};
619
620/*!
621 * @copydoc xrt_builder::estimate_system
622 *
623 * Helper function for @ref xrt_builder::estimate_system.
624 *
625 * @public @memberof xrt_builder
626 */
627XRT_NONNULL_ALL static inline xrt_result_t
629 cJSON *config,
630 struct xrt_prober *xp,
631 struct xrt_builder_estimate *out_estimate)
632{
633 return xb->estimate_system(xb, config, xp, out_estimate);
634}
635
636/*!
637 * @copydoc xrt_builder::open_system
638 *
639 * Helper function for @ref xrt_builder::open_system.
640 *
641 * @public @memberof xrt_builder
642 */
643XRT_NONNULL_ALL static inline xrt_result_t
645 cJSON *config,
646 struct xrt_prober *xp,
647 struct xrt_session_event_sink *broadcast,
648 struct xrt_system_devices **out_xsysd,
649 struct xrt_space_overseer **out_xso)
650{
651 return xb->open_system(xb, config, xp, broadcast, out_xsysd, out_xso);
652}
653
654/*!
655 * @copydoc xrt_builder::destroy
656 *
657 * Helper for calling through the function pointer: does a null check and sets
658 * xb_ptr to null if freed.
659 *
660 * @public @memberof xrt_builder
661 */
662XRT_NONNULL_ALL static inline void
664{
665 struct xrt_builder *xb = *xb_ptr;
666 if (xb == NULL) {
667 return;
668 }
669
670 xb->destroy(xb);
671 *xb_ptr = NULL;
672}
673
674
675/*
676 *
677 * Found device interface.
678 *
679 */
680
681/*!
682 * Function pointer type for a handler that gets called when a device matching vendor and product ID is detected.
683 *
684 * @param xp Prober
685 * @param devices The array of prober devices found by the prober.
686 * @param num_devices The number of elements in @p devices
687 * @param index Which element in the prober device array matches your query?
688 * @param attached_data
689 * @param out_xdevs An empty array of size @p XRT_MAX_DEVICES_PER_PROBE you may populate with @ref xrt_device
690 * instances.
691 *
692 * @return the number of elements of @p out_xdevs populated by this call.
693 */
694typedef int (*xrt_prober_found_func_t)(struct xrt_prober *xp,
695 struct xrt_prober_device **devices,
696 size_t num_devices,
697 size_t index,
698 cJSON *attached_data,
699 struct xrt_device **out_xdevs);
700
701/*!
702 * Entry for a single device.
703 *
704 * @ingroup xrt_iface
705 */
707{
708 /*!
709 * USB/Bluetooth vendor ID (VID) to filter on.
710 */
711 uint16_t vendor_id;
712
713 /*!
714 * USB/Bluetooth product ID (PID) to filter on.
715 */
716 uint16_t product_id;
717
718 /*!
719 * Handler that gets called when a device matching vendor and product ID is detected.
720 *
721 * @see xrt_prober_found_func_t
722 */
724
725 /*!
726 * A human-readable name for the device associated with this VID/PID.
727 */
728 const char *name;
729
730 /*!
731 * A human-readable name for the driver associated with this VID/PID.
732 *
733 * Separate because a single driver might handle multiple VID/PID entries.
734 */
735 const char *driver_name;
736};
737
738
739/*
740 *
741 * Auto prober.
742 *
743 */
744
745/*!
746 * Function pointer type for creating a auto prober.
747 *
748 * @ingroup xrt_iface
749 */
750typedef struct xrt_auto_prober *(*xrt_auto_prober_create_func_t)(void);
751
752/*!
753 * @interface xrt_auto_prober
754 *
755 * An interface to be exposed by a device driver that should probe for the
756 * existence of its own device on the system, rather than using shared probers
757 * with vendor/product IDs, etc.
758 *
759 * @ingroup xrt_iface
760 */
762{
763 const char *name;
764
765 /*!
766 * Do the internal probing that the driver needs to do to find
767 * devices.
768 *
769 * @param xap Self pointer
770 * @param attached_data JSON "attached data" for this device from
771 * config, if any.
772 * @param[in] no_hmds If true, do not probe for HMDs, only other
773 * devices.
774 * @param[in] xp Prober: provided to use the tracking factory,
775 * among other reasons.
776 * @param[out] out_xdevs Array of @ref XRT_MAX_DEVICES_PER_PROBE @c NULL
777 * @ref xrt_device pointers. First elements will be populated with new
778 * devices.
779 *
780 * @return The number of devices written into @p out_xdevs, 0 if none.
781 *
782 * @note Leeloo Dallas is a reference to The Fifth Element.
783 */
785 cJSON *attached_data,
786 bool no_hmds,
787 struct xrt_prober *xp,
788 struct xrt_device **out_xdevs);
789 /*!
790 * Destroy this auto-prober.
791 *
792 * @param xap Self pointer
793 */
794 void (*destroy)(struct xrt_auto_prober *xap);
795};
796
797
798/*
799 *
800 * Prober creation.
801 *
802 */
803
804/*!
805 * Main root of all of the probing device.
806 *
807 * @ingroup xrt_iface
808 */
810{
811 /*!
812 * A null terminated list of @ref xrt_builder creation functions.
813 */
815
816 /*!
817 * A null terminated list of null terminated lists of
818 * @ref xrt_prober_entry.
819 */
821
822 /*!
823 * A null terminated list of @ref xrt_auto_prober creation functions.
824 */
826
827 /*!
828 * Lets you chain multiple prober entry lists.
829 */
831};
832
833/*!
834 * Create a prober with a list of known devices and autoprobers.
835 *
836 * Typically used by xrt_instance_create implementations to create the prober,
837 * often with a shared list called `target_list`.
838 *
839 * @param[out] out_xp Pointer to xrt_prober pointer, will be populated with
840 * created xrt_prober instance.
841 * @param[in] list Prober entry list
842 *
843 * @public @memberof xrt_prober
844 */
845XRT_NONNULL_ALL int
847
848
849#ifdef __cplusplus
850}
851#endif
void(* xrt_prober_list_video_func_t)(struct xrt_prober *xp, struct xrt_prober_device *pdev, const char *product, const char *manufacturer, const char *serial, void *ptr)
Callback for listing video devices.
Definition: xrt_prober.h:119
struct xrt_auto_prober *(* xrt_auto_prober_create_func_t)(void)
Function pointer type for creating a auto prober.
Definition: xrt_prober.h:750
enum xrt_result xrt_result_t
Result type used across Monado.
struct xrt_builder *(* xrt_builder_create_func_t)(void)
Function pointer type for creating a xrt_builder.
Definition: xrt_prober.h:553
Representing a single hid interface on a device.
Definition: os_hid.h:29
An interface to be exposed by a device driver that should probe for the existence of its own device o...
Definition: xrt_prober.h:762
void(* destroy)(struct xrt_auto_prober *xap)
Destroy this auto-prober.
Definition: xrt_prober.h:794
int(* lelo_dallas_autoprobe)(struct xrt_auto_prober *xap, cJSON *attached_data, bool no_hmds, struct xrt_prober *xp, struct xrt_device **out_xdevs)
Do the internal probing that the driver needs to do to find devices.
Definition: xrt_prober.h:784
A estimate from a setter upper about how many devices they can open.
Definition: xrt_prober.h:530
int32_t priority
A setter upper defined priority, mostly for vive vs survive.
Definition: xrt_prober.h:545
Sets up a collection of devices and builds a system, a setter upper.
Definition: xrt_prober.h:561
static XRT_NONNULL_ALL xrt_result_t xrt_builder_estimate_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_builder_estimate *out_estimate)
From the devices found, estimate without opening the devices how good the system will be.
Definition: xrt_prober.h:628
const char ** driver_identifiers
List of identifiers for drivers this setter-upper uses/supports.
Definition: xrt_prober.h:569
static XRT_NONNULL_ALL xrt_result_t xrt_builder_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
We are now committed to opening these devices.
Definition: xrt_prober.h:644
static XRT_NONNULL_ALL void xrt_builder_destroy(struct xrt_builder **xb_ptr)
Destroy this setter upper.
Definition: xrt_prober.h:663
xrt_result_t(* estimate_system)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_builder_estimate *out_estimate)
From the devices found, estimate without opening the devices how good the system will be.
Definition: xrt_prober.h:588
void(* destroy)(struct xrt_builder *xb)
Destroy this setter upper.
Definition: xrt_prober.h:617
bool exclude_from_automatic_discovery
Should this builder be excluded from automatic discovery.
Definition: xrt_prober.h:575
const char * name
"Localized" pretty name.
Definition: xrt_prober.h:566
xrt_result_t(* open_system)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
We are now committed to opening these devices.
Definition: xrt_prober.h:605
size_t driver_identifier_count
Number of driver identifiers.
Definition: xrt_prober.h:572
const char * identifier
Short identifier, like "vive", "north_star", "rgb_tracking".
Definition: xrt_prober.h:563
A single HMD or input device.
Definition: xrt_device.h:310
Object used to track all sinks and frame producers in a graph.
Definition: xrt_frame.h:108
Frameserver that generates frames.
Definition: xrt_frameserver.h:70
A probed device, may or may not be opened.
Definition: xrt_prober.h:86
uint16_t product_id
USB/Bluetooth product ID (PID)
Definition: xrt_prober.h:95
uint8_t usb_dev_class
USB device class.
Definition: xrt_prober.h:105
uint16_t vendor_id
USB/Bluetooth vendor ID (VID)
Definition: xrt_prober.h:90
enum xrt_bus_type bus
Device bus type.
Definition: xrt_prober.h:100
Main root of all of the probing device.
Definition: xrt_prober.h:810
struct xrt_prober_entry ** entries
A null terminated list of null terminated lists of xrt_prober_entry.
Definition: xrt_prober.h:820
xrt_builder_create_func_t * builders
A null terminated list of xrt_builder creation functions.
Definition: xrt_prober.h:814
struct xrt_prober_entry_lists * next
Lets you chain multiple prober entry lists.
Definition: xrt_prober.h:830
xrt_auto_prober_create_func_t * auto_probers
A null terminated list of xrt_auto_prober creation functions.
Definition: xrt_prober.h:825
Entry for a single device.
Definition: xrt_prober.h:707
uint16_t product_id
USB/Bluetooth product ID (PID) to filter on.
Definition: xrt_prober.h:716
xrt_prober_found_func_t found
Handler that gets called when a device matching vendor and product ID is detected.
Definition: xrt_prober.h:723
uint16_t vendor_id
USB/Bluetooth vendor ID (VID) to filter on.
Definition: xrt_prober.h:711
const char * driver_name
A human-readable name for the driver associated with this VID/PID.
Definition: xrt_prober.h:735
const char * name
A human-readable name for the device associated with this VID/PID.
Definition: xrt_prober.h:728
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:133
xrt_result_t(* lock_list)(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
Locks the prober list of probed devices and returns it.
Definition: xrt_prober.h:161
struct xrt_tracking_factory * tracking
Factory for producing tracked objects.
Definition: xrt_prober.h:135
static XRT_NONNULL_ALL void xrt_prober_destroy(struct xrt_prober **xp_ptr)
Destroy the prober and set the pointer to null.
Definition: xrt_prober.h:506
static XRT_NONNULL_ALL xrt_result_t xrt_prober_probe(struct xrt_prober *xp)
Enumerate all connected devices, whether or not we have an associated driver.
Definition: xrt_prober.h:330
int(* select)(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
Iterate through drivers (by ID and auto-probers) checking to see if they can handle any connected dev...
Definition: xrt_prober.h:226
static XRT_NONNULL_ALL int xrt_prober_select(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
Iterate through drivers (by ID and auto-probers) checking to see if they can handle any connected dev...
Definition: xrt_prober.h:398
static XRT_NONNULL_ALL bool xrt_prober_can_open(struct xrt_prober *xp, struct xrt_prober_device *xpdev)
Determine whether a prober device can be opened.
Definition: xrt_prober.h:444
xrt_result_t(* unlock_list)(struct xrt_prober *xp, struct xrt_prober_device ***devices)
Unlocks the list, allowing for xrt_prober::probe to be called.
Definition: xrt_prober.h:172
XRT_NONNULL_ALL int xrt_prober_create_with_lists(struct xrt_prober **out_xp, struct xrt_prober_entry_lists *list)
Create a prober with a list of known devices and autoprobers.
Definition: p_prober.c:146
int(* open_video_device)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, struct xrt_frame_context *xfctx, struct xrt_fs **out_xfs)
Opens the selected video device and returns a xrt_fs, does not start it.
Definition: xrt_prober.h:247
static XRT_NONNULL_FIRST int xrt_prober_open_video_device(struct xrt_prober *xp, struct xrt_prober_device *xpdev, struct xrt_frame_context *xfctx, struct xrt_fs **out_xfs)
Opens the selected video device and returns a xrt_fs, does not start it.
Definition: xrt_prober.h:458
int(* open_hid_interface)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, int iface, struct os_hid_device **out_hid_dev)
Open a HID (Human Interface Device) interface using native HID support.
Definition: xrt_prober.h:238
bool(* can_open)(struct xrt_prober *xp, struct xrt_prober_device *xpdev)
Determine whether a prober device can be opened.
Definition: xrt_prober.h:310
int(* dump)(struct xrt_prober *xp, bool use_stdout)
Dump a listing of all devices found on the system to logging system or platform dependent output (std...
Definition: xrt_prober.h:183
static XRT_NONNULL_ALL int xrt_prober_get_string_descriptor(struct xrt_prober *xp, struct xrt_prober_device *xpdev, enum xrt_prober_string which_string, unsigned char *out_buffer, size_t max_length)
Returns a string property on the device of the given type which_string in out_buffer.
Definition: xrt_prober.h:427
static XRT_NONNULL_ALL xrt_result_t xrt_prober_lock_list(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
Locks the prober list of probed devices and returns it.
Definition: xrt_prober.h:343
int(* get_string_descriptor)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, enum xrt_prober_string which_string, unsigned char *out_buffer, size_t max_length)
Returns a string property on the device of the given type which_string in out_buffer.
Definition: xrt_prober.h:296
int(* get_builders)(struct xrt_prober *xp, size_t *out_builder_count, struct xrt_builder ***out_builders, size_t *out_entry_count, struct xrt_prober_entry ***out_entries, struct xrt_auto_prober ***out_auto_probers)
Retrieve the raw xrt_builder, xrt_prober_entry and xrt_auto_prober arrays.
Definition: xrt_prober.h:276
int(* list_video_devices)(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr)
Iterate through available video devices, calling your callback cb with your userdata ptr.
Definition: xrt_prober.h:262
static XRT_NONNULL_ALL int xrt_prober_dump(struct xrt_prober *xp, bool use_stdout)
Dump a listing of all devices found on the system to logging system or platform dependent output (std...
Definition: xrt_prober.h:369
static XRT_NONNULL_ALL xrt_result_t xrt_prober_unlock_list(struct xrt_prober *xp, struct xrt_prober_device ***devices)
Unlocks the list, allowing for xrt_prober::probe to be called.
Definition: xrt_prober.h:356
xrt_result_t(* create_system)(struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
Create system devices.
Definition: xrt_prober.h:195
static int xrt_prober_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr)
Iterate through available video devices, calling your callback cb with your userdata ptr.
Definition: xrt_prober.h:474
xrt_result_t(* probe)(struct xrt_prober *xp)
Enumerate all connected devices, whether or not we have an associated driver.
Definition: xrt_prober.h:151
static XRT_NONNULL_ALL int xrt_prober_open_hid_interface(struct xrt_prober *xp, struct xrt_prober_device *xpdev, int iface, struct os_hid_device **out_hid_dev)
Open a HID (Human Interface Device) interface using native HID support.
Definition: xrt_prober.h:411
static XRT_NONNULL_ALL int xrt_prober_get_builders(struct xrt_prober *xp, size_t *out_builder_count, struct xrt_builder ***out_builders, size_t *out_entry_count, struct xrt_prober_entry ***out_entries, struct xrt_auto_prober ***out_auto_probers)
Retrieve the raw xrt_builder, xrt_prober_entry and xrt_auto_prober arrays.
Definition: xrt_prober.h:487
static XRT_NONNULL_ALL xrt_result_t xrt_prober_create_system(struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
Create system devices.
Definition: xrt_prober.h:382
void(* destroy)(struct xrt_prober **xp_ptr)
Destroy the prober and set the pointer to null.
Definition: xrt_prober.h:319
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition: xrt_session.h:237
Object that oversees and manages spaces, one created for each XR system.
Definition: xrt_space.h:97
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition: xrt_system.h:221
Tracking factory.
Definition: xrt_tracking.h:94
Header defining an xrt display or controller device.
xrt_prober_string
String descriptor types.
Definition: xrt_prober.h:74
xrt_bus_type
Bus type of a device.
Definition: xrt_prober.h:64
int(* xrt_prober_found_func_t)(struct xrt_prober *xp, struct xrt_prober_device **devices, size_t num_devices, size_t index, cJSON *attached_data, struct xrt_device **out_xdevs)
Function pointer type for a handler that gets called when a device matching vendor and product ID is ...
Definition: xrt_prober.h:694