From 8126bb0541a366dd6a4b4b05410a2720faf5cbfa Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 27 Oct 2024 20:14:10 +0100 Subject: [PATCH] Improve virtual keyboard behaviour when using hand tracking --- client/render/imgui_impl.cpp | 6 +++--- client/scenes/lobby_keyboard.cpp | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index 4324a337..59cccc38 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -206,7 +206,7 @@ std::vector> imgui_context::ray_plane_intersection(cons // => ray_start.z + distance × ray_dir.z = 0 float distance = -ray_start.z / ray_dir.z; - if (distance < 0) + if (distance < -0.1) continue; coord.x = ray_start.x + distance * ray_dir.x; @@ -687,10 +687,10 @@ std::vector imgui_context::read_controllers_sta if (state.source == ImGuiMouseSource_VRHandTracking) { // TODO tunable - if (std::abs(state.hover_distance) < 0.1) + if (state.hover_distance < 0.15) state.fingertip_hovering = true; - if (std::abs(state.hover_distance) < 0.02) + if (state.hover_distance < 0.05) state.fingertip_touching = true; } } diff --git a/client/scenes/lobby_keyboard.cpp b/client/scenes/lobby_keyboard.cpp index ab116883..23f11433 100644 --- a/client/scenes/lobby_keyboard.cpp +++ b/client/scenes/lobby_keyboard.cpp @@ -292,12 +292,7 @@ virtual_keyboard::key_status virtual_keyboard::button_behavior(const ImRect & bb ImGuiContext & g = *GImGui; if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) - { - if (g.IO.MouseSource == ImGuiMouseSource_VRHandTracking) - flags |= ImGuiButtonFlags_PressedOnClick; - else - flags |= ImGuiButtonFlags_PressedOnClickRelease; - } + flags |= ImGuiButtonFlags_PressedOnClickRelease; bool pressed = false; bool hovered = window_hovered and ImGui::IsMouseHoveringRect(bb.Min, bb.Max);