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