From 7a788c42af6acf81e7d3e27c61a1e4a8797a643a Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sun, 2 Mar 2025 19:22:30 +0100 Subject: [PATCH] auto cast for get_tracked_pose --- server/driver/wivrn_controller.cpp | 25 ++++++++----------------- server/driver/wivrn_controller.h | 3 ++- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/server/driver/wivrn_controller.cpp b/server/driver/wivrn_controller.cpp index 603dfce1..44bcd0b7 100644 --- a/server/driver/wivrn_controller.cpp +++ b/server/driver/wivrn_controller.cpp @@ -21,6 +21,7 @@ #include "configuration.h" #include "driver/xrt_cast.h" #include "math/m_api.h" +#include "utils/method.h" #include "wivrn_session.h" #include "util/u_logging.h" @@ -473,15 +474,6 @@ static xrt_binding_profile wivrn_binding_profiles[] = { static void wivrn_controller_destroy(xrt_device * xdev) {}; -static xrt_result_t wivrn_controller_get_tracked_pose(xrt_device * xdev, - xrt_input_name name, - int64_t at_timestamp_ns, - xrt_space_relation * out_relation) -{ - *out_relation = static_cast(xdev)->get_tracked_pose(name, at_timestamp_ns); - return XRT_SUCCESS; -} - static void wivrn_controller_get_hand_tracking(xrt_device * xdev, xrt_input_name name, int64_t desired_timestamp_ns, @@ -573,7 +565,7 @@ wivrn_controller::wivrn_controller(int hand_id, .position_tracking_supported = true, .hand_tracking_supported = cnx->get_info().hand_tracking, .update_inputs = wivrn_controller_update_inputs, - .get_tracked_pose = wivrn_controller_get_tracked_pose, + .get_tracked_pose = method_pointer<&wivrn_controller::get_tracked_pose>, .get_hand_tracking = wivrn_controller_get_hand_tracking, .set_output = wivrn_controller_set_output, .destroy = wivrn_controller_destroy, @@ -748,23 +740,22 @@ void wivrn_controller::set_inputs(const from_headset::inputs & inputs, const clo } } -xrt_space_relation wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns) +xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * res) { std::chrono::nanoseconds extrapolation_time; - xrt_space_relation res; device_id device; switch (name) { case XRT_INPUT_TOUCH_AIM_POSE: - std::tie(extrapolation_time, res, device) = aim.get_pose_at(at_timestamp_ns); + std::tie(extrapolation_time, *res, device) = aim.get_pose_at(at_timestamp_ns); cnx->set_enabled(device, true); break; case XRT_INPUT_TOUCH_GRIP_POSE: - std::tie(extrapolation_time, res, device) = grip.get_pose_at(at_timestamp_ns); + std::tie(extrapolation_time, *res, device) = grip.get_pose_at(at_timestamp_ns); cnx->set_enabled(device, true); break; case XRT_INPUT_GENERIC_PALM_POSE: - std::tie(extrapolation_time, res, device) = palm.get_pose_at(at_timestamp_ns); + std::tie(extrapolation_time, *res, device) = palm.get_pose_at(at_timestamp_ns); cnx->set_enabled(device, true); break; default: @@ -790,10 +781,10 @@ xrt_space_relation wivrn_controller::get_tracked_pose(xrt_input_name name, int64 << at_timestamp_ns << ',' << extrapolation_time.count() << ',' << "g," - << res << std::endl; + << *res << std::endl; ; } - return res; + return XRT_SUCCESS; } std::pair wivrn_controller::get_hand_tracking(xrt_input_name name, int64_t desired_timestamp_ns) diff --git a/server/driver/wivrn_controller.h b/server/driver/wivrn_controller.h index e314fef3..0e73d27f 100644 --- a/server/driver/wivrn_controller.h +++ b/server/driver/wivrn_controller.h @@ -47,11 +47,12 @@ class wivrn_controller : public xrt_device wivrn::wivrn_session * cnx; public: + using base = xrt_device; wivrn_controller(int hand_id, xrt_device * hmd, wivrn::wivrn_session * cnx); void update_inputs(); - xrt_space_relation get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns); + xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation); std::pair get_hand_tracking(xrt_input_name name, int64_t desired_timestamp_ns); void set_output(xrt_output_name name, const xrt_output_value * value);