···1616struct xrt_system_devices;
1717struct xrt_instance;
18181919-1919+/*!
2020+ * Maximum number of devices simultaneously usable by an implementation of
2121+ * @ref xrt_system_devices
2222+ *
2323+ * @ingroup xrt_iface
2424+ */
2025#define XRT_SYSTEM_MAX_DEVICES (32)
21262227/*!
2323- * Roles of the devices, negative index means unpopulated. When the devices
2424- * change the caller will do the needed actions to handle a device changes, for
2525- * the OpenXR state tracker this may include switching bound interaction profile
2626- * and generating the events for such a change.
2828+ * Data associating a device index (in @ref xrt_system_devices::xdevs) with a
2929+ * given "role" for dynamic role switching.
3030+ *
3131+ * For each of the named roles, a negative value means unpopulated/not available.
3232+ *
3333+ * Populated by a call from the @ref xrt_system_devices interface.
3434+ *
3535+ * When the caller of @ref xrt_system_devices_get_roles sees a change (based on
3636+ * comparing @ref generation_id) the caller must do the needed actions to handle
3737+ * device changes. For example, for the OpenXR state tracker this may include
3838+ * rebinding, queuing a change to the current interaction profile, and queuing
3939+ * the events associated with such a change.
2740 *
2841 * @see xrt_system_devices
2942 * @ingroup xrt_iface
···3144struct xrt_system_roles
3245{
3346 /*!
3434- * Monotonically increasing generation counter, is increased when ever
3535- * the roles is changed. Will always be greater then zero, this is to
4747+ * Monotonically increasing generation counter for the association
4848+ * between role and index.
4949+ *
5050+ * Increment whenever the roles are changed.
5151+ *
5252+ * All valid values are greater then zero; this is to
3653 * make init easier where any cache can start at zero and be guaranteed
3754 * to be replaced with a new @ref xrt_system_roles.
3855 */
3956 uint64_t generation_id;
40575858+ /*!
5959+ * Index in @ref xrt_system_devices::xdevs for the user's left
6060+ * controller/hand, or negative if none available.
6161+ */
4162 int32_t left;
6363+6464+ /*!
6565+ * Index in @ref xrt_system_devices::xdevs for the user's right
6666+ * controller/hand, or negative if none available.
6767+ */
4268 int32_t right;
6969+7070+ /*!
7171+ * Index in @ref xrt_system_devices::xdevs for the user's gamepad
7272+ * device, or negative if none available.
7373+ */
4374 int32_t gamepad;
4475};
45764677/*!
4747- * Guaranteed invalid content, not using designated initializers due to C++.
7878+ * Guaranteed invalid constant for @ref xrt_system_roles, not using designated
7979+ * initializers due to C++.
4880 *
4981 * @ingroup xrt_iface
8282+ * @relates xrt_system_roles
5083 */
5184#define XRT_SYSTEM_ROLES_INIT \
5285 { \
···558856895790/*!
5858- * A collection of @ref xrt_device, and the roles they have been assigned.
9191+ * A collection of @ref xrt_device, and an interface for identifying the roles
9292+ * they have been assigned.
5993 *
6094 * @see xrt_device, xrt_instance.
6195 */
6296struct xrt_system_devices
6397{
9898+ /*!
9999+ * All devices known in the system.
100100+ *
101101+ * This is conventionally considered the "owning" reference to the devices.
102102+ * Valid entries are contiguous.
103103+ */
64104 struct xrt_device *xdevs[XRT_SYSTEM_MAX_DEVICES];
105105+106106+ /*!
107107+ * The number of elements in @ref xdevs that are valid.
108108+ */
65109 size_t xdev_count;
66110111111+ /*!
112112+ * Observing pointers for devices in some static (unchangeable) roles.
113113+ *
114114+ * All pointers in this struct must also exist in @ref xdevs. The
115115+ * association between a member of this struct and a given device
116116+ * cannot change during runtime.
117117+ */
67118 struct
68119 {
120120+ /*!
121121+ * An observing pointer to the device serving as the "head"
122122+ * (and HMD).
123123+ *
124124+ * Required.
125125+ */
69126 struct xrt_device *head;
127127+128128+ /*!
129129+ * An observing pointer to the device providing eye tracking
130130+ * (optional).
131131+ */
70132 struct xrt_device *eyes;
133133+134134+ /*!
135135+ * Devices providing optical (or otherwise more directly
136136+ * measured than from controller estimation) hand tracking.
137137+ */
71138 struct
72139 {
140140+141141+ /*!
142142+ * An observing pointer to the device providing hand
143143+ * tracking for the left hand (optional).
144144+ *
145145+ * Currently this is used for both optical and
146146+ * controller driven hand-tracking.
147147+ */
73148 struct xrt_device *left;
149149+150150+ /*!
151151+ * An observing pointer to the device providing hand
152152+ * tracking for the right hand (optional).
153153+ *
154154+ * Currently this is used for both optical and
155155+ * controller driven hand-tracking.
156156+ */
74157 struct xrt_device *right;
75158 } hand_tracking;
76159 } static_roles;
···80163 * Function to get the dynamic input device roles from this system
81164 * devices, see @ref xrt_system_roles for more information.
82165 *
8383- * @param[in] xsysd Pointer to self
8484- * @param[out] roles Pointer to xrt_system_roles
166166+ * @param xsysd Pointer to self
167167+ * @param[out] out_roles Pointer to xrt_system_roles
85168 */
86169 xrt_result_t (*get_roles)(struct xrt_system_devices *xsysd, struct xrt_system_roles *out_roles);
8717088171 /*!
89172 * Destroy all the devices that are owned by this system devices.
90173 *
9191- * Code consuming this interface should use xrt_system_devices_destroy.
174174+ * Code consuming this interface should use @ref xrt_system_devices_destroy.
175175+ *
176176+ * @param xsysd Pointer to self
92177 */
93178 void (*destroy)(struct xrt_system_devices *xsysd);
94179};
···111196 *
112197 * @param[in,out] xsysd_ptr A pointer to the xrt_system_devices struct pointer.
113198 *
114114- * Will destroy the system devices if *xsysd_ptr is not NULL. Will then set
115115- * *xsysd_ptr to NULL.
199199+ * Will destroy the system devices if `*xsysd_ptr` is not NULL. Will then set
200200+ * `*xsysd_ptr` to NULL.
116201 *
117202 * @public @memberof xrt_system_devices
118203 */