diff --git a/client/constants.h b/client/constants.h index 8ed9e3e6..04b8d2a6 100644 --- a/client/constants.h +++ b/client/constants.h @@ -43,7 +43,7 @@ constexpr float scroll_ratio = 10; constexpr float trigger_click_thd = 0.8; // Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI) -constexpr float fingertip_distance_close_thd = 0.15; // Distance to switch between touch and aim interaction +constexpr float palm_distance_close_thd = 0.20; // Distance to switch between touch and aim interaction constexpr float fingertip_distance_touching_thd_hi = -0.01; // Distance to register a click constexpr float fingertip_distance_touching_thd_lo = -0.15; // Distance to register a click constexpr float fingertip_distance_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index 7bd308f7..bf41d9f9 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -581,10 +581,23 @@ std::vector imgui_context::read_controllers_sta } compute_pointer_position(state); - if (state.hover_distance < constants::gui::fingertip_distance_close_thd) - aim_interaction[ctrl.index] = false; - else - state.pointer_position.reset(); + XrHandJointLocationEXT & palm = (*joints)[XR_HAND_JOINT_PALM_EXT].first; + if (palm.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) + { + controller_state palm_state{ + .aim_position = { + palm.pose.position.x, + palm.pose.position.y, + palm.pose.position.z, + }, + .source = ImGuiMouseSource_VRHandTracking, + }; + compute_pointer_position(palm_state); + if (palm_state.hover_distance < constants::gui::palm_distance_close_thd) + aim_interaction[ctrl.index] = false; + else + state.pointer_position.reset(); + } if (state.hover_distance < constants::gui::fingertip_distance_touching_thd_hi and state.hover_distance > constants::gui::fingertip_distance_touching_thd_lo) state.fingertip_touching = true;