diff --git a/src/xrt/drivers/android/android_sensors.c b/src/xrt/drivers/android/android_sensors.c index 9678060a9..69e7383e4 100644 --- a/src/xrt/drivers/android/android_sensors.c +++ b/src/xrt/drivers/android/android_sensors.c @@ -170,7 +170,7 @@ android_device_destroy(struct xrt_device *xdev) free(android); } -static void +static xrt_result_t android_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -189,6 +189,7 @@ android_device_get_tracked_pose(struct xrt_device *xdev, XRT_SPACE_RELATION_POSITION_VALID_BIT); *out_relation = new_relation; + return XRT_SUCCESS; } diff --git a/src/xrt/drivers/arduino/arduino_device.c b/src/xrt/drivers/arduino/arduino_device.c index 7ffdd7349..9ea0bce2c 100644 --- a/src/xrt/drivers/arduino/arduino_device.c +++ b/src/xrt/drivers/arduino/arduino_device.c @@ -273,7 +273,7 @@ arduino_run_thread(void *ptr) * */ -static void +static xrt_result_t arduino_get_fusion_pose(struct arduino_device *ad, enum xrt_input_name name, struct xrt_space_relation *out_relation) { out_relation->pose.orientation = ad->fusion.rot; @@ -281,6 +281,8 @@ arduino_get_fusion_pose(struct arduino_device *ad, enum xrt_input_name name, str //! @todo assuming that orientation is actually currently tracked. out_relation->relation_flags = (enum xrt_space_relation_flags)(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); + + return XRT_SUCCESS; } static void @@ -331,7 +333,7 @@ arduino_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t arduino_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -340,7 +342,7 @@ arduino_device_get_tracked_pose(struct xrt_device *xdev, struct arduino_device *ad = arduino_device(xdev); (void)at_timestamp_ns; - arduino_get_fusion_pose(ad, name, out_relation); + return arduino_get_fusion_pose(ad, name, out_relation); } diff --git a/src/xrt/drivers/daydream/daydream_device.c b/src/xrt/drivers/daydream/daydream_device.c index 696c8e503..b08446936 100644 --- a/src/xrt/drivers/daydream/daydream_device.c +++ b/src/xrt/drivers/daydream/daydream_device.c @@ -310,7 +310,7 @@ daydream_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t daydream_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -320,6 +320,8 @@ daydream_device_get_tracked_pose(struct xrt_device *xdev, (void)at_timestamp_ns; daydream_get_fusion_pose(daydream, name, out_relation); + + return XRT_SUCCESS; } diff --git a/src/xrt/drivers/euroc/euroc_device.c b/src/xrt/drivers/euroc/euroc_device.c index 91668039e..35d2240c8 100644 --- a/src/xrt/drivers/euroc/euroc_device.c +++ b/src/xrt/drivers/euroc/euroc_device.c @@ -102,7 +102,7 @@ euroc_device(struct xrt_device *xdev) return (struct euroc_device *)xdev; } -static void +static xrt_result_t euroc_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -128,6 +128,8 @@ euroc_device_get_tracked_pose(struct xrt_device *xdev, out_relation->relation_flags = (enum xrt_space_relation_flags)( XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/hdk/hdk_device.cpp b/src/xrt/drivers/hdk/hdk_device.cpp index 97acdf6e0..c2f1d80b9 100644 --- a/src/xrt/drivers/hdk/hdk_device.cpp +++ b/src/xrt/drivers/hdk/hdk_device.cpp @@ -213,7 +213,7 @@ hdk_device_update(struct hdk_device *hd) return 1; } -static void +static xrt_result_t hdk_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t requested_timestamp_ns, @@ -222,8 +222,8 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev, struct hdk_device *hd = hdk_device(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - HDK_ERROR(hd, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&hd->base, hd->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } os_mutex_lock(&hd->lock); @@ -231,7 +231,7 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev, out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE; HDK_TRACE(hd, "GET_TRACKED_POSE: No pose"); os_mutex_unlock(&hd->lock); - return; + return XRT_SUCCESS; } out_relation->pose.orientation = hd->quat; @@ -248,6 +248,7 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev, HDK_TRACE(hd, "GET_TRACKED_POSE (%f, %f, %f, %f) ANG_VEL (%f, %f, %f)", hd->quat.x, hd->quat.y, hd->quat.z, hd->quat.w, hd->ang_vel_quat.x, hd->ang_vel_quat.y, hd->ang_vel_quat.z); + return XRT_SUCCESS; } static void * diff --git a/src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp b/src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp index 653732d71..72caca8ac 100644 --- a/src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp +++ b/src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp @@ -175,7 +175,7 @@ joint_pose_global(xrt_hand_joint_set *joint_set, xrt_hand_joint joint) return out_relation.pose; } -static void +static xrt_result_t do_grip_pose(struct xrt_hand_joint_set *joint_set, struct xrt_space_relation *out_relation, float grip_offset_from_palm, @@ -211,11 +211,13 @@ do_grip_pose(struct xrt_hand_joint_set *joint_set, math_quat_from_plus_x_z(&plus_x, &plus_z, &out_relation->pose.orientation); out_relation->relation_flags = valid_flags; + + return XRT_SUCCESS; } -static void +static xrt_result_t get_other_two(struct cemu_device *dev, int64_t head_timestamp_ns, int64_t hand_timestamp_ns, @@ -223,7 +225,12 @@ get_other_two(struct cemu_device *dev, xrt_hand_joint_set *out_secondary) { struct xrt_space_relation head_rel; - xrt_device_get_tracked_pose(dev->sys->in_head, XRT_INPUT_GENERIC_HEAD_POSE, head_timestamp_ns, &head_rel); + xrt_result_t xret = + xrt_device_get_tracked_pose(dev->sys->in_head, XRT_INPUT_GENERIC_HEAD_POSE, head_timestamp_ns, &head_rel); + if (xret != XRT_SUCCESS) { + return xret; + } + *out_head = head_rel.pose; int other; if (dev->hand_index == 0) { @@ -235,11 +242,13 @@ get_other_two(struct cemu_device *dev, int64_t noop; xrt_device_get_hand_tracking(dev->sys->in_hand, dev->sys->out_hand[other]->ht_input_name, hand_timestamp_ns, out_secondary, &noop); + + return xret; } // Mostly stolen from // https://github.com/maluoi/StereoKit/blob/048b689f71d080a67fde29838c0362a49b88b3d6/StereoKitC/systems/hand/hand_oxr_articulated.cpp#L149 -static void +static xrt_result_t do_aim_pose(struct cemu_device *dev, struct xrt_hand_joint_set *joint_set_primary, int64_t head_timestamp_ns, @@ -251,12 +260,14 @@ do_aim_pose(struct cemu_device *dev, struct xrt_hand_joint_set joint_set_secondary; #if 0 // "Jakob way" - get_other_two(dev, hand_timestamp_ns, hand_timestamp_ns, &head, &joint_set_secondary); + xrt_result_t xret = get_other_two(dev, hand_timestamp_ns, hand_timestamp_ns, &head, &joint_set_secondary); #else // "Moses way" - get_other_two(dev, head_timestamp_ns, hand_timestamp_ns, &head, &joint_set_secondary); + xrt_result_t xret = get_other_two(dev, head_timestamp_ns, hand_timestamp_ns, &head, &joint_set_secondary); #endif - + if (xret != XRT_SUCCESS) { + return xret; + } // Average shoulder width for women:37cm, men:41cm, center of shoulder // joint is around 4cm inwards @@ -313,10 +324,12 @@ do_aim_pose(struct cemu_device *dev, math_quat_from_plus_x_z(&out_x_vector, &ray_direction, &out_relation->pose.orientation); out_relation->relation_flags = valid_flags; + + return xret; } // Pose for controller emulation -static void +static xrt_result_t cemu_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -326,8 +339,8 @@ cemu_device_get_tracked_pose(struct xrt_device *xdev, struct cemu_system *sys = dev->sys; if (name != XRT_INPUT_SIMPLE_GRIP_POSE && name != XRT_INPUT_SIMPLE_AIM_POSE) { - CEMU_ERROR(dev, "unknown input name %d for controller pose", name); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&dev->base, dev->sys->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } static int64_t hand_timestamp_ns; @@ -337,24 +350,25 @@ cemu_device_get_tracked_pose(struct xrt_device *xdev, if (joint_set.is_active == false) { out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE; - return; + return XRT_SUCCESS; } - - + xrt_result_t xret = XRT_SUCCESS; switch (name) { case XRT_INPUT_SIMPLE_GRIP_POSE: { - do_grip_pose(&joint_set, out_relation, sys->grip_offset_from_palm, dev->hand_index); + xret = do_grip_pose(&joint_set, out_relation, sys->grip_offset_from_palm, dev->hand_index); break; } case XRT_INPUT_SIMPLE_AIM_POSE: { // Assume that now we're doing everything in the timestamp from the hand-tracker, so use // hand_timestamp_ns. This will cause the controller to lag behind but otherwise be correct - do_aim_pose(dev, &joint_set, at_timestamp_ns, hand_timestamp_ns, out_relation); + xret = do_aim_pose(dev, &joint_set, at_timestamp_ns, hand_timestamp_ns, out_relation); break; } default: assert(false); } + + return xret; } static void diff --git a/src/xrt/drivers/hydra/hydra_driver.c b/src/xrt/drivers/hydra/hydra_driver.c index e7f11197a..80cefcf38 100644 --- a/src/xrt/drivers/hydra/hydra_driver.c +++ b/src/xrt/drivers/hydra/hydra_driver.c @@ -482,7 +482,7 @@ hydra_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t hydra_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -505,6 +505,8 @@ hydra_device_get_tracked_pose(struct xrt_device *xdev, // HYDRA_SPEW(hd, "GET_TRACKED_POSE (%f, %f, %f) (%f, %f, %f, %f) ", // pos.x, // pos.y, pos.z, quat.x, quat.y, quat.z, quat.w); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/multi_wrapper/multi.c b/src/xrt/drivers/multi_wrapper/multi.c index ddca26cf2..d28e1e9bd 100644 --- a/src/xrt/drivers/multi_wrapper/multi.c +++ b/src/xrt/drivers/multi_wrapper/multi.c @@ -79,7 +79,7 @@ attached_override(struct multi_device *d, m_relation_chain_resolve(&xrc, out_relation); } -static void +static xrt_result_t get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -91,7 +91,11 @@ get_tracked_pose(struct xrt_device *xdev, struct xrt_space_relation tracker_relation; - xrt_device_get_tracked_pose(tracker, tracker_input_name, at_timestamp_ns, &tracker_relation); + xrt_result_t xret = + xrt_device_get_tracked_pose(tracker, tracker_input_name, at_timestamp_ns, &tracker_relation); + if (xret != XRT_SUCCESS) { + return xret; + } switch (d->override_type) { case XRT_TRACKING_OVERRIDE_DIRECT: { @@ -101,8 +105,10 @@ get_tracked_pose(struct xrt_device *xdev, struct xrt_device *target = d->tracking_override.target; struct xrt_space_relation target_relation; - xrt_device_get_tracked_pose(target, name, at_timestamp_ns, &target_relation); - + xret = xrt_device_get_tracked_pose(target, name, at_timestamp_ns, &target_relation); + if (xret != XRT_SUCCESS) { + break; + } // just use the origin of the tracker space as reference frame struct xrt_space_relation in_target_space; @@ -116,6 +122,8 @@ get_tracked_pose(struct xrt_device *xdev, &in_target_space, out_relation); } break; } + + return xret; } static void diff --git a/src/xrt/drivers/north_star/ns_hmd.c b/src/xrt/drivers/north_star/ns_hmd.c index 0f35912ae..12843452e 100644 --- a/src/xrt/drivers/north_star/ns_hmd.c +++ b/src/xrt/drivers/north_star/ns_hmd.c @@ -367,7 +367,7 @@ ns_hmd_destroy(struct xrt_device *xdev) u_device_free(&ns->base); } -static void +static xrt_result_t ns_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -377,11 +377,12 @@ ns_hmd_get_tracked_pose(struct xrt_device *xdev, NS_DEBUG(ns, "Called!"); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - NS_ERROR(ns, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&ns->base, ns->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } *out_relation = ns->no_tracker_relation; // you can change this using the debug gui + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/ohmd/oh_device.c b/src/xrt/drivers/ohmd/oh_device.c index 471fecd56..00e50a8ab 100644 --- a/src/xrt/drivers/ohmd/oh_device.c +++ b/src/xrt/drivers/ohmd/oh_device.c @@ -373,7 +373,7 @@ check_tracker_pose(struct oh_device *ohd, enum xrt_input_name name) return (ohd->ohmd_device_type == OPENHMD_GENERIC_TRACKER) && name == XRT_INPUT_GENERIC_TRACKER_POSE; } -static void +static xrt_result_t oh_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -384,8 +384,8 @@ oh_device_get_tracked_pose(struct xrt_device *xdev, struct xrt_vec3 pos = XRT_VEC3_ZERO; if (!check_head_pose(ohd, name) && !check_controller_pose(ohd, name) && !check_tracker_pose(ohd, name)) { - OHMD_ERROR(ohd, "unknown input name: %d", name); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&ohd->base, ohd->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } ohmd_ctx_update(ohd->ctx); @@ -429,7 +429,7 @@ oh_device_get_tracked_pose(struct xrt_device *xdev, */ *out_relation = ohd->last_relation; OHMD_TRACE(ohd, "GET_TRACKED_POSE (%s) - no new data", ohd->base.str); - return; + return XRT_SUCCESS; } /*! @@ -470,6 +470,8 @@ oh_device_get_tracked_pose(struct xrt_device *xdev, // Update state within driver ohd->last_update = (int64_t)now; ohd->last_relation = *out_relation; + + return XRT_SUCCESS; } diff --git a/src/xrt/drivers/psmv/psmv_driver.c b/src/xrt/drivers/psmv/psmv_driver.c index 1c484c944..f67bd289e 100644 --- a/src/xrt/drivers/psmv/psmv_driver.c +++ b/src/xrt/drivers/psmv/psmv_driver.c @@ -794,32 +794,6 @@ psmv_get_fusion_pose(struct psmv_device *psmv, XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT); } -static void -psmv_push_pose_offset(enum xrt_input_name name, struct xrt_relation_chain *xrc) -{ - /* - * Both the grip and aim pose needs adjustments, the grip is a rotated - * body center pose, while the aim pose needs to rotated and translated - * to the tip of the ball. - */ - if (name != XRT_INPUT_PSMV_AIM_POSE && name != XRT_INPUT_PSMV_GRIP_POSE) { - return; - } - - float y = 0.0; - if (name == XRT_INPUT_PSMV_AIM_POSE) { - y += PSMV_BALL_FROM_IMU_Y_M; - y += PSMV_BALL_DIAMETER_M / 2.0; - } - - struct xrt_pose pose = { - {0.7071068, 0, 0, 0.7071068}, - {0, y, 0}, - }; - - m_relation_chain_push_pose(xrc, &pose); -} - /* * @@ -888,16 +862,39 @@ psmv_device_update_inputs(struct xrt_device *xdev) } static xrt_result_t -psmv_device_get_relation_chain(struct xrt_device *xdev, - enum xrt_input_name name, - uint64_t at_timestamp_ns, - struct xrt_relation_chain *xrc) +psmv_device_get_tracked_pose(struct xrt_device *xdev, + enum xrt_input_name name, + int64_t at_timestamp_ns, + struct xrt_space_relation *out_relation) { struct psmv_device *psmv = psmv_device(xdev); - psmv_push_pose_offset(name, xrc); + if (name != XRT_INPUT_PSMV_AIM_POSE && name != XRT_INPUT_PSMV_GRIP_POSE) { + U_LOG_XDEV_UNSUPPORTED_INPUT(&psmv->base, psmv->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; + } - struct xrt_space_relation *rel = m_relation_chain_reserve(xrc); + /* + * Both the grip and aim pose needs adjustments, the grip is a rotated + * body center pose, while the aim pose needs to rotated and translated + * to the tip of the ball. + */ + + float y = 0.0; + if (name == XRT_INPUT_PSMV_AIM_POSE) { + y += PSMV_BALL_FROM_IMU_Y_M; + y += PSMV_BALL_DIAMETER_M / 2.0; + } + + struct xrt_pose pose = { + {0.7071068, 0, 0, 0.7071068}, + {0, y, 0}, + }; + + struct xrt_relation_chain xrc = {0}; + m_relation_chain_push_pose(&xrc, &pose); + + struct xrt_space_relation *rel = m_relation_chain_reserve(&xrc); if (psmv->ball != NULL) { xrt_tracked_psmv_get_tracked_pose(psmv->ball, name, at_timestamp_ns, rel); @@ -905,20 +902,9 @@ psmv_device_get_relation_chain(struct xrt_device *xdev, psmv_get_fusion_pose(psmv, name, at_timestamp_ns, rel); } - return XRT_SUCCESS; -} - -static void -psmv_device_get_tracked_pose(struct xrt_device *xdev, - enum xrt_input_name name, - int64_t at_timestamp_ns, - struct xrt_space_relation *out_relation) -{ - struct xrt_relation_chain xrc = {0}; - - psmv_device_get_relation_chain(xdev, name, at_timestamp_ns, &xrc); - m_relation_chain_resolve(&xrc, out_relation); + + return XRT_SUCCESS; } static float diff --git a/src/xrt/drivers/pssense/pssense_driver.c b/src/xrt/drivers/pssense/pssense_driver.c index db4991336..d63b54c2f 100644 --- a/src/xrt/drivers/pssense/pssense_driver.c +++ b/src/xrt/drivers/pssense/pssense_driver.c @@ -757,7 +757,7 @@ pssense_get_fusion_pose(struct pssense_device *pssense, XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT); } -static void +static xrt_result_t pssense_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -766,8 +766,8 @@ pssense_get_tracked_pose(struct xrt_device *xdev, struct pssense_device *pssense = (struct pssense_device *)xdev; if (name != XRT_INPUT_PSSENSE_AIM_POSE && name != XRT_INPUT_PSSENSE_GRIP_POSE) { - PSSENSE_ERROR(pssense, "Unknown pose name requested %u", name); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&pssense->base, pssense->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_relation_chain xrc = {0}; @@ -785,6 +785,8 @@ pssense_get_tracked_pose(struct xrt_device *xdev, os_mutex_unlock(&pssense->lock); m_relation_chain_resolve(&xrc, out_relation); + + return XRT_SUCCESS; } static xrt_result_t diff --git a/src/xrt/drivers/psvr/psvr_device.c b/src/xrt/drivers/psvr/psvr_device.c index 4485104d4..6b0aa3ee0 100644 --- a/src/xrt/drivers/psvr/psvr_device.c +++ b/src/xrt/drivers/psvr/psvr_device.c @@ -957,7 +957,7 @@ psvr_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t psvr_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -966,8 +966,8 @@ psvr_device_get_tracked_pose(struct xrt_device *xdev, struct psvr_device *psvr = psvr_device(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - PSVR_ERROR(psvr, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&psvr->base, psvr->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } os_mutex_lock(&psvr->device_mutex); @@ -993,6 +993,8 @@ psvr_device_get_tracked_pose(struct xrt_device *xdev, //! @todo Move this to the tracker. // Make sure that the orientation is valid. math_quat_normalize(&out_relation->pose.orientation); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/qwerty/qwerty_device.c b/src/xrt/drivers/qwerty/qwerty_device.c index 238e12f70..fcaf21e3f 100644 --- a/src/xrt/drivers/qwerty/qwerty_device.c +++ b/src/xrt/drivers/qwerty/qwerty_device.c @@ -136,7 +136,7 @@ qwerty_set_output(struct xrt_device *xd, enum xrt_output_name name, const union } } -static void +static xrt_result_t qwerty_get_tracked_pose(struct xrt_device *xd, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -146,8 +146,8 @@ qwerty_get_tracked_pose(struct xrt_device *xd, if (name != XRT_INPUT_GENERIC_HEAD_POSE && name != XRT_INPUT_SIMPLE_GRIP_POSE && name != XRT_INPUT_SIMPLE_AIM_POSE) { - QWERTY_ERROR(qd, "Unexpected input name = 0x%04X", name >> 8); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&qd->base, qd->sys->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } // Position @@ -201,6 +201,8 @@ qwerty_get_tracked_pose(struct xrt_device *xd, out_relation->relation_flags = XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT; + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/realsense/rs_ddev.c b/src/xrt/drivers/realsense/rs_ddev.c index 8eab91476..763c7ee8d 100644 --- a/src/xrt/drivers/realsense/rs_ddev.c +++ b/src/xrt/drivers/realsense/rs_ddev.c @@ -388,7 +388,7 @@ load_config(struct rs_ddev *rs) * */ -static void +static xrt_result_t rs_ddev_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -397,11 +397,12 @@ rs_ddev_get_tracked_pose(struct xrt_device *xdev, struct rs_ddev *rs = rs_ddev(xdev); if (name != XRT_INPUT_GENERIC_TRACKER_POSE) { - U_LOG_E("unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&rs->base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } m_relation_history_get(rs->relation_hist, at_timestamp_ns, out_relation); + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/realsense/rs_hdev.c b/src/xrt/drivers/realsense/rs_hdev.c index c43d0b899..f2fc0354f 100644 --- a/src/xrt/drivers/realsense/rs_hdev.c +++ b/src/xrt/drivers/realsense/rs_hdev.c @@ -273,7 +273,7 @@ rs_hdev_correct_pose_from_basalt(struct xrt_pose pose) return out_relation.pose; } -static void +static xrt_result_t rs_hdev_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -305,6 +305,8 @@ rs_hdev_get_tracked_pose(struct xrt_device *xdev, out_relation->relation_flags = (enum xrt_space_relation_flags)( XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/remote/r_device.c b/src/xrt/drivers/remote/r_device.c index e19a1cb0d..6a5a5cb91 100644 --- a/src/xrt/drivers/remote/r_device.c +++ b/src/xrt/drivers/remote/r_device.c @@ -97,7 +97,7 @@ r_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t r_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -108,8 +108,8 @@ r_device_get_tracked_pose(struct xrt_device *xdev, if (name != XRT_INPUT_INDEX_AIM_POSE && name != XRT_INPUT_INDEX_GRIP_POSE && name != XRT_INPUT_GENERIC_PALM_POSE) { - U_LOG_E("Unknown input name: 0x%0x", name); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&rd->base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct r_remote_controller_data *latest = rd->is_left ? &r->latest.left : &r->latest.right; @@ -133,6 +133,8 @@ r_device_get_tracked_pose(struct xrt_device *xdev, } else { out_relation->relation_flags = 0; } + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/remote/r_hmd.c b/src/xrt/drivers/remote/r_hmd.c index 4e220143e..be23acbdc 100644 --- a/src/xrt/drivers/remote/r_hmd.c +++ b/src/xrt/drivers/remote/r_hmd.c @@ -56,7 +56,7 @@ r_hmd_destroy(struct xrt_device *xdev) u_device_free(&rh->base); } -static void +static xrt_result_t r_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -66,8 +66,12 @@ r_hmd_get_tracked_pose(struct xrt_device *xdev, switch (name) { case XRT_INPUT_GENERIC_HEAD_POSE: copy_head_center_to_relation(rh, out_relation); break; - default: U_LOG_E("Unknown input name"); break; + default: + U_LOG_XDEV_UNSUPPORTED_INPUT(&rh->base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/rift_s/rift_s_controller.c b/src/xrt/drivers/rift_s/rift_s_controller.c index 11459957a..3ccb8fb40 100644 --- a/src/xrt/drivers/rift_s/rift_s_controller.c +++ b/src/xrt/drivers/rift_s/rift_s_controller.c @@ -539,7 +539,7 @@ rift_s_controller_get_fusion_pose(struct rift_s_controller *ctrl, XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT); } -static void +static xrt_result_t rift_s_controller_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -548,8 +548,8 @@ rift_s_controller_get_tracked_pose(struct xrt_device *xdev, struct rift_s_controller *ctrl = (struct rift_s_controller *)(xdev); if (name != XRT_INPUT_TOUCH_AIM_POSE && name != XRT_INPUT_TOUCH_GRIP_POSE) { - RIFT_S_ERROR("unknown pose name requested"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&ctrl->base, rift_s_log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_relation_chain xrc = {0}; @@ -571,6 +571,8 @@ rift_s_controller_get_tracked_pose(struct xrt_device *xdev, os_mutex_unlock(&ctrl->mutex); m_relation_chain_resolve(&xrc, out_relation); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/rift_s/rift_s_hmd.c b/src/xrt/drivers/rift_s/rift_s_hmd.c index de60d7588..7fb37b1e6 100644 --- a/src/xrt/drivers/rift_s/rift_s_hmd.c +++ b/src/xrt/drivers/rift_s/rift_s_hmd.c @@ -43,7 +43,7 @@ #define DEG_TO_RAD(D) ((D)*M_PI / 180.) -static void +static xrt_result_t rift_s_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -52,13 +52,14 @@ rift_s_get_tracked_pose(struct xrt_device *xdev, struct rift_s_hmd *hmd = (struct rift_s_hmd *)(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - RIFT_S_ERROR("Unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&hmd->base, rift_s_log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } U_ZERO(out_relation); rift_s_tracker_get_tracked_pose(hmd->tracker, RIFT_S_TRACKER_POSE_DEVICE, at_timestamp_ns, out_relation); + return XRT_SUCCESS; } void diff --git a/src/xrt/drivers/rift_s/rift_s_tracker.c b/src/xrt/drivers/rift_s/rift_s_tracker.c index 532313fc5..c21d55ed9 100644 --- a/src/xrt/drivers/rift_s/rift_s_tracker.c +++ b/src/xrt/drivers/rift_s/rift_s_tracker.c @@ -67,7 +67,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(rift_s_slam, "RIFT_S_SLAM", true) //! Specifies whether the user wants to use the hand tracker. DEBUG_GET_ONCE_BOOL_OPTION(rift_s_handtracking, "RIFT_S_HANDTRACKING", true) -static void +static xrt_result_t rift_s_tracker_get_tracked_pose_imu(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -608,16 +608,21 @@ rift_s_tracker_correct_pose_from_basalt(struct xrt_pose *pose) math_quat_rotate_vec3(&q, &pose->position, &pose->position); } -static void +static xrt_result_t rift_s_tracker_get_tracked_pose_imu(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation) { struct rift_s_tracker *tracker = (struct rift_s_tracker *)(xdev); - assert(name == XRT_INPUT_GENERIC_TRACKER_POSE); + if (name != XRT_INPUT_GENERIC_TRACKER_POSE) { + U_LOG_XDEV_UNSUPPORTED_INPUT(&tracker->base, rift_s_log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; + } rift_s_tracker_get_tracked_pose(tracker, RIFT_S_TRACKER_POSE_IMU, at_timestamp_ns, out_relation); + + return XRT_SUCCESS; } void diff --git a/src/xrt/drivers/rokid/rokid_hmd.c b/src/xrt/drivers/rokid/rokid_hmd.c index e28368751..ceb50dd5c 100644 --- a/src/xrt/drivers/rokid/rokid_hmd.c +++ b/src/xrt/drivers/rokid/rokid_hmd.c @@ -430,7 +430,7 @@ rokid_hmd_destroy(struct xrt_device *xdev) u_device_free(&rokid->base); } -static void +static xrt_result_t rokid_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -439,12 +439,14 @@ rokid_hmd_get_tracked_pose(struct xrt_device *xdev, struct rokid_hmd *rokid = rokid_hmd(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - ROKID_ERROR(rokid, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&rokid->base, rokid->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } os_mutex_lock(&rokid->fusion.mutex); rokid_fusion_get_pose(&rokid->fusion, at_timestamp_ns, out_relation); os_mutex_unlock(&rokid->fusion.mutex); + + return XRT_SUCCESS; } static struct xrt_device * diff --git a/src/xrt/drivers/sample/sample_hmd.c b/src/xrt/drivers/sample/sample_hmd.c index e09e0e1c0..e56ef28bb 100644 --- a/src/xrt/drivers/sample/sample_hmd.c +++ b/src/xrt/drivers/sample/sample_hmd.c @@ -96,7 +96,7 @@ sample_hmd_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t sample_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -105,8 +105,8 @@ sample_hmd_get_tracked_pose(struct xrt_device *xdev, struct sample_hmd *hmd = sample_hmd(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - HMD_ERROR(hmd, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&hmd->base, hmd->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_space_relation relation = XRT_SPACE_RELATION_ZERO; @@ -125,6 +125,7 @@ sample_hmd_get_tracked_pose(struct xrt_device *xdev, } *out_relation = relation; + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/simula/svr_hmd.c b/src/xrt/drivers/simula/svr_hmd.c index 103b34ad6..8e130d0b6 100644 --- a/src/xrt/drivers/simula/svr_hmd.c +++ b/src/xrt/drivers/simula/svr_hmd.c @@ -72,7 +72,7 @@ svr_hmd_destroy(struct xrt_device *xdev) u_device_free(&ns->base); } -static void +static xrt_result_t svr_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -82,7 +82,8 @@ svr_hmd_get_tracked_pose(struct xrt_device *xdev, if (name != XRT_INPUT_GENERIC_HEAD_POSE) { SVR_ERROR(ns, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&ns->base, ns->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } @@ -92,6 +93,8 @@ svr_hmd_get_tracked_pose(struct xrt_device *xdev, (struct xrt_pose)XRT_POSE_IDENTITY; // This is so that tracking overrides/multi driver just transforms us by // the tracker + offset from the tracker. out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_ALL; + + return XRT_SUCCESS; } #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) diff --git a/src/xrt/drivers/simulated/simulated_controller.c b/src/xrt/drivers/simulated/simulated_controller.c index d76a9fe21..2a164e6fd 100644 --- a/src/xrt/drivers/simulated/simulated_controller.c +++ b/src/xrt/drivers/simulated/simulated_controller.c @@ -46,8 +46,8 @@ struct simulated_device #define CHECK_THAT_NAME_IS_AND_ERROR(NAME) \ do { \ if (sd->base.name != NAME) { \ - U_LOG_E("Unknown input for controller %s 0x%02x", #NAME, name); \ - return; \ + U_LOG_XDEV_UNSUPPORTED_INPUT(&sd->base, u_log_get_global_level(), name); \ + return XRT_ERROR_INPUT_UNSUPPORTED; \ } \ } while (false) @@ -118,7 +118,7 @@ simulated_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t simulated_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -133,13 +133,15 @@ simulated_device_get_tracked_pose(struct xrt_device *xdev, case XRT_INPUT_WMR_AIM_POSE: CHECK_THAT_NAME_IS_AND_ERROR(XRT_DEVICE_WMR_CONTROLLER); break; case XRT_INPUT_ML2_CONTROLLER_GRIP_POSE: case XRT_INPUT_ML2_CONTROLLER_AIM_POSE: CHECK_THAT_NAME_IS_AND_ERROR(XRT_DEVICE_ML2_CONTROLLER); break; - default: U_LOG_E("Unknown input name: 0x%0x", name); return; + default: + U_LOG_XDEV_UNSUPPORTED_INPUT(&sd->base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } if (!sd->active) { out_relation->pose = (struct xrt_pose)XRT_POSE_IDENTITY; out_relation->relation_flags = 0; - return; + return XRT_SUCCESS; } struct xrt_pose pose = sd->center; @@ -160,6 +162,8 @@ simulated_device_get_tracked_pose(struct xrt_device *xdev, XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT | XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT); + + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/simulated/simulated_hmd.c b/src/xrt/drivers/simulated/simulated_hmd.c index 81d6ecf49..34223cd4f 100644 --- a/src/xrt/drivers/simulated/simulated_hmd.c +++ b/src/xrt/drivers/simulated/simulated_hmd.c @@ -85,7 +85,7 @@ simulated_hmd_destroy(struct xrt_device *xdev) u_device_free(&dh->base); } -static void +static xrt_result_t simulated_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -94,8 +94,8 @@ simulated_hmd_get_tracked_pose(struct xrt_device *xdev, struct simulated_hmd *hmd = simulated_hmd(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - HMD_ERROR(hmd, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&hmd->base, hmd->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } const double time_s = time_ns_to_s(at_timestamp_ns - hmd->created_ns); @@ -142,6 +142,8 @@ simulated_hmd_get_tracked_pose(struct xrt_device *xdev, out_relation->relation_flags = (enum xrt_space_relation_flags)(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); + + return XRT_SUCCESS; } static xrt_result_t diff --git a/src/xrt/drivers/steamvr_lh/device.cpp b/src/xrt/drivers/steamvr_lh/device.cpp index 53406734e..cfea43b1f 100644 --- a/src/xrt/drivers/steamvr_lh/device.cpp +++ b/src/xrt/drivers/steamvr_lh/device.cpp @@ -426,16 +426,18 @@ Device::get_battery_status(bool *out_present, bool *out_charging, float *out_cha return XRT_SUCCESS; } -void +xrt_result_t HmdDevice::get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) { switch (name) { case XRT_INPUT_GENERIC_HEAD_POSE: Device::get_pose(at_timestamp_ns, out_relation); break; - default: U_LOG_W("steamvr_lh hmd: Requested pose for unknown name %u", name); break; + default: U_LOG_XDEV_UNSUPPORTED_INPUT(this, ctx->log_level, name); return XRT_ERROR_INPUT_UNSUPPORTED; } + + return XRT_SUCCESS; } -void +xrt_result_t ControllerDevice::get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) { xrt_space_relation rel = {}; @@ -453,6 +455,8 @@ ControllerDevice::get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns struct xrt_pose *p = &out_relation->pose; DEV_DEBUG("controller %u: GET_POSITION (%f %f %f) GET_ORIENTATION (%f, %f, %f, %f)", name, p->position.x, p->position.y, p->position.z, p->orientation.x, p->orientation.y, p->orientation.z, p->orientation.w); + + return XRT_SUCCESS; } void diff --git a/src/xrt/drivers/steamvr_lh/device.hpp b/src/xrt/drivers/steamvr_lh/device.hpp index 60efc1b57..6bd3de993 100644 --- a/src/xrt/drivers/steamvr_lh/device.hpp +++ b/src/xrt/drivers/steamvr_lh/device.hpp @@ -69,7 +69,7 @@ public: handle_properties(const vr::PropertyWrite_t *batch, uint32_t count); //! Maps to @ref xrt_device::get_tracked_pose. - virtual void + virtual xrt_result_t get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) = 0; xrt_result_t @@ -116,7 +116,7 @@ public: HmdDevice(const DeviceBuilder &builder); - void + xrt_result_t get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) override; void @@ -168,7 +168,7 @@ public: void set_haptic_handle(vr::VRInputComponentHandle_t handle); - void + xrt_result_t get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) override; IndexFingerInput * diff --git a/src/xrt/drivers/survive/survive_driver.c b/src/xrt/drivers/survive/survive_driver.c index 95034d573..6595a0818 100644 --- a/src/xrt/drivers/survive/survive_driver.c +++ b/src/xrt/drivers/survive/survive_driver.c @@ -324,7 +324,7 @@ verify_device_name(struct survive_device *survive, enum xrt_input_name name) return false; } -static void +static xrt_result_t survive_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -332,13 +332,13 @@ survive_device_get_tracked_pose(struct xrt_device *xdev, { struct survive_device *survive = (struct survive_device *)xdev; if (!verify_device_name(survive, name)) { - SURVIVE_ERROR(survive, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&survive->base, survive->sys->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } if (!survive->survive_obj) { // U_LOG_D("Obj not set for %p", (void*)survive); - return; + return XRT_SUCCESS; } // We're pretty sure libsurvive is giving us the IMU pose here, so this works. @@ -356,6 +356,7 @@ survive_device_get_tracked_pose(struct xrt_device *xdev, struct xrt_pose *p = &out_relation->pose; SURVIVE_TRACE(survive, "GET_POSITION (%f %f %f) GET_ORIENTATION (%f, %f, %f, %f)", p->position.x, p->position.y, p->position.z, p->orientation.x, p->orientation.y, p->orientation.z, p->orientation.w); + return XRT_SUCCESS; } static xrt_result_t diff --git a/src/xrt/drivers/twrap/twrap_slam.c b/src/xrt/drivers/twrap/twrap_slam.c index 6cf1c23c0..4e4581178 100644 --- a/src/xrt/drivers/twrap/twrap_slam.c +++ b/src/xrt/drivers/twrap/twrap_slam.c @@ -84,7 +84,7 @@ twrap_hmd_correct_pose_from_basalt(struct xrt_pose pose) } #endif -static void +static xrt_result_t twrap_slam_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -93,8 +93,8 @@ twrap_slam_get_tracked_pose(struct xrt_device *xdev, struct slam_device *dx = slam_device(xdev); if (name != XRT_INPUT_GENERIC_TRACKER_POSE) { - SLAM_ERROR(dx, "unknown input name %d", name); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&dx->base, dx->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } #ifdef XRT_FEATURE_SLAM if (!dx->use_3dof) { @@ -109,7 +109,7 @@ twrap_slam_get_tracked_pose(struct xrt_device *xdev, if (!pose_tracked) { U_ZERO(&out_relation->relation_flags); - return; + return XRT_SUCCESS; } basalt_rel.pose = twrap_hmd_correct_pose_from_basalt(basalt_rel.pose); @@ -127,11 +127,12 @@ twrap_slam_get_tracked_pose(struct xrt_device *xdev, } m_relation_chain_resolve(&xrc, out_relation); - return; + return XRT_SUCCESS; } #endif m_relation_history_get(dx->dof3->rh, at_timestamp_ns, out_relation); + return XRT_SUCCESS; } static void diff --git a/src/xrt/drivers/vive/vive_controller.c b/src/xrt/drivers/vive/vive_controller.c index a871605ee..590ae6d87 100644 --- a/src/xrt/drivers/vive/vive_controller.c +++ b/src/xrt/drivers/vive/vive_controller.c @@ -410,7 +410,7 @@ vive_controller_get_hand_tracking(struct xrt_device *xdev, out_value->is_active = true; } -static void +static xrt_result_t vive_controller_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -421,11 +421,13 @@ vive_controller_device_get_tracked_pose(struct xrt_device *xdev, // U_LOG_D("input name %d %d", name, XRT_INPUT_VIVE_GRIP_POSE); if (name != XRT_INPUT_VIVE_AIM_POSE && name != XRT_INPUT_VIVE_GRIP_POSE && name != XRT_INPUT_INDEX_AIM_POSE && name != XRT_INPUT_INDEX_GRIP_POSE) { - VIVE_ERROR(d, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&d->base, d->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } get_pose(d, name, at_timestamp_ns, out_relation); + + return XRT_SUCCESS; } static int diff --git a/src/xrt/drivers/vive/vive_device.c b/src/xrt/drivers/vive/vive_device.c index 7b1dcddbe..05ad7493f 100644 --- a/src/xrt/drivers/vive/vive_device.c +++ b/src/xrt/drivers/vive/vive_device.c @@ -106,7 +106,7 @@ vive_device_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t vive_device_get_3dof_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, uint64_t at_timestamp_ns, @@ -117,8 +117,8 @@ vive_device_get_3dof_tracked_pose(struct xrt_device *xdev, struct vive_device *d = vive_device(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - U_LOG_E("unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&d->base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_space_relation relation = {0}; @@ -131,6 +131,8 @@ vive_device_get_3dof_tracked_pose(struct xrt_device *xdev, *out_relation = relation; d->pose = out_relation->pose; + + return XRT_SUCCESS; } //! Specific pose corrections for Basalt and a Valve Index headset @@ -179,7 +181,7 @@ vive_device_get_slam_tracked_pose(struct xrt_device *xdev, XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT); } -static void +static xrt_result_t vive_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -192,12 +194,18 @@ vive_device_get_tracked_pose(struct xrt_device *xdev, // Ajdust the timestamp with the offset. at_timestamp_ns += (int64_t)(d->tracked_offset_ms.val * (double)U_TIME_1MS_IN_NS); + xrt_result_t xret = XRT_SUCCESS; if (d->tracking.slam_enabled && d->slam_over_3dof) { vive_device_get_slam_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } else { - vive_device_get_3dof_tracked_pose(xdev, name, at_timestamp_ns, out_relation); + xret = vive_device_get_3dof_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } - math_pose_transform(&d->offset, &out_relation->pose, &out_relation->pose); + + if (xret == XRT_SUCCESS) { + math_pose_transform(&d->offset, &out_relation->pose, &out_relation->pose); + } + + return xret; } static void diff --git a/src/xrt/drivers/wmr/wmr_controller_base.c b/src/xrt/drivers/wmr/wmr_controller_base.c index 5520611cc..164cbfea7 100644 --- a/src/xrt/drivers/wmr/wmr_controller_base.c +++ b/src/xrt/drivers/wmr/wmr_controller_base.c @@ -443,7 +443,7 @@ read_controller_config(struct wmr_controller_base *wcb) return true; } -static void +static xrt_result_t wmr_controller_base_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -479,13 +479,15 @@ wmr_controller_base_get_tracked_pose(struct xrt_device *xdev, // No prediction needed. if (at_timestamp_ns < last_imu_timestamp_ns) { *out_relation = relation; - return; + return XRT_SUCCESS; } int64_t prediction_ns = at_timestamp_ns - last_imu_timestamp_ns; double prediction_s = time_ns_to_s(prediction_ns); m_predict_relation(&relation, prediction_s, out_relation); + + return XRT_SUCCESS; } void diff --git a/src/xrt/drivers/wmr/wmr_hmd.c b/src/xrt/drivers/wmr/wmr_hmd.c index 59bd5b819..f190e8c77 100644 --- a/src/xrt/drivers/wmr/wmr_hmd.c +++ b/src/xrt/drivers/wmr/wmr_hmd.c @@ -1073,7 +1073,7 @@ wmr_read_config(struct wmr_hmd *wh) * */ -static void +static xrt_result_t wmr_hmd_get_3dof_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, uint64_t at_timestamp_ns, @@ -1084,8 +1084,8 @@ wmr_hmd_get_3dof_tracked_pose(struct xrt_device *xdev, struct wmr_hmd *wh = wmr_hmd(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - WMR_ERROR(wh, "Unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&wh->base, wh->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } // Variables needed for prediction. @@ -1105,7 +1105,7 @@ wmr_hmd_get_3dof_tracked_pose(struct xrt_device *xdev, // No prediction needed. if (at_timestamp_ns < last_imu_timestamp_ns) { *out_relation = relation; - return; + return XRT_SUCCESS; } uint64_t prediction_ns = at_timestamp_ns - last_imu_timestamp_ns; @@ -1113,6 +1113,8 @@ wmr_hmd_get_3dof_tracked_pose(struct xrt_device *xdev, m_predict_relation(&relation, prediction_s, out_relation); wh->pose = out_relation->pose; + + return XRT_SUCCESS; } //! Specific pose corrections for Basalt and a WMR headset @@ -1165,7 +1167,7 @@ wmr_hmd_get_slam_tracked_pose(struct xrt_device *xdev, XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT); } -static void +static xrt_result_t wmr_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -1177,12 +1179,18 @@ wmr_hmd_get_tracked_pose(struct xrt_device *xdev, at_timestamp_ns += (int64_t)(wh->tracked_offset_ms.val * (double)U_TIME_1MS_IN_NS); + xrt_result_t xret = XRT_SUCCESS; if (wh->tracking.slam_enabled && wh->slam_over_3dof) { wmr_hmd_get_slam_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } else { - wmr_hmd_get_3dof_tracked_pose(xdev, name, at_timestamp_ns, out_relation); + xret = wmr_hmd_get_3dof_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } - math_pose_transform(&wh->offset, &out_relation->pose, &out_relation->pose); + + if (xret == XRT_SUCCESS) { + math_pose_transform(&wh->offset, &out_relation->pose, &out_relation->pose); + } + + return xret; } static void diff --git a/src/xrt/drivers/xreal_air/xreal_air_hmd.c b/src/xrt/drivers/xreal_air/xreal_air_hmd.c index 800164998..a9e0cde33 100644 --- a/src/xrt/drivers/xreal_air/xreal_air_hmd.c +++ b/src/xrt/drivers/xreal_air/xreal_air_hmd.c @@ -1049,7 +1049,7 @@ xreal_air_hmd_update_inputs(struct xrt_device *xdev) return XRT_SUCCESS; } -static void +static xrt_result_t xreal_air_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -1058,8 +1058,8 @@ xreal_air_hmd_get_tracked_pose(struct xrt_device *xdev, struct xreal_air_hmd *hmd = xreal_air_hmd(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - XREAL_AIR_ERROR(hmd, "unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&hmd->base, hmd->log_level, name); + return XRT_ERROR_INPUT_UNSUPPORTED; } const enum xrt_space_relation_flags flags = (enum xrt_space_relation_flags)( @@ -1076,6 +1076,7 @@ xreal_air_hmd_get_tracked_pose(struct xrt_device *xdev, // Make sure that the orientation is valid. math_quat_normalize(&out_relation->pose.orientation); + return XRT_SUCCESS; } static void diff --git a/src/xrt/include/xrt/xrt_device.h b/src/xrt/include/xrt/xrt_device.h index bee4789a7..4d9a5bebd 100644 --- a/src/xrt/include/xrt/xrt_device.h +++ b/src/xrt/include/xrt/xrt_device.h @@ -319,10 +319,10 @@ struct xrt_device * * @see xrt_input_name */ - void (*get_tracked_pose)(struct xrt_device *xdev, - enum xrt_input_name name, - int64_t at_timestamp_ns, - struct xrt_space_relation *out_relation); + xrt_result_t (*get_tracked_pose)(struct xrt_device *xdev, + enum xrt_input_name name, + int64_t at_timestamp_ns, + struct xrt_space_relation *out_relation); /*! * @brief Get relationship of hand joints to the tracking origin space as @@ -580,8 +580,7 @@ xrt_device_get_tracked_pose(struct xrt_device *xdev, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation) { - xdev->get_tracked_pose(xdev, name, at_timestamp_ns, out_relation); - return XRT_SUCCESS; + return xdev->get_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } /*! diff --git a/src/xrt/ipc/client/ipc_client_device.c b/src/xrt/ipc/client/ipc_client_device.c index 777faa0ad..c6bac7b39 100644 --- a/src/xrt/ipc/client/ipc_client_device.c +++ b/src/xrt/ipc/client/ipc_client_device.c @@ -82,7 +82,7 @@ ipc_client_device_update_inputs(struct xrt_device *xdev) IPC_CHK_ALWAYS_RET(icd->ipc_c, xret, "ipc_call_device_update_input"); } -static void +static xrt_result_t ipc_client_device_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -96,7 +96,7 @@ ipc_client_device_get_tracked_pose(struct xrt_device *xdev, name, // at_timestamp_ns, // out_relation); // - IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_get_tracked_pose"); + IPC_CHK_ALWAYS_RET(icd->ipc_c, xret, "ipc_call_device_get_tracked_pose"); } static void diff --git a/src/xrt/ipc/client/ipc_client_hmd.c b/src/xrt/ipc/client/ipc_client_hmd.c index 7fa921dcd..f4639e144 100644 --- a/src/xrt/ipc/client/ipc_client_hmd.c +++ b/src/xrt/ipc/client/ipc_client_hmd.c @@ -149,7 +149,7 @@ ipc_client_hmd_update_inputs(struct xrt_device *xdev) IPC_CHK_ALWAYS_RET(ich->ipc_c, xret, "ipc_call_device_update_input"); } -static void +static xrt_result_t ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -164,7 +164,7 @@ ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev, name, // at_timestamp_ns, // out_relation); // - IPC_CHK_ONLY_PRINT(ich->ipc_c, xret, "ipc_call_device_get_tracked_pose"); + IPC_CHK_ALWAYS_RET(ich->ipc_c, xret, "ipc_call_device_get_tracked_pose"); } static void diff --git a/src/xrt/targets/sdl_test/sdl_device.c b/src/xrt/targets/sdl_test/sdl_device.c index 89cd5f10a..674d838be 100644 --- a/src/xrt/targets/sdl_test/sdl_device.c +++ b/src/xrt/targets/sdl_test/sdl_device.c @@ -14,7 +14,7 @@ #include "util/u_distortion_mesh.h" -static void +static xrt_result_t sdl_hmd_get_tracked_pose(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, @@ -23,8 +23,8 @@ sdl_hmd_get_tracked_pose(struct xrt_device *xdev, struct sdl_program *sp = from_xdev(xdev); if (name != XRT_INPUT_GENERIC_HEAD_POSE) { - U_LOG_E("Unknown input name"); - return; + U_LOG_XDEV_UNSUPPORTED_INPUT(&sp->xdev_base, u_log_get_global_level(), name); + return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_space_relation relation = XRT_SPACE_RELATION_ZERO; @@ -37,6 +37,8 @@ sdl_hmd_get_tracked_pose(struct xrt_device *xdev, XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT; // *out_relation = relation; + + return XRT_SUCCESS; } static void