diff --git a/client/application.cpp b/client/application.cpp index 555d3a9e..7c713537 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -627,6 +627,15 @@ void application::initialize_actions() if (!profile.available) continue; + // Patch profile to add palm_ext + 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/palm_ext/pose")) + { + profile.input_sources.push_back("/user/hand/left/palm_ext/pose"); + profile.input_sources.push_back("/user/hand/right/palm_ext/pose"); + } + suggested_bindings.emplace(profile.profile_name, std::vector{}); for (const std::string & source: profile.input_sources) @@ -659,6 +668,10 @@ void application::initialize_actions() spaces[size_t(xr::spaces::aim_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 == "/user/hand/right/palm_ext/pose") + spaces[size_t(xr::spaces::palm_right)] = xr_session.create_action_space(a); + else if (name == "/user/hand/left/palm_ext/pose") + spaces[size_t(xr::spaces::palm_left)] = xr_session.create_action_space(a); } // Build an action set for each scene @@ -742,6 +755,7 @@ void application::initialize() opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME); opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME); opt_extensions.push_back(XR_FB_FACE_TRACKING2_EXTENSION_NAME); + opt_extensions.push_back(XR_EXT_PALM_POSE_EXTENSION_NAME); for (const auto & i: interaction_profiles) { diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index 1c80373b..eca8267f 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -126,6 +126,7 @@ std::shared_ptr scenes::stream::create(std::unique_ptr supported_codecs; // from preferred to least preferred }; @@ -373,8 +376,10 @@ struct tracking_control { left_aim, left_grip, + left_palm, right_aim, right_grip, + right_palm, left_hand, right_hand, face, diff --git a/server/driver/wivrn_controller.cpp b/server/driver/wivrn_controller.cpp index 2060bd37..a7822815 100644 --- a/server/driver/wivrn_controller.cpp +++ b/server/driver/wivrn_controller.cpp @@ -33,6 +33,7 @@ enum wivrn_controller_input_index WIVRN_CONTROLLER_AIM_POSE, WIVRN_CONTROLLER_GRIP_POSE, WIVRN_CONTROLLER_HAND_TRACKER, + WIVRN_CONTROLLER_PALM_POSE, WIVRN_CONTROLLER_MENU_CLICK, // /user/hand/left/input/menu/click WIVRN_CONTROLLER_A_CLICK, // /user/hand/right/input/a/click @@ -152,6 +153,7 @@ wivrn_controller::wivrn_controller(int hand_id, xrt_device{}, grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP), 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), cnx(cnx) { @@ -172,7 +174,7 @@ wivrn_controller::wivrn_controller(int hand_id, inputs_array.resize(WIVRN_CONTROLLER_INPUT_COUNT); inputs = inputs_array.data(); - input_count = WIVRN_CONTROLLER_INPUT_COUNT; + input_count = inputs_array.size(); // Setup input. #define SET_INPUT(NAME) \ @@ -210,6 +212,9 @@ wivrn_controller::wivrn_controller(int hand_id, inputs[WIVRN_CONTROLLER_HAND_TRACKER].name = hand_id == 0 ? XRT_INPUT_GENERIC_HAND_TRACKING_LEFT : XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT; inputs[WIVRN_CONTROLLER_HAND_TRACKER].active = true; + inputs[WIVRN_CONTROLLER_PALM_POSE].name = XRT_INPUT_GENERIC_PALM_POSE; + inputs[WIVRN_CONTROLLER_PALM_POSE].active = cnx->get_info().palm_pose; + output_count = 1; outputs = &haptic_output; haptic_output.name = XRT_OUTPUT_NAME_TOUCH_HAPTIC; @@ -319,6 +324,10 @@ xrt_space_relation wivrn_controller::get_tracked_pose(xrt_input_name name, int64 std::tie(extrapolation_time, res) = grip.get_at(at_timestamp_ns); cnx->set_enabled(grip.device, true); break; + case XRT_INPUT_GENERIC_PALM_POSE: + std::tie(extrapolation_time, res) = palm.get_at(at_timestamp_ns); + cnx->set_enabled(palm.device, true); + break; default: U_LOG_W("Unknown input name requested"); return {}; diff --git a/server/driver/wivrn_controller.h b/server/driver/wivrn_controller.h index 3d9b6c75..3d9c8980 100644 --- a/server/driver/wivrn_controller.h +++ b/server/driver/wivrn_controller.h @@ -37,6 +37,7 @@ class wivrn_controller : public xrt_device pose_list grip; pose_list aim; + pose_list palm; hand_joints_list joints; std::vector inputs_staging; diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 6e0b29f3..cc375030 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -373,10 +373,14 @@ static auto to_tracking_control(device_id id) return tid::left_aim; case device_id::LEFT_GRIP: return tid::left_grip; + case device_id::LEFT_PALM: + return tid::left_palm; 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; default: break; }