Switch between poke and pointer interaction in lobby

This commit is contained in:
Patrick Nicolas
2025-11-13 21:48:10 +01:00
parent a9907e0810
commit 3e8a78002e
7 changed files with 115 additions and 55 deletions
+13 -6
View File
@@ -397,15 +397,22 @@ static void set_clipping_planes(entt::registry & scene, entt::entity entity, std
}
}
void input_profile::apply(entt::registry & scene, XrSpace world_space, XrTime predicted_display_time, bool hide_left, bool hide_right, std::span<glm::vec4> pointer_limits)
void input_profile::apply(
entt::registry & scene,
XrSpace world_space,
XrTime predicted_display_time,
bool hide_left_controller,
bool hide_left_ray,
bool hide_right_controller,
bool hide_right_ray,
std::span<glm::vec4> pointer_limits)
{
for (auto && [entity, node, space]: scene.view<components::node, bound_space>().each())
{
if ((space.space == xr::spaces::grip_left or space.space == xr::spaces::aim_left) and hide_left)
{
node.visible = false;
}
else if ((space.space == xr::spaces::grip_right or space.space == xr::spaces::aim_right) and hide_right)
if ((space.space == xr::spaces::grip_left and hide_left_controller) or
(space.space == xr::spaces::aim_left and hide_left_ray) or
(space.space == xr::spaces::grip_right and hide_right_controller) or
(space.space == xr::spaces::aim_right and hide_right_ray))
{
node.visible = false;
}
+9 -1
View File
@@ -40,5 +40,13 @@ struct input_profile
input_profile(scene & scene, const std::filesystem::path & json_profile, uint32_t layer_mask_controller, uint32_t layer_mask_ray);
// application::poll_actions() must have been called before
void apply(entt::registry & scene, XrSpace world_space, XrTime predicted_display_time, bool hide_left, bool hide_right, std::span<glm::vec4> pointer_limits);
void apply(
entt::registry & scene,
XrSpace world_space,
XrTime predicted_display_time,
bool hide_left_controller,
bool hide_left_ray,
bool hide_right_controller,
bool hide_right_ray,
std::span<glm::vec4> pointer_limits);
};
+23 -3
View File
@@ -1065,7 +1065,14 @@ void scenes::lobby::render(const XrFrameState & frame_state)
ray_limits.push_back(compute_ray_limits(layer.pose));
}
input->apply(world, world_space, frame_state.predictedDisplayTime, hide_left_controller, hide_right_controller, ray_limits);
input->apply(world,
world_space,
frame_state.predictedDisplayTime,
hide_left_controller,
not imgui_ctx->is_aim_interaction()[0],
hide_right_controller,
not imgui_ctx->is_aim_interaction()[1],
ray_limits);
renderer::animate(world, frame_state.predictedDisplayPeriod * 1.0e-9);
@@ -1198,6 +1205,7 @@ void scenes::lobby::on_focused()
std::vector imgui_inputs{
imgui_context::controller{
.index = 0,
.aim = get_action_space("left_aim"),
.offset = input->offset[xr::spaces::aim_left],
.trigger = get_action("left_trigger").first,
@@ -1206,6 +1214,7 @@ void scenes::lobby::on_focused()
.haptic_output = get_action("left_haptic").first,
},
imgui_context::controller{
.index = 1,
.aim = get_action_space("right_aim"),
.offset = input->offset[xr::spaces::aim_right],
.trigger = get_action("right_trigger").first,
@@ -1221,8 +1230,8 @@ void scenes::lobby::on_focused()
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
hand_model::add_hand(*this, XR_HAND_LEFT_EXT, "assets://left-hand.glb", layer_controllers);
hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, "assets://right-hand.glb", layer_controllers);
imgui_inputs.push_back({.hand = &*left_hand});
imgui_inputs.push_back({.hand = &*right_hand});
imgui_inputs.push_back({.index = 0, .hand = &*left_hand});
imgui_inputs.push_back({.index = 1, .hand = &*right_hand});
}
face_tracker = xr::make_face_tracker(instance, system, session);
@@ -1443,6 +1452,17 @@ scene::meta & scenes::lobby::get_meta_scene()
{"right_squeeze", "/user/hand/right/input/menu/click"},
},
},
suggested_binding{
{
"/interaction_profiles/ext/hand_interaction_ext",
},
{
{"left_aim", "/user/hand/left/input/aim/pose"},
{"left_trigger", "/user/hand/left/input/aim_activate_ext"},
{"right_aim", "/user/hand/right/input/aim/pose"},
{"right_trigger", "/user/hand/right/input/aim_activate_ext"},
},
},
}};
return m;
+2
View File
@@ -429,6 +429,7 @@ void scenes::stream::on_focused()
std::array imgui_inputs{
imgui_context::controller{
.index = 0,
.aim = get_action_space("left_aim"),
.offset = input->offset[xr::spaces::aim_left],
.trigger = get_action("left_trigger").first,
@@ -437,6 +438,7 @@ void scenes::stream::on_focused()
.haptic_output = get_action("left_haptic").first,
},
imgui_context::controller{
.index = 1,
.aim = get_action_space("right_aim"),
.offset = input->offset[xr::spaces::aim_right],
.trigger = get_action("right_trigger").first,
+8 -1
View File
@@ -1032,7 +1032,14 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
hide_right_controller = true;
}
input->apply(world, world_space, predicted_display_time, hide_left_controller, hide_right_controller, ray_limits);
input->apply(world,
world_space,
predicted_display_time,
hide_left_controller,
hide_left_controller,
hide_right_controller,
hide_right_controller,
ray_limits);
// Add the layer with the controllers
if (composition_layer_depth_test_supported)