This does some of the heavy lifting when it comes to managing the system devices and the space overseer. The same code was replicated in basically all of the builders, this lets us avoid that.
···1818#endif
19192020struct xrt_prober_device;
2121+struct u_builder_roles_helper;
2222+21232224/*!
2325 * Max return of the number @ref xrt_prober_device.
···2729#define U_BUILDER_SEARCH_MAX (16) // 16 Vive trackers
28302931/*!
3232+ * Argument to @ref u_builder_roles_helper_open_system and implemented by
3333+ * @ref u_builder::open_system_static_roles function.
3434+ *
3535+ * A builder implement this function is free to focus on only creating the
3636+ * devices and assigning them initial roles. With this implementation details
3737+ * of the @ref xrt_system_devices and @ref xrt_space_overseer is taken care of
3838+ * by the caller of this function.
3939+ *
4040+ * @ingroup aux_util
4141+ */
4242+typedef xrt_result_t (*u_builder_open_system_fn)(struct xrt_builder *xb,
4343+ cJSON *config,
4444+ struct xrt_prober *xp,
4545+ struct xrt_tracking_origin *origin,
4646+ struct xrt_system_devices *xsysd,
4747+ struct xrt_frame_context *xfctx,
4848+ struct u_builder_roles_helper *ubrh);
4949+5050+/*!
3051 * A filter to match the against.
3152 *
3253 * @ingroup aux_util
···5374};
54755576/*!
7777+ * This small helper struct is for @ref u_builder_roles_helper_open_system,
7878+ * lets a builder focus on opening devices rather then dealing with Monado
7979+ * structs like @ref xrt_system_devices and the like.
8080+ *
8181+ * @ingroup aux_util
8282+ */
8383+struct u_builder_roles_helper
8484+{
8585+ struct xrt_device *head;
8686+ struct xrt_device *left;
8787+ struct xrt_device *right;
8888+8989+ struct
9090+ {
9191+ struct xrt_device *left;
9292+ struct xrt_device *right;
9393+ } hand_tracking;
9494+};
9595+9696+/*!
9797+ * This helper struct makes it easier to implement the builder interface, but it
9898+ * also comes with a set of integration that may not be what all builders want.
9999+ * See the below functions for more information.
100100+ *
101101+ * * @ref u_builder_open_system_static_roles
102102+ * * @ref u_builder_roles_helper_open_system
103103+ *
104104+ * @ingroup aux_util
105105+ */
106106+struct u_builder
107107+{
108108+ //! Base for this struct.
109109+ struct xrt_builder base;
110110+111111+ /*!
112112+ * @copydoc u_builder_open_system_fn
113113+ */
114114+ u_builder_open_system_fn open_system_static_roles;
115115+};
116116+117117+118118+/*
119119+ *
120120+ * Functions.
121121+ *
122122+ */
123123+124124+/*!
56125 * Find the first @ref xrt_prober_device in the prober list.
57126 *
58127 * @ingroup aux_util
···104173 struct xrt_device **xdevs,
105174 uint32_t xdev_count,
106175 struct xrt_space_overseer **out_xso);
176176+177177+/*!
178178+ * Helper to create a system devices that has static roles and a appropriate
179179+ * space overseer. Currently uses the functions below to create a full system
180180+ * with the help of @p fn argument. But this might change in the future.
181181+ *
182182+ * * @ref u_system_devices_static_allocate
183183+ * * @ref u_system_devices_static_finalize
184184+ * * @ref u_builder_create_space_overseer_legacy
185185+ *
186186+ * @ingroup aux_util
187187+ */
188188+xrt_result_t
189189+u_builder_roles_helper_open_system(struct xrt_builder *xb,
190190+ cJSON *config,
191191+ struct xrt_prober *xp,
192192+ struct xrt_system_devices **out_xsysd,
193193+ struct xrt_space_overseer **out_xso,
194194+ u_builder_open_system_fn fn);
195195+196196+/*!
197197+ * Implementation for xrt_builder::open_system to be used with @ref u_builder.
198198+ * Uses @ref u_builder_roles_helper_open_system internally, a builder that uses
199199+ * the @ref u_builder should use this function for xrt_builder::open_system.
200200+ *
201201+ * When using this function the builder must have @ref u_builder and implement
202202+ * the @ref u_builder::open_static_roles function, see documentation for
203203+ * @ref u_builder_open_system_fn about requirements.
204204+ *
205205+ * @ingroup aux_util
206206+ */
207207+xrt_result_t
208208+u_builder_open_system_static_roles(struct xrt_builder *xb,
209209+ cJSON *config,
210210+ struct xrt_prober *xp,
211211+ struct xrt_system_devices **out_xsysd,
212212+ struct xrt_space_overseer **out_xso);
107213108214109215#ifdef __cplusplus