+64
src/xrt/auxiliary/util/u_device.c
+64
src/xrt/auxiliary/util/u_device.c
···
11
11
*/
12
12
13
13
#include "util/u_device.h"
14
+
#include "util/u_device_ni.h"
14
15
#include "util/u_logging.h"
15
16
#include "util/u_misc.h"
16
17
#include "util/u_visibility_mask.h"
···
507
508
// Empty, should only be used from a device without any inputs.
508
509
return XRT_SUCCESS;
509
510
}
511
+
512
+
513
+
/*
514
+
*
515
+
* Helper function to fill in defaults.
516
+
*
517
+
*/
518
+
519
+
void
520
+
u_device_populate_function_pointers(struct xrt_device *xdev,
521
+
u_device_get_tracked_pose_function_t get_tracked_pose_fn,
522
+
u_device_destroy_function_t destroy_fn)
523
+
{
524
+
if (get_tracked_pose_fn == NULL) {
525
+
U_LOG_E("Got get_tracked_pose_fn == NULL!");
526
+
assert(get_tracked_pose_fn != NULL);
527
+
}
528
+
529
+
if (destroy_fn == NULL) {
530
+
U_LOG_E("Got destroy_fn == NULL!");
531
+
assert(destroy_fn != NULL);
532
+
}
533
+
534
+
/*
535
+
* This must be implemented by the xrt_device, but not necessarily by
536
+
* the driver so use noop version.
537
+
*/
538
+
xdev->update_inputs = u_device_noop_update_inputs;
539
+
540
+
// This must be implemented by the driver.
541
+
xdev->get_tracked_pose = get_tracked_pose_fn;
542
+
543
+
/*
544
+
* These are not required to be implemented by the xrt_device, so use
545
+
* not implemented versions, and let the driver override if needed.
546
+
*/
547
+
xdev->get_hand_tracking = u_device_ni_get_hand_tracking;
548
+
xdev->get_face_tracking = u_device_ni_get_face_tracking;
549
+
xdev->get_body_skeleton = u_device_ni_get_body_skeleton;
550
+
xdev->get_body_joints = u_device_ni_get_body_joints;
551
+
xdev->reset_body_tracking_calibration_meta = u_device_ni_reset_body_tracking_calibration_meta;
552
+
xdev->set_body_tracking_calibration_override_meta = u_device_ni_set_body_tracking_calibration_override_meta;
553
+
xdev->set_output = u_device_ni_set_output;
554
+
xdev->get_output_limits = u_device_ni_get_output_limits;
555
+
xdev->get_presence = u_device_ni_get_presence;
556
+
xdev->begin_plane_detection_ext = u_device_ni_begin_plane_detection_ext;
557
+
xdev->destroy_plane_detection_ext = u_device_ni_destroy_plane_detection_ext;
558
+
xdev->get_plane_detection_state_ext = u_device_ni_get_plane_detection_state_ext;
559
+
xdev->get_plane_detections_ext = u_device_ni_get_plane_detections_ext;
560
+
xdev->get_view_poses = u_device_ni_get_view_poses;
561
+
xdev->compute_distortion = u_device_ni_compute_distortion;
562
+
xdev->get_visibility_mask = u_device_ni_get_visibility_mask;
563
+
xdev->ref_space_usage = u_device_ni_ref_space_usage;
564
+
xdev->is_form_factor_available = u_device_ni_is_form_factor_available;
565
+
xdev->get_battery_status = u_device_ni_get_battery_status;
566
+
xdev->get_brightness = u_device_ni_get_brightness;
567
+
xdev->set_brightness = u_device_ni_set_brightness;
568
+
xdev->begin_feature = u_device_ni_begin_feature;
569
+
xdev->end_feature = u_device_ni_end_feature;
570
+
571
+
// This must be implemented by the driver.
572
+
xdev->destroy = destroy_fn;
573
+
}
+42
src/xrt/auxiliary/util/u_device.h
+42
src/xrt/auxiliary/util/u_device.h
···
204
204
u_device_noop_update_inputs(struct xrt_device *xdev);
205
205
206
206
207
+
/*
208
+
*
209
+
* Helper function to fill in defaults.
210
+
*
211
+
*/
212
+
213
+
/*!
214
+
* Function pointer type for the device's get_tracked_pose function.
215
+
*
216
+
* @ingroup aux_util
217
+
*/
218
+
typedef xrt_result_t (*u_device_get_tracked_pose_function_t)(struct xrt_device *xdev,
219
+
const enum xrt_input_name name,
220
+
const int64_t at_timestamp_ns,
221
+
struct xrt_space_relation *const out_relation);
222
+
223
+
/*!
224
+
* Function pointer type for the device's destroy function.
225
+
*
226
+
* @ingroup aux_util
227
+
*/
228
+
typedef void (*u_device_destroy_function_t)(struct xrt_device *xdev);
229
+
230
+
/*!
231
+
* Populate the device's function pointers with default implementations.
232
+
*
233
+
* This function fills in all device function pointers with either noop or
234
+
* not-implemented versions, allowing drivers to override only the functions
235
+
* they actually implement. The exceptions are get_tracked_pose and destroy,
236
+
* which must be implemented by the driver and are passed in as function
237
+
* pointers, these must not be NULL.
238
+
*
239
+
* @param[in,out] xdev The device to populate with default function pointers.
240
+
* @param[in] get_tracked_pose_fn The function pointer to the device's get_tracked_pose function.
241
+
* @param[in] destroy_fn The function pointer to the device's destroy function.
242
+
* @ingroup aux_util
243
+
*/
244
+
void
245
+
u_device_populate_function_pointers(struct xrt_device *xdev,
246
+
u_device_get_tracked_pose_function_t get_tracked_pose_fn,
247
+
u_device_destroy_function_t destroy_fn);
248
+
207
249
#ifdef __cplusplus
208
250
}
209
251
#endif