···1111 */
12121313#include "util/u_device.h"
1414+#include "util/u_device_ni.h"
1415#include "util/u_logging.h"
1516#include "util/u_misc.h"
1617#include "util/u_visibility_mask.h"
···507508 // Empty, should only be used from a device without any inputs.
508509 return XRT_SUCCESS;
509510}
511511+512512+513513+/*
514514+ *
515515+ * Helper function to fill in defaults.
516516+ *
517517+ */
518518+519519+void
520520+u_device_populate_function_pointers(struct xrt_device *xdev,
521521+ u_device_get_tracked_pose_function_t get_tracked_pose_fn,
522522+ u_device_destroy_function_t destroy_fn)
523523+{
524524+ if (get_tracked_pose_fn == NULL) {
525525+ U_LOG_E("Got get_tracked_pose_fn == NULL!");
526526+ assert(get_tracked_pose_fn != NULL);
527527+ }
528528+529529+ if (destroy_fn == NULL) {
530530+ U_LOG_E("Got destroy_fn == NULL!");
531531+ assert(destroy_fn != NULL);
532532+ }
533533+534534+ /*
535535+ * This must be implemented by the xrt_device, but not necessarily by
536536+ * the driver so use noop version.
537537+ */
538538+ xdev->update_inputs = u_device_noop_update_inputs;
539539+540540+ // This must be implemented by the driver.
541541+ xdev->get_tracked_pose = get_tracked_pose_fn;
542542+543543+ /*
544544+ * These are not required to be implemented by the xrt_device, so use
545545+ * not implemented versions, and let the driver override if needed.
546546+ */
547547+ xdev->get_hand_tracking = u_device_ni_get_hand_tracking;
548548+ xdev->get_face_tracking = u_device_ni_get_face_tracking;
549549+ xdev->get_body_skeleton = u_device_ni_get_body_skeleton;
550550+ xdev->get_body_joints = u_device_ni_get_body_joints;
551551+ xdev->reset_body_tracking_calibration_meta = u_device_ni_reset_body_tracking_calibration_meta;
552552+ xdev->set_body_tracking_calibration_override_meta = u_device_ni_set_body_tracking_calibration_override_meta;
553553+ xdev->set_output = u_device_ni_set_output;
554554+ xdev->get_output_limits = u_device_ni_get_output_limits;
555555+ xdev->get_presence = u_device_ni_get_presence;
556556+ xdev->begin_plane_detection_ext = u_device_ni_begin_plane_detection_ext;
557557+ xdev->destroy_plane_detection_ext = u_device_ni_destroy_plane_detection_ext;
558558+ xdev->get_plane_detection_state_ext = u_device_ni_get_plane_detection_state_ext;
559559+ xdev->get_plane_detections_ext = u_device_ni_get_plane_detections_ext;
560560+ xdev->get_view_poses = u_device_ni_get_view_poses;
561561+ xdev->compute_distortion = u_device_ni_compute_distortion;
562562+ xdev->get_visibility_mask = u_device_ni_get_visibility_mask;
563563+ xdev->ref_space_usage = u_device_ni_ref_space_usage;
564564+ xdev->is_form_factor_available = u_device_ni_is_form_factor_available;
565565+ xdev->get_battery_status = u_device_ni_get_battery_status;
566566+ xdev->get_brightness = u_device_ni_get_brightness;
567567+ xdev->set_brightness = u_device_ni_set_brightness;
568568+ xdev->begin_feature = u_device_ni_begin_feature;
569569+ xdev->end_feature = u_device_ni_end_feature;
570570+571571+ // This must be implemented by the driver.
572572+ xdev->destroy = destroy_fn;
573573+}
+42
src/xrt/auxiliary/util/u_device.h
···204204u_device_noop_update_inputs(struct xrt_device *xdev);
205205206206207207+/*
208208+ *
209209+ * Helper function to fill in defaults.
210210+ *
211211+ */
212212+213213+/*!
214214+ * Function pointer type for the device's get_tracked_pose function.
215215+ *
216216+ * @ingroup aux_util
217217+ */
218218+typedef xrt_result_t (*u_device_get_tracked_pose_function_t)(struct xrt_device *xdev,
219219+ const enum xrt_input_name name,
220220+ const int64_t at_timestamp_ns,
221221+ struct xrt_space_relation *const out_relation);
222222+223223+/*!
224224+ * Function pointer type for the device's destroy function.
225225+ *
226226+ * @ingroup aux_util
227227+ */
228228+typedef void (*u_device_destroy_function_t)(struct xrt_device *xdev);
229229+230230+/*!
231231+ * Populate the device's function pointers with default implementations.
232232+ *
233233+ * This function fills in all device function pointers with either noop or
234234+ * not-implemented versions, allowing drivers to override only the functions
235235+ * they actually implement. The exceptions are get_tracked_pose and destroy,
236236+ * which must be implemented by the driver and are passed in as function
237237+ * pointers, these must not be NULL.
238238+ *
239239+ * @param[in,out] xdev The device to populate with default function pointers.
240240+ * @param[in] get_tracked_pose_fn The function pointer to the device's get_tracked_pose function.
241241+ * @param[in] destroy_fn The function pointer to the device's destroy function.
242242+ * @ingroup aux_util
243243+ */
244244+void
245245+u_device_populate_function_pointers(struct xrt_device *xdev,
246246+ u_device_get_tracked_pose_function_t get_tracked_pose_fn,
247247+ u_device_destroy_function_t destroy_fn);
248248+207249#ifdef __cplusplus
208250}
209251#endif