From 8f0ca7b04c8ceacffc3f437bdf795da7f0fcd945 Mon Sep 17 00:00:00 2001 From: Sapphire Date: Sat, 5 Jul 2025 00:27:17 -0500 Subject: [PATCH] Forward XR_EXT_hand_interaction * Fix binds * hand_interaction tids --- client/application.cpp | 83 +++++++++++++-- client/scenes/stream.cpp | 15 +++ client/scenes/stream_tracking.cpp | 104 ++++++++++++------- client/xr/space.h | 5 + common/wivrn_packets.h | 161 ++++++++++++++++------------- server/CMakeLists.txt | 2 +- server/driver/wivrn_controller.cpp | 85 +++++++++++++++ server/driver/wivrn_controller.h | 3 + server/driver/wivrn_session.cpp | 10 ++ 9 files changed, 350 insertions(+), 118 deletions(-) diff --git a/client/application.cpp b/client/application.cpp index 5bf205af..7d51d097 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -517,6 +517,35 @@ static std::vector interaction_profiles{ "/user/hand/right/input/thumbrest/touch", }, }, + interaction_profile{ + .profile_name = "/interaction_profiles/ext/hand_interaction_ext", + .required_extensions = {"XR_EXT_hand_interaction"}, + .input_sources = { + "/user/hand/left/input/aim/pose", + "/user/hand/left/input/grip/pose", + + "/user/hand/left/input/pinch_ext/pose", + "/user/hand/left/input/pinch_ext/value", + "/user/hand/left/input/pinch_ext/ready_ext", + "/user/hand/left/input/poke_ext/pose", + "/user/hand/left/input/aim_activate_ext/value", + "/user/hand/left/input/aim_activate_ext/ready_ext", + "/user/hand/left/input/grasp_ext/value", + "/user/hand/left/input/grasp_ext/ready_ext", + + "/user/hand/right/input/aim/pose", + "/user/hand/right/input/grip/pose", + + "/user/hand/right/input/pinch_ext/pose", + "/user/hand/right/input/pinch_ext/value", + "/user/hand/right/input/pinch_ext/ready_ext", + "/user/hand/right/input/poke_ext/pose", + "/user/hand/right/input/aim_activate_ext/value", + "/user/hand/right/input/aim_activate_ext/ready_ext", + "/user/hand/right/input/grasp_ext/value", + "/user/hand/right/input/grasp_ext/ready_ext", + }, + }, interaction_profile{ .profile_name = "/interaction_profiles/htc/vive_xr_tracker", .required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"}, @@ -556,6 +585,9 @@ static const std::pair action_suffixes[] = {"/joystick", XR_ACTION_TYPE_VECTOR2F_INPUT}, {"/trackball", XR_ACTION_TYPE_VECTOR2F_INPUT}, + // XR_EXT_hand_interaction + {"/ready_ext", XR_ACTION_TYPE_BOOLEAN_INPUT}, + // Output paths {"/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT}, {"/haptic_trigger", XR_ACTION_TYPE_VIBRATION_OUTPUT}, @@ -949,19 +981,41 @@ void application::initialize_actions() continue; // Patch profile to add grip_surface or palm_ext - if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) // - and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") // - and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose")) + bool add_palms = true; + if (profile.profile_name.ends_with("ext/hand_interaction_ext")) { - profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose"); - profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose"); + switch (guess_model()) + { + // Quest breaks spec and does not support grip_surface for ext/hand_interaction_ext + case model::meta_quest_3: + case model::meta_quest_pro: + case model::meta_quest_3s: + case model::oculus_quest_2: + case model::oculus_quest: + add_palms = false; + break; + default: + break; + } } - else if (utils::contains(xr_extensions, XR_EXT_PALM_POSE_EXTENSION_NAME) // - and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") // - and not utils::contains(profile.input_sources, "/user/hand/left/input/palm_ext/pose")) + if (add_palms) { - profile.input_sources.push_back("/user/hand/left/input/palm_ext/pose"); - profile.input_sources.push_back("/user/hand/right/input/palm_ext/pose"); + if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) // + and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") // + and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose")) + { + spdlog::info("Adding grip_surface/pose for interaction profile {}", profile.profile_name); + profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose"); + profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose"); + } + else if (utils::contains(xr_extensions, XR_EXT_PALM_POSE_EXTENSION_NAME) // + and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") // + and not utils::contains(profile.input_sources, "/user/hand/left/input/palm_ext/pose")) + { + spdlog::info("Adding palm_ext/pose for interaction profile {}", profile.profile_name); + profile.input_sources.push_back("/user/hand/left/input/palm_ext/pose"); + profile.input_sources.push_back("/user/hand/right/input/palm_ext/pose"); + } } // Dynamically add VIVE XR Trackers to the profile if available @@ -1004,12 +1058,20 @@ void application::initialize_actions() spaces[size_t(xr::spaces::aim_left)] = xr_session.create_action_space(a); else if (name == "/user/hand/left/input/palm_ext/pose" or name == "/user/hand/left/input/grip_surface/pose") spaces[size_t(xr::spaces::palm_left)] = xr_session.create_action_space(a); + else if (name == "/user/hand/left/input/pinch_ext/pose") + spaces[size_t(xr::spaces::pinch_left)] = xr_session.create_action_space(a); + else if (name == "/user/hand/left/input/poke_ext/pose") + spaces[size_t(xr::spaces::poke_left)] = xr_session.create_action_space(a); else if (name == "/user/hand/right/input/grip/pose") spaces[size_t(xr::spaces::grip_right)] = xr_session.create_action_space(a); else if (name == "/user/hand/right/input/aim/pose") spaces[size_t(xr::spaces::aim_right)] = xr_session.create_action_space(a); else if (name == "/user/hand/right/input/palm_ext/pose" or name == "/user/hand/right/input/grip_surface/pose") spaces[size_t(xr::spaces::palm_right)] = xr_session.create_action_space(a); + else if (name == "/user/hand/right/input/pinch_ext/pose") + spaces[size_t(xr::spaces::pinch_right)] = xr_session.create_action_space(a); + else if (name == "/user/hand/right/input/poke_ext/pose") + spaces[size_t(xr::spaces::poke_right)] = xr_session.create_action_space(a); else if (name == "/user/eyes_ext/input/gaze_ext/pose") spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a); else if (name.contains("/input/entity_htc/pose") && htc_body) @@ -1098,6 +1160,7 @@ void application::initialize() opt_extensions.push_back(XR_KHR_MAINTENANCE1_EXTENSION_NAME); opt_extensions.push_back(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME); opt_extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME); + opt_extensions.push_back(XR_EXT_HAND_INTERACTION_EXTENSION_NAME); opt_extensions.push_back(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME); opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME); opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME); diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index 352350f9..85134d44 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -117,6 +117,21 @@ static const std::unordered_map device_ids = { {"/user/hand/right/input/trackpad/force", device_id::RIGHT_TRACKPAD_FORCE}, {"/user/hand/right/input/stylus/force", device_id::RIGHT_STYLUS_FORCE}, {"/user/hand/right/input/stylus_fb/force", device_id::RIGHT_STYLUS_FORCE}, + + // XR_EXT_hand_interaction + {"/user/hand/left/input/pinch_ext/value", device_id::LEFT_PINCH_VALUE}, + {"/user/hand/left/input/pinch_ext/ready_ext", device_id::LEFT_PINCH_READY}, + {"/user/hand/left/input/aim_activate_ext/value",device_id::LEFT_AIM_ACTIVATE_VALUE}, + {"/user/hand/left/input/aim_activate_ext/ready_ext",device_id::LEFT_AIM_ACTIVATE_READY}, + {"/user/hand/left/input/grasp_ext/value", device_id::LEFT_GRASP_VALUE}, + {"/user/hand/left/input/grasp_ext/ready_ext", device_id::LEFT_GRASP_READY}, + + {"/user/hand/right/input/pinch_ext/value", device_id::RIGHT_PINCH_VALUE}, + {"/user/hand/right/input/pinch_ext/ready_ext", device_id::RIGHT_PINCH_READY}, + {"/user/hand/right/input/aim_activate_ext/value",device_id::RIGHT_AIM_ACTIVATE_VALUE}, + {"/user/hand/right/input/aim_activate_ext/ready_ext",device_id::RIGHT_AIM_ACTIVATE_READY}, + {"/user/hand/right/input/grasp_ext/value", device_id::RIGHT_GRASP_VALUE}, + {"/user/hand/right/input/grasp_ext/ready_ext", device_id::RIGHT_GRASP_READY}, }; // clang-format on diff --git a/client/scenes/stream_tracking.cpp b/client/scenes/stream_tracking.cpp index 7aaadf04..76f70ec1 100644 --- a/client/scenes/stream_tracking.cpp +++ b/client/scenes/stream_tracking.cpp @@ -234,31 +234,6 @@ static std::optional static T & from_pool(std::vector & container, std::vector & pool) { @@ -283,12 +258,20 @@ static xr::spaces device_to_space(device_id id) return xr::spaces::grip_left; case device_id::LEFT_PALM: return xr::spaces::palm_left; + case device_id::LEFT_PINCH_POSE: + return xr::spaces::pinch_left; + case device_id::LEFT_POKE: + return xr::spaces::poke_left; case device_id::RIGHT_AIM: return xr::spaces::aim_right; case device_id::RIGHT_GRIP: return xr::spaces::grip_right; case device_id::RIGHT_PALM: return xr::spaces::palm_right; + case device_id::RIGHT_PINCH_POSE: + return xr::spaces::pinch_right; + case device_id::RIGHT_POKE: + return xr::spaces::poke_right; default: assert(false); __builtin_unreachable(); @@ -306,20 +289,66 @@ void scenes::stream::tracking() #endif std::vector> spaces; - for (auto id: { - device_id::HEAD, - device_id::LEFT_AIM, - device_id::LEFT_GRIP, - device_id::LEFT_PALM, - device_id::RIGHT_AIM, - device_id::RIGHT_GRIP, - device_id::RIGHT_PALM, - }) + { - if (XrSpace space = application::space(device_to_space(id))) - spaces.emplace_back(id, space); + std::vector ids{ + device_id::HEAD, + device_id::LEFT_AIM, + device_id::LEFT_GRIP, + device_id::LEFT_PALM, + device_id::RIGHT_AIM, + device_id::RIGHT_GRIP, + device_id::RIGHT_PALM, + }; + if (instance.has_extension("XR_EXT_hand_interaction")) + { + spdlog::info("Adding hand_interaction poses to device list"); + ids.insert(ids.end(), {device_id::LEFT_PINCH_POSE, device_id::LEFT_POKE, device_id::RIGHT_PINCH_POSE, device_id::RIGHT_POKE}); + } + + for (auto id: ids) + { + if (XrSpace space = application::space(device_to_space(id))) + spaces.emplace_back(id, space); + else + spdlog::warn("Missing space for device {}", magic_enum::enum_name(id)); + } } + auto enabled = [this](const to_headset::tracking_control & control, device_id id) -> bool { + switch (id) + { + case device_id::HEAD: + case device_id::EYE_GAZE: + return true; + case device_id::LEFT_AIM: + return control.enabled[size_t(tid::left_aim)]; + case device_id::LEFT_GRIP: + return control.enabled[size_t(tid::left_grip)]; + case device_id::LEFT_PALM: + return control.enabled[size_t(tid::left_palm)]; + case device_id::LEFT_PINCH_POSE: + case device_id::LEFT_POKE: { + const auto tracking_id = id == device_id::LEFT_PINCH_POSE ? tid::left_pinch : tid::left_poke; + return control.enabled[size_t(tracking_id)] and interaction_profiles[0].load() == interaction_profile::ext_hand_interaction_ext; + } + case device_id::RIGHT_AIM: + return control.enabled[size_t(tid::right_aim)]; + case device_id::RIGHT_GRIP: + return control.enabled[size_t(tid::right_grip)]; + case device_id::RIGHT_PALM: + return control.enabled[size_t(tid::right_palm)]; + case device_id::RIGHT_PINCH_POSE: + case device_id::RIGHT_POKE: { + const auto tracking_id = id == device_id::RIGHT_PINCH_POSE ? tid::right_pinch : tid::right_poke; + return control.enabled[size_t(tracking_id)] and interaction_profiles[1].load() == interaction_profile::ext_hand_interaction_ext; + } + default: + break; + } + throw std::runtime_error("enabled called on unhandled device " + std::string(magic_enum::enum_name(id))); + }; + const auto & config = application::get_config(); if (config.check_feature(feature::eye_gaze)) @@ -712,6 +741,7 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction auto profile = session.get_current_interaction_profile(path[i]); spdlog::info("interaction profile for {}: {}", path[i], profile); DO_PROFILE(khr, simple_controller) + DO_PROFILE(ext, hand_interaction_ext) DO_PROFILE(bytedance, pico_neo3_controller) DO_PROFILE(bytedance, pico4_controller) DO_PROFILE(bytedance, pico4s_controller) @@ -737,7 +767,7 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction } catch (std::exception & e) { - spdlog::warn("Failed to get current interation profile: {}", e.what()); + spdlog::warn("Failed to get current interaction profile: {}", e.what()); } interaction_profiles[i] = interaction_profile::none; } diff --git a/client/xr/space.h b/client/xr/space.h index da35f20b..51e702a3 100644 --- a/client/xr/space.h +++ b/client/xr/space.h @@ -37,6 +37,11 @@ enum class spaces aim_right, palm_left, palm_right, + // hand_interaction_ext + pinch_left, + pinch_right, + poke_left, + poke_right, count }; diff --git a/common/wivrn_packets.h b/common/wivrn_packets.h index e08453c5..3571b5c6 100644 --- a/common/wivrn_packets.h +++ b/common/wivrn_packets.h @@ -45,82 +45,99 @@ static constexpr int protocol_revision = 1; enum class device_id : uint8_t { - HEAD, // /user/head - LEFT_CONTROLLER_HAPTIC, // /user/hand/left/output/haptic - RIGHT_CONTROLLER_HAPTIC, // /user/hand/right/output/haptic - LEFT_TRIGGER_HAPTIC, // /user/hand/left/output/haptic_trigger - RIGHT_TRIGGER_HAPTIC, // /user/hand/right/output/haptic_trigger - LEFT_THUMB_HAPTIC, // /user/hand/left/output/haptic_thumb - RIGHT_THUMB_HAPTIC, // /user/hand/right/output/haptic_thumb - LEFT_GRIP, // /user/hand/left/input/grip/pose - LEFT_AIM, // /user/hand/left/input/aim/pose - LEFT_PALM, // /user/hand/left/palm_ext/pose - RIGHT_GRIP, // /user/hand/right/input/grip/pose - RIGHT_AIM, // /user/hand/right/input/aim/pose - RIGHT_PALM, // /user/hand/right/palm_ext/pose - X_CLICK, // /user/hand/left/input/x/click - X_TOUCH, // /user/hand/left/input/x/touch - Y_CLICK, // /user/hand/left/input/y/click - Y_TOUCH, // /user/hand/left/input/y/touch - MENU_CLICK, // /user/hand/left/input/menu/click - LEFT_SQUEEZE_CLICK, // /user/hand/left/input/squeeze/click - LEFT_SQUEEZE_FORCE, // /user/hand/left/input/squeeze/force - LEFT_SQUEEZE_VALUE, // /user/hand/left/input/squeeze/value - LEFT_TRIGGER_CLICK, // /user/hand/left/input/trigger/click - LEFT_TRIGGER_VALUE, // /user/hand/left/input/trigger/value - LEFT_TRIGGER_TOUCH, // /user/hand/left/input/trigger/touch - LEFT_TRIGGER_PROXIMITY, // /user/hand/left/input/trigger/proximity - LEFT_TRIGGER_CURL, // /user/hand/left/input/trigger/curl_fb - LEFT_TRIGGER_SLIDE, // /user/hand/left/input/trigger/slide_fb - LEFT_TRIGGER_FORCE, // /user/hand/left/input/trigger/force - LEFT_THUMBSTICK_X, // /user/hand/left/input/thumbstick/x - LEFT_THUMBSTICK_Y, // /user/hand/left/input/thumbstick/y - LEFT_THUMBSTICK_CLICK, // /user/hand/left/input/thumbstick/click - LEFT_THUMBSTICK_TOUCH, // /user/hand/left/input/thumbstick/touch - LEFT_THUMBREST_TOUCH, // /user/hand/left/input/thumbrest/touch - LEFT_THUMBREST_FORCE, // /user/hand/left/input/thumbrest/force - LEFT_THUMB_PROXIMITY, // /user/hand/left/input/thumb_resting_surfaces/proximity - LEFT_TRACKPAD_X, // /user/hand/left/input/trackpad/x - LEFT_TRACKPAD_Y, // /user/hand/left/input/trackpad/y - LEFT_TRACKPAD_CLICK, // /user/hand/left/input/trackpad/click - LEFT_TRACKPAD_TOUCH, // /user/hand/left/input/trackpad/touch - LEFT_TRACKPAD_FORCE, // /user/hand/left/input/trackpad/force - LEFT_STYLUS_FORCE, // /user/hand/left/input/stylus_fb/force - A_CLICK, // /user/hand/right/input/a/click - A_TOUCH, // /user/hand/right/input/a/touch - B_CLICK, // /user/hand/right/input/b/click - B_TOUCH, // /user/hand/right/input/b/touch - SYSTEM_CLICK, // /user/hand/right/input/system/click - RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click - RIGHT_SQUEEZE_FORCE, // /user/hand/right/input/squeeze/force - RIGHT_SQUEEZE_VALUE, // /user/hand/right/input/squeeze/value - RIGHT_TRIGGER_CLICK, // /user/hand/right/input/trigger/click - RIGHT_TRIGGER_VALUE, // /user/hand/right/input/trigger/value - RIGHT_TRIGGER_TOUCH, // /user/hand/right/input/trigger/touch - RIGHT_TRIGGER_PROXIMITY, // /user/hand/right/input/trigger/proximity - RIGHT_TRIGGER_CURL, // /user/hand/right/input/trigger/curl_fb - RIGHT_TRIGGER_SLIDE, // /user/hand/right/input/trigger/slide_fb - RIGHT_TRIGGER_FORCE, // /user/hand/right/input/trigger/force - RIGHT_THUMBSTICK_X, // /user/hand/right/input/thumbstick/x - RIGHT_THUMBSTICK_Y, // /user/hand/right/input/thumbstick/y - RIGHT_THUMBSTICK_CLICK, // /user/hand/right/input/thumbstick/click - RIGHT_THUMBSTICK_TOUCH, // /user/hand/right/input/thumbstick/touch - RIGHT_THUMBREST_TOUCH, // /user/hand/right/input/thumbrest/touch - RIGHT_THUMBREST_FORCE, // /user/hand/right/input/thumbrest/force - RIGHT_THUMB_PROXIMITY, // /user/hand/right/input/thumb_resting_surfaces/proximity - RIGHT_TRACKPAD_X, // /user/hand/right/input/trackpad/x - RIGHT_TRACKPAD_Y, // /user/hand/right/input/trackpad/y - RIGHT_TRACKPAD_CLICK, // /user/hand/right/input/trackpad/click - RIGHT_TRACKPAD_TOUCH, // /user/hand/right/input/trackpad/touch - RIGHT_TRACKPAD_FORCE, // /user/hand/right/input/trackpad/force - RIGHT_STYLUS_FORCE, // /user/hand/right/input/stylus_fb/force - EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose + HEAD, // /user/head + LEFT_CONTROLLER_HAPTIC, // /user/hand/left/output/haptic + RIGHT_CONTROLLER_HAPTIC, // /user/hand/right/output/haptic + LEFT_TRIGGER_HAPTIC, // /user/hand/left/output/haptic_trigger + RIGHT_TRIGGER_HAPTIC, // /user/hand/right/output/haptic_trigger + LEFT_THUMB_HAPTIC, // /user/hand/left/output/haptic_thumb + RIGHT_THUMB_HAPTIC, // /user/hand/right/output/haptic_thumb + LEFT_GRIP, // /user/hand/left/input/grip/pose + LEFT_AIM, // /user/hand/left/input/aim/pose + LEFT_PALM, // /user/hand/left/palm_ext/pose + RIGHT_GRIP, // /user/hand/right/input/grip/pose + RIGHT_AIM, // /user/hand/right/input/aim/pose + RIGHT_PALM, // /user/hand/right/palm_ext/pose + X_CLICK, // /user/hand/left/input/x/click + X_TOUCH, // /user/hand/left/input/x/touch + Y_CLICK, // /user/hand/left/input/y/click + Y_TOUCH, // /user/hand/left/input/y/touch + MENU_CLICK, // /user/hand/left/input/menu/click + LEFT_SQUEEZE_CLICK, // /user/hand/left/input/squeeze/click + LEFT_SQUEEZE_FORCE, // /user/hand/left/input/squeeze/force + LEFT_SQUEEZE_VALUE, // /user/hand/left/input/squeeze/value + LEFT_TRIGGER_CLICK, // /user/hand/left/input/trigger/click + LEFT_TRIGGER_VALUE, // /user/hand/left/input/trigger/value + LEFT_TRIGGER_TOUCH, // /user/hand/left/input/trigger/touch + LEFT_TRIGGER_PROXIMITY, // /user/hand/left/input/trigger/proximity + LEFT_TRIGGER_CURL, // /user/hand/left/input/trigger/curl_fb + LEFT_TRIGGER_SLIDE, // /user/hand/left/input/trigger/slide_fb + LEFT_TRIGGER_FORCE, // /user/hand/left/input/trigger/force + LEFT_THUMBSTICK_X, // /user/hand/left/input/thumbstick/x + LEFT_THUMBSTICK_Y, // /user/hand/left/input/thumbstick/y + LEFT_THUMBSTICK_CLICK, // /user/hand/left/input/thumbstick/click + LEFT_THUMBSTICK_TOUCH, // /user/hand/left/input/thumbstick/touch + LEFT_THUMBREST_TOUCH, // /user/hand/left/input/thumbrest/touch + LEFT_THUMBREST_FORCE, // /user/hand/left/input/thumbrest/force + LEFT_THUMB_PROXIMITY, // /user/hand/left/input/thumb_resting_surfaces/proximity + LEFT_TRACKPAD_X, // /user/hand/left/input/trackpad/x + LEFT_TRACKPAD_Y, // /user/hand/left/input/trackpad/y + LEFT_TRACKPAD_CLICK, // /user/hand/left/input/trackpad/click + LEFT_TRACKPAD_TOUCH, // /user/hand/left/input/trackpad/touch + LEFT_TRACKPAD_FORCE, // /user/hand/left/input/trackpad/force + LEFT_STYLUS_FORCE, // /user/hand/left/input/stylus_fb/force + LEFT_PINCH_POSE, // /user/hand/left/input/pinch_ext/pose + LEFT_PINCH_VALUE, // /user/hand/left/input/pinch_ext/value + LEFT_PINCH_READY, // /user/hand/left/input/pinch_ext/ready_ext + LEFT_POKE, // /user/hand/left/input/poke_ext/pose + LEFT_AIM_ACTIVATE_VALUE, // /user/hand/left/input/aim_activate_ext/value + LEFT_AIM_ACTIVATE_READY, // /user/hand/left/input/aim_activate_ext/ready_ext + LEFT_GRASP_VALUE, // /user/hand/left/input/grasp_ext/value + LEFT_GRASP_READY, // /user/hand/left/input/grasp_ext/ready_ext + A_CLICK, // /user/hand/right/input/a/click + A_TOUCH, // /user/hand/right/input/a/touch + B_CLICK, // /user/hand/right/input/b/click + B_TOUCH, // /user/hand/right/input/b/touch + SYSTEM_CLICK, // /user/hand/right/input/system/click + RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click + RIGHT_SQUEEZE_FORCE, // /user/hand/right/input/squeeze/force + RIGHT_SQUEEZE_VALUE, // /user/hand/right/input/squeeze/value + RIGHT_TRIGGER_CLICK, // /user/hand/right/input/trigger/click + RIGHT_TRIGGER_VALUE, // /user/hand/right/input/trigger/value + RIGHT_TRIGGER_TOUCH, // /user/hand/right/input/trigger/touch + RIGHT_TRIGGER_PROXIMITY, // /user/hand/right/input/trigger/proximity + RIGHT_TRIGGER_CURL, // /user/hand/right/input/trigger/curl_fb + RIGHT_TRIGGER_SLIDE, // /user/hand/right/input/trigger/slide_fb + RIGHT_TRIGGER_FORCE, // /user/hand/right/input/trigger/force + RIGHT_THUMBSTICK_X, // /user/hand/right/input/thumbstick/x + RIGHT_THUMBSTICK_Y, // /user/hand/right/input/thumbstick/y + RIGHT_THUMBSTICK_CLICK, // /user/hand/right/input/thumbstick/click + RIGHT_THUMBSTICK_TOUCH, // /user/hand/right/input/thumbstick/touch + RIGHT_THUMBREST_TOUCH, // /user/hand/right/input/thumbrest/touch + RIGHT_THUMBREST_FORCE, // /user/hand/right/input/thumbrest/force + RIGHT_THUMB_PROXIMITY, // /user/hand/right/input/thumb_resting_surfaces/proximity + RIGHT_TRACKPAD_X, // /user/hand/right/input/trackpad/x + RIGHT_TRACKPAD_Y, // /user/hand/right/input/trackpad/y + RIGHT_TRACKPAD_CLICK, // /user/hand/right/input/trackpad/click + RIGHT_TRACKPAD_TOUCH, // /user/hand/right/input/trackpad/touch + RIGHT_TRACKPAD_FORCE, // /user/hand/right/input/trackpad/force + RIGHT_STYLUS_FORCE, // /user/hand/right/input/stylus_fb/force + RIGHT_PINCH_POSE, // /user/hand/right/input/pinch_ext/pose + RIGHT_PINCH_VALUE, // /user/hand/right/input/pinch_ext/value + RIGHT_PINCH_READY, // /user/hand/right/input/pinch_ext/ready_ext + RIGHT_POKE, // /user/hand/right/input/poke_ext/pose + RIGHT_AIM_ACTIVATE_VALUE, // /user/hand/right/input/aim_activate_ext/value + RIGHT_AIM_ACTIVATE_READY, // /user/hand/right/input/aim_activate_ext/ready_ext + RIGHT_GRASP_VALUE, // /user/hand/right/input/grasp_ext/value + RIGHT_GRASP_READY, // /user/hand/right/input/grasp_ext/ready_ext + EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose }; enum class interaction_profile : uint8_t { none, khr_simple_controller, + ext_hand_interaction_ext, bytedance_pico_neo3_controller, bytedance_pico4_controller, bytedance_pico4s_controller, @@ -600,9 +617,13 @@ struct tracking_control left_aim, left_grip, left_palm, + left_pinch, + left_poke, right_aim, right_grip, right_palm, + right_pinch, + right_poke, left_hand, right_hand, face, diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 285e8bbf..e3e4b029 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -36,12 +36,12 @@ set(XRT_FEATURE_RENDERDOC ${WIVRN_FEATURE_RENDERDOC}) set(XRT_FEATURE_OPENXR_FACE_TRACKING2_FB ON) set(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC ON) set(XRT_FEATURE_OPENXR_HAND_TRACKING_EXT ON) +set(XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND ON) set(XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE ON) set(XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE ON) set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON) set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PRO ON) set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PLUS ON) -set(XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND OFF) set(XRT_HAVE_BLUETOOTH OFF) set(XRT_HAVE_GST OFF) diff --git a/server/driver/wivrn_controller.cpp b/server/driver/wivrn_controller.cpp index 0598068c..7c8f1bd9 100644 --- a/server/driver/wivrn_controller.cpp +++ b/server/driver/wivrn_controller.cpp @@ -77,6 +77,14 @@ enum wivrn_controller_input_index WIVRN_CONTROLLER_TRACKPAD_FORCE, // /user/hand/XXXX/input/trackpad/force WIVRN_CONTROLLER_TRACKPAD_TOUCH, // /user/hand/XXXX/input/trackpad/touch WIVRN_CONTROLLER_STYLUS_FORCE, // /user/hand/XXXX/input/stylus_fb/force + WIVRN_CONTROLLER_PINCH_POSE, // /user/hand/XXXX/input/pinch_ext/pose + WIVRN_CONTROLLER_PINCH_VALUE, // /user/hand/XXXX/input/pinch_ext/value + WIVRN_CONTROLLER_PINCH_READY, // /user/hand/XXXX/input/pinch_ext/ready_ext + WIVRN_CONTROLLER_POKE_POSE, // /user/hand/XXXX/input/poke_ext/pose + WIVRN_CONTROLLER_AIM_ACTIVATE_VALUE, // /user/hand/XXXX/input/aim_activate_ext/value + WIVRN_CONTROLLER_AIM_ACTIVATE_READY, // /user/hand/XXXX/input/aim_activate_ext/ready_ext + WIVRN_CONTROLLER_GRASP_VALUE, // /user/hand/XXXX/input/grasp_ext/value + WIVRN_CONTROLLER_GRASP_READY, // /user/hand/XXXX/input/ready_ext/value WIVRN_CONTROLLER_INPUT_COUNT }; @@ -234,6 +242,39 @@ static input_data map_input(device_id id) return {WIVRN_CONTROLLER_THUMBREST_FORCE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; case device_id::RIGHT_STYLUS_FORCE: return {WIVRN_CONTROLLER_STYLUS_FORCE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + // XR_EXT_hand_interaction + case device_id::LEFT_PINCH_POSE: + return {WIVRN_CONTROLLER_PINCH_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::LEFT_PINCH_VALUE: + return {WIVRN_CONTROLLER_PINCH_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::LEFT_PINCH_READY: + return {WIVRN_CONTROLLER_PINCH_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::RIGHT_PINCH_POSE: + return {WIVRN_CONTROLLER_PINCH_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::RIGHT_PINCH_VALUE: + return {WIVRN_CONTROLLER_PINCH_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::RIGHT_PINCH_READY: + return {WIVRN_CONTROLLER_PINCH_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::LEFT_POKE: + return {WIVRN_CONTROLLER_POKE_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::RIGHT_POKE: + return {WIVRN_CONTROLLER_POKE_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::LEFT_AIM_ACTIVATE_VALUE: + return {WIVRN_CONTROLLER_AIM_ACTIVATE_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::LEFT_AIM_ACTIVATE_READY: + return {WIVRN_CONTROLLER_AIM_ACTIVATE_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::LEFT_GRASP_VALUE: + return {WIVRN_CONTROLLER_GRASP_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::LEFT_GRASP_READY: + return {WIVRN_CONTROLLER_GRASP_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER}; + case device_id::RIGHT_AIM_ACTIVATE_VALUE: + return {WIVRN_CONTROLLER_AIM_ACTIVATE_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::RIGHT_AIM_ACTIVATE_READY: + return {WIVRN_CONTROLLER_AIM_ACTIVATE_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::RIGHT_GRASP_VALUE: + return {WIVRN_CONTROLLER_GRASP_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; + case device_id::RIGHT_GRASP_READY: + return {WIVRN_CONTROLLER_GRASP_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER}; default: break; } @@ -251,6 +292,19 @@ static xrt_binding_output_pair simple_output_binding[] = { {XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_TOUCH_HAPTIC}, }; +static xrt_binding_input_pair hand_interaction_input_binding[] = { + {XRT_INPUT_HAND_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE}, + {XRT_INPUT_HAND_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE}, + {XRT_INPUT_HAND_PINCH_POSE, XRT_INPUT_HAND_PINCH_POSE}, + {XRT_INPUT_HAND_PINCH_VALUE, XRT_INPUT_HAND_PINCH_VALUE}, + {XRT_INPUT_HAND_PINCH_READY, XRT_INPUT_HAND_PINCH_READY}, + {XRT_INPUT_HAND_POKE_POSE, XRT_INPUT_HAND_POKE_POSE}, + {XRT_INPUT_HAND_AIM_ACTIVATE_READY, XRT_INPUT_HAND_AIM_ACTIVATE_READY}, + {XRT_INPUT_HAND_AIM_ACTIVATE_VALUE, XRT_INPUT_HAND_AIM_ACTIVATE_VALUE}, + {XRT_INPUT_HAND_GRASP_VALUE, XRT_INPUT_HAND_GRASP_VALUE}, + {XRT_INPUT_HAND_GRASP_READY, XRT_INPUT_HAND_GRASP_READY}, +}; + static xrt_binding_input_pair index_input_binding[] = { {XRT_INPUT_INDEX_SYSTEM_CLICK, XRT_INPUT_TOUCH_SYSTEM_CLICK}, {XRT_INPUT_INDEX_SYSTEM_TOUCH, XRT_INPUT_INDEX_SYSTEM_TOUCH}, @@ -429,6 +483,13 @@ static xrt_binding_profile wivrn_binding_profiles[] = { .outputs = simple_output_binding, .output_count = std::size(simple_output_binding), }, + { + .name = XRT_DEVICE_EXT_HAND_INTERACTION, + .inputs = hand_interaction_input_binding, + .input_count = std::size(hand_interaction_input_binding), + .outputs = nullptr, + .output_count = 0, + }, { .name = XRT_DEVICE_INDEX_CONTROLLER, .inputs = index_input_binding, @@ -555,6 +616,8 @@ wivrn_controller::wivrn_controller(int hand_id, aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM), palm(hand_id == 0 ? device_id::LEFT_PALM : device_id::RIGHT_PALM), joints(hand_id), + pinch_ext(hand_id == 0 ? device_id::LEFT_PINCH_POSE : device_id::RIGHT_PINCH_POSE), + poke_ext(hand_id == 0 ? device_id::LEFT_POKE : device_id::RIGHT_POKE), inputs_array(input_count, xrt_input{}), cnx(cnx) { @@ -607,6 +670,14 @@ wivrn_controller::wivrn_controller(int hand_id, SET_INPUT(TOUCH, A_TOUCH); SET_INPUT(TOUCH, B_TOUCH); } + SET_INPUT(HAND, PINCH_POSE); + SET_INPUT(HAND, PINCH_VALUE); + SET_INPUT(HAND, PINCH_READY); + SET_INPUT(HAND, POKE_POSE); + SET_INPUT(HAND, AIM_ACTIVATE_VALUE); + SET_INPUT(HAND, AIM_ACTIVATE_READY); + SET_INPUT(HAND, GRASP_VALUE); + SET_INPUT(HAND, GRASP_READY); SET_INPUT(VIVE_FOCUS3, SQUEEZE_CLICK); SET_INPUT(INDEX, SQUEEZE_FORCE); SET_INPUT(TOUCH, SQUEEZE_VALUE); @@ -740,6 +811,14 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_ std::tie(extrapolation_time, *res, device) = palm.get_pose_at(at_timestamp_ns); cnx->set_enabled(device, true); break; + case XRT_INPUT_HAND_PINCH_POSE: + std::tie(extrapolation_time, *res, device) = pinch_ext.get_pose_at(at_timestamp_ns); + cnx->set_enabled(device, true); + break; + case XRT_INPUT_HAND_POKE_POSE: + std::tie(extrapolation_time, *res, device) = poke_ext.get_pose_at(at_timestamp_ns); + cnx->set_enabled(device, true); + break; default: U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name); return XRT_ERROR_INPUT_UNSUPPORTED; @@ -754,6 +833,8 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_ case XRT_INPUT_TOUCH_AIM_POSE: return aim.device; case XRT_INPUT_TOUCH_GRIP_POSE: return grip.device; case XRT_INPUT_GENERIC_PALM_POSE: return palm.device; + case XRT_INPUT_HAND_PINCH_POSE: return pinch_ext.device; + case XRT_INPUT_HAND_POKE_POSE: return poke_ext.device; default: assert(false); __builtin_unreachable(); @@ -817,6 +898,10 @@ void wivrn_controller::update_tracking(const from_headset::tracking & tracking, cnx->set_enabled(grip.device, false); if (not palm.update_tracking(tracking, offset)) cnx->set_enabled(palm.device, false); + if (not pinch_ext.update_tracking(tracking, offset)) + cnx->set_enabled(pinch_ext.device, false); + if (not poke_ext.update_tracking(tracking, offset)) + cnx->set_enabled(poke_ext.device, false); if (auto & out = tracking_dump(); out and offset) { std::lock_guard lock{tracking_dump_mutex}; diff --git a/server/driver/wivrn_controller.h b/server/driver/wivrn_controller.h index b88a1240..f66214af 100644 --- a/server/driver/wivrn_controller.h +++ b/server/driver/wivrn_controller.h @@ -39,6 +39,9 @@ class wivrn_controller : public xrt_device pose_list aim; pose_list palm; hand_joints_list joints; + // hand_interaction + pose_list pinch_ext; + pose_list poke_ext; std::vector inputs_staging; std::vector inputs_array; diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 8e429d4c..3429b555 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -362,6 +362,8 @@ static xrt_device_name get_name(interaction_profile profile) return XRT_DEVICE_INVALID; case interaction_profile::khr_simple_controller: return XRT_DEVICE_SIMPLE_CONTROLLER; + case interaction_profile::ext_hand_interaction_ext: + return XRT_DEVICE_EXT_HAND_INTERACTION; case interaction_profile::bytedance_pico_neo3_controller: return XRT_DEVICE_PICO_NEO3_CONTROLLER; case interaction_profile::bytedance_pico4_controller: @@ -504,12 +506,20 @@ static auto to_tracking_control(device_id id) return tid::left_grip; case device_id::LEFT_PALM: return tid::left_palm; + case device_id::LEFT_PINCH_POSE: + return tid::left_pinch; + case device_id::LEFT_POKE: + return tid::left_poke; case device_id::RIGHT_AIM: return tid::right_aim; case device_id::RIGHT_GRIP: return tid::right_grip; case device_id::RIGHT_PALM: return tid::right_palm; + case device_id::RIGHT_PINCH_POSE: + return tid::right_pinch; + case device_id::RIGHT_POKE: + return tid::right_poke; default: break; }