Remove model enum, change Quest default power mode

Store all quirks in the hmd_traits object
This commit is contained in:
Patrick Nicolas
2026-05-10 19:11:17 +02:00
committed by xytovl
parent 209145ce0d
commit d8fbbb23ab
12 changed files with 290 additions and 479 deletions
+1 -1
View File
@@ -306,7 +306,7 @@ input_profile::input_profile(scene & scene, const std::filesystem::path & json_p
else
continue;
auto && [ray_entity, ray_node] = scene.add_gltf(runtime_hmd_traits().controller_ray_model, layer_mask_ray);
auto && [ray_entity, ray_node] = scene.add_gltf(hmd_traits.controller_ray_model, layer_mask_ray);
ray_node.name = (std::string)layout.key + "_ray";
spdlog::debug("Created entity {}", ray_node.name);
+3 -3
View File
@@ -1114,7 +1114,7 @@ void scenes::lobby::on_focused()
auto views = system.view_configuration_views(viewconfig);
assert(views.size() == 2); // FIXME
stream_view = override_view_for_hmd(runtime_hmd_traits(), views[0]);
stream_view = hmd_traits.override_view_for_hmd(views[0]);
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
@@ -1135,10 +1135,10 @@ void scenes::lobby::on_focused()
config.save();
}
const std::string_view profile = runtime_hmd_traits().controller_profile;
const auto & profile = hmd_traits.controller_profile;
input.emplace(
*this,
"assets://controllers/" + std::string(profile) + "/profile.json",
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
+29 -36
View File
@@ -217,7 +217,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
{
auto view = self->system.view_configuration_views(self->viewconfig)[0];
view = override_view_for_hmd(runtime_hmd_traits(), view);
view = hmd_traits.override_view_for_hmd(view);
info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale;
info.render_eye_height = view.recommendedImageRectHeight * config.resolution_scale;
@@ -421,10 +421,10 @@ void scenes::stream::on_focused()
{
gui_status_last_change = instance.now();
const std::string_view profile = runtime_hmd_traits().controller_profile;
const auto & profile = hmd_traits.controller_profile;
input.emplace(
*this,
"assets://controllers/" + std::string(profile) + "/profile.json",
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
@@ -684,41 +684,34 @@ void scenes::stream::update_gui_position(xr::spaces controller)
{
std::optional<std::pair<glm::vec3, glm::quat>> aim;
switch (guess_model())
if (hmd_traits.view_locate)
{
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico fails to find its controllers within view space, so use the head position in
// world space as a reference
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::world),
predicted_display_time);
auto head_position = application::locate_controller(application::space(xr::spaces::view),
application::space(xr::spaces::world),
predicted_display_time);
if (not aim || not head_position)
return;
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
aim->second = glm::conjugate(head_position->second) * aim->second;
break;
}
default:
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
if (not aim)
return;
break;
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
}
else
{
// Pico fails to find its controllers within view space, so use the head position in
// world space as a reference
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::world),
predicted_display_time);
auto head_position = application::locate_controller(application::space(xr::spaces::view),
application::space(xr::spaces::world),
predicted_display_time);
if (not(aim and head_position))
return;
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
aim->second = glm::conjugate(head_position->second) * aim->second;
}
if (not aim)
return;
auto [offset_position, offset_orientation] = input->offset[controller];
+1 -1
View File
@@ -127,7 +127,7 @@ stream_defoveator::pipeline_t & stream_defoveator::ensure_pipeline(size_t view,
// Fragment shader
auto specialization = make_specialization_constants(
int32_t(alpha),
VkBool32(runtime_hmd_traits().needs_srgb_conversion));
VkBool32(hmd_traits.needs_srgb_conversion));
auto fragment_shader = load_shader(device, "reprojection.frag");
vk::pipeline_builder pipeline_info{
+45 -57
View File
@@ -493,36 +493,31 @@ void scenes::stream::tracking()
break;
case wivrn::device_id::EYE_GAZE:
// Eye gaze uses view pose as the origin
switch (guess_model())
if (hmd_traits.view_locate)
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
else
{
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::tracking::flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
break;
default:
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
break;
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::tracking::flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
break;
case wivrn::device_id::FACE:
@@ -759,37 +754,30 @@ void scenes::stream::send_derived_pose()
{
// This may happen if the runtime does not support palm ext
// check if we have a device specific offset
switch (guess_model())
if (not hmd_traits.hand_interaction_grip_surface)
{
case model::oculus_quest:
case model::oculus_quest_2:
case model::meta_quest_pro:
case model::meta_quest_3:
case model::meta_quest_3s:
switch (target)
{
case device_id::LEFT_PALM:
case device_id::RIGHT_PALM: {
glm::quat q(glm::vec3(glm::radians(-60.), 0, 0));
network_session->send_control(from_headset::derived_pose{
.source = source,
.target = target,
.relation = {
.orientation = {
.x = q.x,
.y = q.y,
.z = q.z,
.w = q.w,
},
},
});
}
break;
default:
break;
switch (target)
{
case device_id::LEFT_PALM:
case device_id::RIGHT_PALM: {
glm::quat q(glm::vec3(glm::radians(-60.), 0, 0));
network_session->send_control(from_headset::derived_pose{
.source = source,
.target = target,
.relation = {
.orientation = {
.x = q.x,
.y = q.y,
.z = q.z,
.w = q.w,
},
},
});
}
default:
break;
default:
break;
}
}
}
else