Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-06-28 11:12:41 +00:00
7 changed files with 91 additions and 70 deletions
+65 -10
View File
@@ -238,6 +238,7 @@ void scenes::stream::tracking()
std::vector<from_headset::tracking> tracking;
std::vector<from_headset::tracking> tracking_pool; // pre-allocated objects
std::vector<from_headset::hand_tracking> hands;
std::array<bool, 2> should_skip_simple_controllers{};
std::vector<from_headset::body_tracking> body;
std::vector<XrView> views;
@@ -245,8 +246,22 @@ void scenes::stream::tracking()
std::vector<serialization_packet> packets;
const bool hand_tracking = config.check_feature(feature::hand_tracking);
// Quest hand tracking creates a fake khr/simple_controller when hand tracking
// is enabled, let's not send it when hand tracking data is invalid
bool block_khr_simple_controller = false;
switch (guess_model())
{
case model::meta_quest_3:
case model::meta_quest_pro:
case model::meta_quest_3s:
case model::oculus_quest_2:
block_khr_simple_controller = hand_tracking;
break;
default:
break;
}
from_headset::face_type face_tracking = from_headset::face_type::none;
const bool body_tracking = config.check_feature(feature::body_tracking);
if (config.check_feature(feature::face_tracking))
{
if (application::get_fb_face_tracking2_supported())
@@ -263,6 +278,7 @@ void scenes::stream::tracking()
}
}
const bool body_tracking = config.check_feature(feature::body_tracking);
auto & body_tracker = application::get_body_tracker();
if (body_tracking)
{
@@ -327,31 +343,70 @@ void scenes::stream::tracking()
if (recenter_requested.exchange(false))
packet.state_flags = wivrn::from_headset::tracking::recentered;
packet.device_poses.clear();
for (auto [device, space]: spaces)
{
if (enabled(control, device))
packet.device_poses.emplace_back(locate_space(device, space, world_space, t0 + Δt));
}
// Hand tracking data are very large, send fewer samples than other items
if (hand_tracking and t0 >= last_hand_sample + period and
(Δt == 0 or Δt >= prediction - 2 * period))
{
last_hand_sample = t0;
if (control.enabled[size_t(tid::left_hand)])
{
auto joints = locate_hands(application::get_left_hand(), world_space, t0 + Δt);
should_skip_simple_controllers[0] = !joints.has_value();
hands.emplace_back(
t0,
t0 + Δt,
from_headset::hand_tracking::left,
locate_hands(application::get_left_hand(), world_space, t0 + Δt));
joints);
}
else
{
should_skip_simple_controllers[0] = false;
}
if (control.enabled[size_t(tid::right_hand)])
{
auto joints = locate_hands(application::get_right_hand(), world_space, t0 + Δt);
should_skip_simple_controllers[1] = !joints.has_value();
hands.emplace_back(
t0,
t0 + Δt,
from_headset::hand_tracking::right,
locate_hands(application::get_right_hand(), world_space, t0 + Δt));
joints);
}
else
{
should_skip_simple_controllers[1] = false;
}
}
packet.device_poses.clear();
for (auto [device, space]: spaces)
{
if (enabled(control, device))
{
switch (device)
{
case device_id::LEFT_AIM:
case device_id::LEFT_GRIP:
case device_id::LEFT_PALM:
case device_id::RIGHT_AIM:
case device_id::RIGHT_GRIP:
case device_id::RIGHT_PALM: {
const bool right = device > device_id::LEFT_PALM;
if (block_khr_simple_controller and interaction_profiles[right].load() == interaction_profile::khr_simple_controller and should_skip_simple_controllers[right])
{
packet.device_poses.emplace_back(from_headset::tracking::pose{
.device = device,
});
continue;
}
[[fallthrough]];
}
default:
packet.device_poses.emplace_back(locate_space(device, space, world_space, t0 + Δt));
break;
}
}
}
if (body_tracking)
+4
View File
@@ -77,6 +77,10 @@ std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::
if (!locations.isActive)
return std::nullopt;
// bail if none of the joints are valid/tracked
if (!std::ranges::any_of(joints_pos, [](const auto & loc) { return loc.locationFlags != 0; }))
return std::nullopt;
float offset_angle = 0;
// check if we have a device that needs a thumb offset
+4 -4
View File
@@ -741,8 +741,8 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_
cnx->set_enabled(device, true);
break;
default:
U_LOG_W("Unknown input name requested");
return {};
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_INPUT_UNSUPPORTED;
}
cnx->add_predict_offset(extrapolation_time);
if (auto & out = tracking_dump())
@@ -784,9 +784,9 @@ xrt_result_t wivrn_controller::get_hand_tracking(xrt_input_name name, int64_t de
}
default:
U_LOG_W("Unknown input name requested %d", int(name));
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_INPUT_UNSUPPORTED;
}
return XRT_ERROR_INPUT_UNSUPPORTED;
}
void wivrn_controller::set_derived_pose(const from_headset::derived_pose & derived)
+11 -37
View File
@@ -25,6 +25,7 @@
#include "xrt/xrt_device.h"
#include "util/u_logging.h"
#include "utils/method.h"
#include <cmath>
#include <cstdint>
@@ -34,23 +35,6 @@
namespace wivrn
{
static void wivrn_eye_tracker_destroy(xrt_device * xdev);
static xrt_result_t wivrn_eye_tracker_update_inputs(xrt_device * xdev)
{
static_cast<wivrn_eye_tracker *>(xdev)->update_inputs();
return XRT_SUCCESS;
}
static xrt_result_t wivrn_eye_tracker_get_tracked_pose(xrt_device * xdev,
xrt_input_name name,
int64_t at_timestamp_ns,
xrt_space_relation * out_relation)
{
*out_relation = static_cast<wivrn_eye_tracker *>(xdev)->get_tracked_pose(name, at_timestamp_ns);
return XRT_SUCCESS;
}
wivrn_eye_tracker::wivrn_eye_tracker(xrt_device * hmd) :
xrt_device{
.name = XRT_DEVICE_EYE_GAZE_INTERACTION,
@@ -63,9 +47,9 @@ wivrn_eye_tracker::wivrn_eye_tracker(xrt_device * hmd) :
.supported = {
.eye_gaze = true,
},
.update_inputs = wivrn_eye_tracker_update_inputs,
.get_tracked_pose = wivrn_eye_tracker_get_tracked_pose,
.destroy = wivrn_eye_tracker_destroy,
.update_inputs = method_pointer<&wivrn_eye_tracker::update_inputs>,
.get_tracked_pose = method_pointer<&wivrn_eye_tracker::get_tracked_pose>,
.destroy = [](xrt_device *) {},
},
gaze_input{
.active = true,
@@ -75,36 +59,26 @@ wivrn_eye_tracker::wivrn_eye_tracker(xrt_device * hmd) :
{
}
void wivrn_eye_tracker::update_inputs()
xrt_result_t wivrn_eye_tracker::update_inputs()
{
// Empty
return XRT_SUCCESS;
}
xrt_space_relation wivrn_eye_tracker::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns)
xrt_result_t wivrn_eye_tracker::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation)
{
if (name == XRT_INPUT_GENERIC_EYE_GAZE_POSE)
{
auto [_, relation] = gaze.get_at(at_timestamp_ns);
return relation;
*out_relation = relation;
return XRT_SUCCESS;
}
U_LOG_E("Unknown input name");
return {};
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_INPUT_UNSUPPORTED;
}
void wivrn_eye_tracker::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
{
gaze.update_tracking(tracking, offset);
}
/*
*
* Functions
*
*/
static void wivrn_eye_tracker_destroy(xrt_device * xdev)
{
}
} // namespace wivrn
+4 -2
View File
@@ -38,10 +38,12 @@ class wivrn_eye_tracker : public xrt_device
pose_list gaze;
public:
using base = xrt_device;
wivrn_eye_tracker(xrt_device * hmd);
void update_inputs();
xrt_result_t update_inputs();
void update_tracking(const from_headset::tracking &, const clock_offset &);
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);
};
} // namespace wivrn
+1 -15
View File
@@ -136,20 +136,6 @@ wivrn_generic_tracker::wivrn_generic_tracker(int index, xrt_device * hmd, wivrn_
input_count = 1;
}
#define XRT_INPUT_NAME_CASE(NAME, VALUE) \
case VALUE: \
return #NAME;
const char * input_name_str(xrt_input_name name)
{
switch (name)
{
XRT_INPUT_LIST(XRT_INPUT_NAME_CASE)
default:
return "Unknown";
}
}
xrt_result_t wivrn_generic_tracker::update_inputs()
{
return XRT_SUCCESS;
@@ -167,7 +153,7 @@ xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_
return XRT_SUCCESS;
}
U_LOG_D("Unknown input name %s", input_name_str(name));
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_NOT_IMPLEMENTED;
}
+2 -2
View File
@@ -124,8 +124,8 @@ xrt_result_t wivrn_hmd::get_tracked_pose(xrt_input_name name, int64_t at_timesta
{
if (name != XRT_INPUT_GENERIC_HEAD_POSE)
{
U_LOG_E("Unknown input name");
return {};
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_INPUT_UNSUPPORTED;
}
auto [extrapolation_time, view] = views.get_at(at_timestamp_ns);