Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+2
-2
@@ -239,9 +239,9 @@ endif()
|
|||||||
|
|
||||||
if (WIVRN_BUILD_DISSECTOR)
|
if (WIVRN_BUILD_DISSECTOR)
|
||||||
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
|
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
|
||||||
find_package(OpenXR 1.0.34)
|
find_package(OpenXR 1.1.48)
|
||||||
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
||||||
find_package(OpenXR 1.0.34 REQUIRED)
|
find_package(OpenXR 1.1.48 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
find_package(Wireshark REQUIRED)
|
find_package(Wireshark REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
+73
-10
@@ -517,6 +517,35 @@ static std::vector<interaction_profile> interaction_profiles{
|
|||||||
"/user/hand/right/input/thumbrest/touch",
|
"/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{
|
interaction_profile{
|
||||||
.profile_name = "/interaction_profiles/htc/vive_xr_tracker",
|
.profile_name = "/interaction_profiles/htc/vive_xr_tracker",
|
||||||
.required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
|
.required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
|
||||||
@@ -556,6 +585,9 @@ static const std::pair<std::string_view, XrActionType> action_suffixes[] =
|
|||||||
{"/joystick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
{"/joystick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
{"/trackball", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
{"/trackball", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
|
|
||||||
|
// XR_EXT_hand_interaction
|
||||||
|
{"/ready_ext", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
|
||||||
// Output paths
|
// Output paths
|
||||||
{"/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
{"/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
{"/haptic_trigger", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
{"/haptic_trigger", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
@@ -949,19 +981,41 @@ void application::initialize_actions()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Patch profile to add grip_surface or palm_ext
|
// 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)) //
|
bool add_palms = true;
|
||||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
if (profile.profile_name.ends_with("ext/hand_interaction_ext"))
|
||||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose"))
|
|
||||||
{
|
{
|
||||||
profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose");
|
switch (guess_model())
|
||||||
profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose");
|
{
|
||||||
|
// 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) //
|
if (add_palms)
|
||||||
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"))
|
|
||||||
{
|
{
|
||||||
profile.input_sources.push_back("/user/hand/left/input/palm_ext/pose");
|
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
|
||||||
profile.input_sources.push_back("/user/hand/right/input/palm_ext/pose");
|
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
|
// 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);
|
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")
|
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);
|
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")
|
else if (name == "/user/hand/right/input/grip/pose")
|
||||||
spaces[size_t(xr::spaces::grip_right)] = xr_session.create_action_space(a);
|
spaces[size_t(xr::spaces::grip_right)] = xr_session.create_action_space(a);
|
||||||
else if (name == "/user/hand/right/input/aim/pose")
|
else if (name == "/user/hand/right/input/aim/pose")
|
||||||
spaces[size_t(xr::spaces::aim_right)] = xr_session.create_action_space(a);
|
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")
|
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);
|
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")
|
else if (name == "/user/eyes_ext/input/gaze_ext/pose")
|
||||||
spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a);
|
spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a);
|
||||||
else if (name.contains("/input/entity_htc/pose") && htc_body)
|
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_KHR_MAINTENANCE1_EXTENSION_NAME);
|
||||||
opt_extensions.push_back(XR_FB_DISPLAY_REFRESH_RATE_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_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_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
|
||||||
opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
|
opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
|
||||||
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
|
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
|
||||||
|
|||||||
@@ -117,6 +117,21 @@ static const std::unordered_map<std::string, device_id> device_ids = {
|
|||||||
{"/user/hand/right/input/trackpad/force", device_id::RIGHT_TRACKPAD_FORCE},
|
{"/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/force", device_id::RIGHT_STYLUS_FORCE},
|
||||||
{"/user/hand/right/input/stylus_fb/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
|
// clang-format on
|
||||||
|
|
||||||
|
|||||||
@@ -234,31 +234,6 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool enabled(const to_headset::tracking_control & control, device_id id)
|
|
||||||
{
|
|
||||||
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::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)];
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
__builtin_unreachable();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T & from_pool(std::vector<T> & container, std::vector<T> & pool)
|
static T & from_pool(std::vector<T> & container, std::vector<T> & pool)
|
||||||
{
|
{
|
||||||
@@ -283,12 +258,20 @@ static xr::spaces device_to_space(device_id id)
|
|||||||
return xr::spaces::grip_left;
|
return xr::spaces::grip_left;
|
||||||
case device_id::LEFT_PALM:
|
case device_id::LEFT_PALM:
|
||||||
return xr::spaces::palm_left;
|
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:
|
case device_id::RIGHT_AIM:
|
||||||
return xr::spaces::aim_right;
|
return xr::spaces::aim_right;
|
||||||
case device_id::RIGHT_GRIP:
|
case device_id::RIGHT_GRIP:
|
||||||
return xr::spaces::grip_right;
|
return xr::spaces::grip_right;
|
||||||
case device_id::RIGHT_PALM:
|
case device_id::RIGHT_PALM:
|
||||||
return xr::spaces::palm_right;
|
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:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
@@ -306,20 +289,66 @@ void scenes::stream::tracking()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::pair<device_id, XrSpace>> spaces;
|
std::vector<std::pair<device_id, XrSpace>> 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)))
|
std::vector ids{
|
||||||
spaces.emplace_back(id, space);
|
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 = [](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)];
|
||||||
|
}
|
||||||
|
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)];
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
throw std::runtime_error("enabled called on unhandled device " + std::string(magic_enum::enum_name(id)));
|
||||||
|
};
|
||||||
|
|
||||||
const auto & config = application::get_config();
|
const auto & config = application::get_config();
|
||||||
|
|
||||||
if (config.check_feature(feature::eye_gaze))
|
if (config.check_feature(feature::eye_gaze))
|
||||||
@@ -623,6 +652,55 @@ static device_id derived_from(device_id target)
|
|||||||
|
|
||||||
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
||||||
{
|
{
|
||||||
|
std::array path = {
|
||||||
|
"/user/hand/left",
|
||||||
|
"/user/hand/right",
|
||||||
|
};
|
||||||
|
#define DO_PROFILE(vendor, name) \
|
||||||
|
if (profile == "/interaction_profiles/" #vendor "/" #name) \
|
||||||
|
{ \
|
||||||
|
interaction_profiles[i] = interaction_profile::vendor##_##name; \
|
||||||
|
continue; \
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
DO_PROFILE(bytedance, pico_g3_controller)
|
||||||
|
DO_PROFILE(google, daydream_controller)
|
||||||
|
DO_PROFILE(hp, mixed_reality_controller)
|
||||||
|
DO_PROFILE(htc, vive_controller)
|
||||||
|
DO_PROFILE(htc, vive_cosmos_controller)
|
||||||
|
DO_PROFILE(htc, vive_focus3_controller)
|
||||||
|
DO_PROFILE(htc, vive_pro)
|
||||||
|
DO_PROFILE(ml, ml2_controller)
|
||||||
|
DO_PROFILE(microsoft, motion_controller)
|
||||||
|
DO_PROFILE(microsoft, xbox_controller)
|
||||||
|
DO_PROFILE(oculus, go_controller)
|
||||||
|
DO_PROFILE(oculus, touch_controller)
|
||||||
|
DO_PROFILE(meta, touch_pro_controller)
|
||||||
|
DO_PROFILE(meta, touch_plus_controller)
|
||||||
|
DO_PROFILE(meta, touch_controller_rift_cv1)
|
||||||
|
DO_PROFILE(meta, touch_controller_quest_1_rift_s)
|
||||||
|
DO_PROFILE(meta, touch_controller_quest_2)
|
||||||
|
DO_PROFILE(samsung, odyssey_controller)
|
||||||
|
DO_PROFILE(valve, index_controller)
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
spdlog::warn("Failed to get current interaction profile: {}", e.what());
|
||||||
|
}
|
||||||
|
interaction_profiles[i] = interaction_profile::none;
|
||||||
|
}
|
||||||
|
|
||||||
auto now = instance.now();
|
auto now = instance.now();
|
||||||
for (device_id target: {
|
for (device_id target: {
|
||||||
device_id::LEFT_AIM,
|
device_id::LEFT_AIM,
|
||||||
@@ -631,6 +709,17 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
|
|||||||
device_id::RIGHT_PALM,
|
device_id::RIGHT_PALM,
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
// don't do derived poses for hand interaction
|
||||||
|
const bool right = target >= device_id::RIGHT_GRIP && target <= device_id::RIGHT_PALM;
|
||||||
|
if (interaction_profiles[right].load() == interaction_profile::ext_hand_interaction_ext)
|
||||||
|
{
|
||||||
|
network_session->send_control(from_headset::derived_pose{
|
||||||
|
.source = target,
|
||||||
|
.target = target,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto source = derived_from(target);
|
auto source = derived_from(target);
|
||||||
auto source_space = application::space(device_to_space(source));
|
auto source_space = application::space(device_to_space(source));
|
||||||
auto target_space = application::space(device_to_space(target));
|
auto target_space = application::space(device_to_space(target));
|
||||||
@@ -693,52 +782,4 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array path = {
|
|
||||||
"/user/hand/left",
|
|
||||||
"/user/hand/right",
|
|
||||||
};
|
|
||||||
#define DO_PROFILE(vendor, name) \
|
|
||||||
if (profile == "/interaction_profiles/" #vendor "/" #name) \
|
|
||||||
{ \
|
|
||||||
interaction_profiles[i] = interaction_profile::vendor##_##name; \
|
|
||||||
continue; \
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 2; ++i)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
auto profile = session.get_current_interaction_profile(path[i]);
|
|
||||||
spdlog::info("interaction profile for {}: {}", path[i], profile);
|
|
||||||
DO_PROFILE(khr, simple_controller)
|
|
||||||
DO_PROFILE(bytedance, pico_neo3_controller)
|
|
||||||
DO_PROFILE(bytedance, pico4_controller)
|
|
||||||
DO_PROFILE(bytedance, pico4s_controller)
|
|
||||||
DO_PROFILE(bytedance, pico_g3_controller)
|
|
||||||
DO_PROFILE(google, daydream_controller)
|
|
||||||
DO_PROFILE(hp, mixed_reality_controller)
|
|
||||||
DO_PROFILE(htc, vive_controller)
|
|
||||||
DO_PROFILE(htc, vive_cosmos_controller)
|
|
||||||
DO_PROFILE(htc, vive_focus3_controller)
|
|
||||||
DO_PROFILE(htc, vive_pro)
|
|
||||||
DO_PROFILE(ml, ml2_controller)
|
|
||||||
DO_PROFILE(microsoft, motion_controller)
|
|
||||||
DO_PROFILE(microsoft, xbox_controller)
|
|
||||||
DO_PROFILE(oculus, go_controller)
|
|
||||||
DO_PROFILE(oculus, touch_controller)
|
|
||||||
DO_PROFILE(meta, touch_pro_controller)
|
|
||||||
DO_PROFILE(meta, touch_plus_controller)
|
|
||||||
DO_PROFILE(meta, touch_controller_rift_cv1)
|
|
||||||
DO_PROFILE(meta, touch_controller_quest_1_rift_s)
|
|
||||||
DO_PROFILE(meta, touch_controller_quest_2)
|
|
||||||
DO_PROFILE(samsung, odyssey_controller)
|
|
||||||
DO_PROFILE(valve, index_controller)
|
|
||||||
}
|
|
||||||
catch (std::exception & e)
|
|
||||||
{
|
|
||||||
spdlog::warn("Failed to get current interation profile: {}", e.what());
|
|
||||||
}
|
|
||||||
interaction_profiles[i] = interaction_profile::none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ enum class spaces
|
|||||||
aim_right,
|
aim_right,
|
||||||
palm_left,
|
palm_left,
|
||||||
palm_right,
|
palm_right,
|
||||||
|
// hand_interaction_ext
|
||||||
|
pinch_left,
|
||||||
|
pinch_right,
|
||||||
|
poke_left,
|
||||||
|
poke_right,
|
||||||
|
|
||||||
count
|
count
|
||||||
};
|
};
|
||||||
|
|||||||
+91
-70
@@ -45,82 +45,99 @@ static constexpr int protocol_revision = 1;
|
|||||||
|
|
||||||
enum class device_id : uint8_t
|
enum class device_id : uint8_t
|
||||||
{
|
{
|
||||||
HEAD, // /user/head
|
HEAD, // /user/head
|
||||||
LEFT_CONTROLLER_HAPTIC, // /user/hand/left/output/haptic
|
LEFT_CONTROLLER_HAPTIC, // /user/hand/left/output/haptic
|
||||||
RIGHT_CONTROLLER_HAPTIC, // /user/hand/right/output/haptic
|
RIGHT_CONTROLLER_HAPTIC, // /user/hand/right/output/haptic
|
||||||
LEFT_TRIGGER_HAPTIC, // /user/hand/left/output/haptic_trigger
|
LEFT_TRIGGER_HAPTIC, // /user/hand/left/output/haptic_trigger
|
||||||
RIGHT_TRIGGER_HAPTIC, // /user/hand/right/output/haptic_trigger
|
RIGHT_TRIGGER_HAPTIC, // /user/hand/right/output/haptic_trigger
|
||||||
LEFT_THUMB_HAPTIC, // /user/hand/left/output/haptic_thumb
|
LEFT_THUMB_HAPTIC, // /user/hand/left/output/haptic_thumb
|
||||||
RIGHT_THUMB_HAPTIC, // /user/hand/right/output/haptic_thumb
|
RIGHT_THUMB_HAPTIC, // /user/hand/right/output/haptic_thumb
|
||||||
LEFT_GRIP, // /user/hand/left/input/grip/pose
|
LEFT_GRIP, // /user/hand/left/input/grip/pose
|
||||||
LEFT_AIM, // /user/hand/left/input/aim/pose
|
LEFT_AIM, // /user/hand/left/input/aim/pose
|
||||||
LEFT_PALM, // /user/hand/left/palm_ext/pose
|
LEFT_PALM, // /user/hand/left/palm_ext/pose
|
||||||
RIGHT_GRIP, // /user/hand/right/input/grip/pose
|
RIGHT_GRIP, // /user/hand/right/input/grip/pose
|
||||||
RIGHT_AIM, // /user/hand/right/input/aim/pose
|
RIGHT_AIM, // /user/hand/right/input/aim/pose
|
||||||
RIGHT_PALM, // /user/hand/right/palm_ext/pose
|
RIGHT_PALM, // /user/hand/right/palm_ext/pose
|
||||||
X_CLICK, // /user/hand/left/input/x/click
|
X_CLICK, // /user/hand/left/input/x/click
|
||||||
X_TOUCH, // /user/hand/left/input/x/touch
|
X_TOUCH, // /user/hand/left/input/x/touch
|
||||||
Y_CLICK, // /user/hand/left/input/y/click
|
Y_CLICK, // /user/hand/left/input/y/click
|
||||||
Y_TOUCH, // /user/hand/left/input/y/touch
|
Y_TOUCH, // /user/hand/left/input/y/touch
|
||||||
MENU_CLICK, // /user/hand/left/input/menu/click
|
MENU_CLICK, // /user/hand/left/input/menu/click
|
||||||
LEFT_SQUEEZE_CLICK, // /user/hand/left/input/squeeze/click
|
LEFT_SQUEEZE_CLICK, // /user/hand/left/input/squeeze/click
|
||||||
LEFT_SQUEEZE_FORCE, // /user/hand/left/input/squeeze/force
|
LEFT_SQUEEZE_FORCE, // /user/hand/left/input/squeeze/force
|
||||||
LEFT_SQUEEZE_VALUE, // /user/hand/left/input/squeeze/value
|
LEFT_SQUEEZE_VALUE, // /user/hand/left/input/squeeze/value
|
||||||
LEFT_TRIGGER_CLICK, // /user/hand/left/input/trigger/click
|
LEFT_TRIGGER_CLICK, // /user/hand/left/input/trigger/click
|
||||||
LEFT_TRIGGER_VALUE, // /user/hand/left/input/trigger/value
|
LEFT_TRIGGER_VALUE, // /user/hand/left/input/trigger/value
|
||||||
LEFT_TRIGGER_TOUCH, // /user/hand/left/input/trigger/touch
|
LEFT_TRIGGER_TOUCH, // /user/hand/left/input/trigger/touch
|
||||||
LEFT_TRIGGER_PROXIMITY, // /user/hand/left/input/trigger/proximity
|
LEFT_TRIGGER_PROXIMITY, // /user/hand/left/input/trigger/proximity
|
||||||
LEFT_TRIGGER_CURL, // /user/hand/left/input/trigger/curl_fb
|
LEFT_TRIGGER_CURL, // /user/hand/left/input/trigger/curl_fb
|
||||||
LEFT_TRIGGER_SLIDE, // /user/hand/left/input/trigger/slide_fb
|
LEFT_TRIGGER_SLIDE, // /user/hand/left/input/trigger/slide_fb
|
||||||
LEFT_TRIGGER_FORCE, // /user/hand/left/input/trigger/force
|
LEFT_TRIGGER_FORCE, // /user/hand/left/input/trigger/force
|
||||||
LEFT_THUMBSTICK_X, // /user/hand/left/input/thumbstick/x
|
LEFT_THUMBSTICK_X, // /user/hand/left/input/thumbstick/x
|
||||||
LEFT_THUMBSTICK_Y, // /user/hand/left/input/thumbstick/y
|
LEFT_THUMBSTICK_Y, // /user/hand/left/input/thumbstick/y
|
||||||
LEFT_THUMBSTICK_CLICK, // /user/hand/left/input/thumbstick/click
|
LEFT_THUMBSTICK_CLICK, // /user/hand/left/input/thumbstick/click
|
||||||
LEFT_THUMBSTICK_TOUCH, // /user/hand/left/input/thumbstick/touch
|
LEFT_THUMBSTICK_TOUCH, // /user/hand/left/input/thumbstick/touch
|
||||||
LEFT_THUMBREST_TOUCH, // /user/hand/left/input/thumbrest/touch
|
LEFT_THUMBREST_TOUCH, // /user/hand/left/input/thumbrest/touch
|
||||||
LEFT_THUMBREST_FORCE, // /user/hand/left/input/thumbrest/force
|
LEFT_THUMBREST_FORCE, // /user/hand/left/input/thumbrest/force
|
||||||
LEFT_THUMB_PROXIMITY, // /user/hand/left/input/thumb_resting_surfaces/proximity
|
LEFT_THUMB_PROXIMITY, // /user/hand/left/input/thumb_resting_surfaces/proximity
|
||||||
LEFT_TRACKPAD_X, // /user/hand/left/input/trackpad/x
|
LEFT_TRACKPAD_X, // /user/hand/left/input/trackpad/x
|
||||||
LEFT_TRACKPAD_Y, // /user/hand/left/input/trackpad/y
|
LEFT_TRACKPAD_Y, // /user/hand/left/input/trackpad/y
|
||||||
LEFT_TRACKPAD_CLICK, // /user/hand/left/input/trackpad/click
|
LEFT_TRACKPAD_CLICK, // /user/hand/left/input/trackpad/click
|
||||||
LEFT_TRACKPAD_TOUCH, // /user/hand/left/input/trackpad/touch
|
LEFT_TRACKPAD_TOUCH, // /user/hand/left/input/trackpad/touch
|
||||||
LEFT_TRACKPAD_FORCE, // /user/hand/left/input/trackpad/force
|
LEFT_TRACKPAD_FORCE, // /user/hand/left/input/trackpad/force
|
||||||
LEFT_STYLUS_FORCE, // /user/hand/left/input/stylus_fb/force
|
LEFT_STYLUS_FORCE, // /user/hand/left/input/stylus_fb/force
|
||||||
A_CLICK, // /user/hand/right/input/a/click
|
LEFT_PINCH_POSE, // /user/hand/left/input/pinch_ext/pose
|
||||||
A_TOUCH, // /user/hand/right/input/a/touch
|
LEFT_PINCH_VALUE, // /user/hand/left/input/pinch_ext/value
|
||||||
B_CLICK, // /user/hand/right/input/b/click
|
LEFT_PINCH_READY, // /user/hand/left/input/pinch_ext/ready_ext
|
||||||
B_TOUCH, // /user/hand/right/input/b/touch
|
LEFT_POKE, // /user/hand/left/input/poke_ext/pose
|
||||||
SYSTEM_CLICK, // /user/hand/right/input/system/click
|
LEFT_AIM_ACTIVATE_VALUE, // /user/hand/left/input/aim_activate_ext/value
|
||||||
RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click
|
LEFT_AIM_ACTIVATE_READY, // /user/hand/left/input/aim_activate_ext/ready_ext
|
||||||
RIGHT_SQUEEZE_FORCE, // /user/hand/right/input/squeeze/force
|
LEFT_GRASP_VALUE, // /user/hand/left/input/grasp_ext/value
|
||||||
RIGHT_SQUEEZE_VALUE, // /user/hand/right/input/squeeze/value
|
LEFT_GRASP_READY, // /user/hand/left/input/grasp_ext/ready_ext
|
||||||
RIGHT_TRIGGER_CLICK, // /user/hand/right/input/trigger/click
|
A_CLICK, // /user/hand/right/input/a/click
|
||||||
RIGHT_TRIGGER_VALUE, // /user/hand/right/input/trigger/value
|
A_TOUCH, // /user/hand/right/input/a/touch
|
||||||
RIGHT_TRIGGER_TOUCH, // /user/hand/right/input/trigger/touch
|
B_CLICK, // /user/hand/right/input/b/click
|
||||||
RIGHT_TRIGGER_PROXIMITY, // /user/hand/right/input/trigger/proximity
|
B_TOUCH, // /user/hand/right/input/b/touch
|
||||||
RIGHT_TRIGGER_CURL, // /user/hand/right/input/trigger/curl_fb
|
SYSTEM_CLICK, // /user/hand/right/input/system/click
|
||||||
RIGHT_TRIGGER_SLIDE, // /user/hand/right/input/trigger/slide_fb
|
RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click
|
||||||
RIGHT_TRIGGER_FORCE, // /user/hand/right/input/trigger/force
|
RIGHT_SQUEEZE_FORCE, // /user/hand/right/input/squeeze/force
|
||||||
RIGHT_THUMBSTICK_X, // /user/hand/right/input/thumbstick/x
|
RIGHT_SQUEEZE_VALUE, // /user/hand/right/input/squeeze/value
|
||||||
RIGHT_THUMBSTICK_Y, // /user/hand/right/input/thumbstick/y
|
RIGHT_TRIGGER_CLICK, // /user/hand/right/input/trigger/click
|
||||||
RIGHT_THUMBSTICK_CLICK, // /user/hand/right/input/thumbstick/click
|
RIGHT_TRIGGER_VALUE, // /user/hand/right/input/trigger/value
|
||||||
RIGHT_THUMBSTICK_TOUCH, // /user/hand/right/input/thumbstick/touch
|
RIGHT_TRIGGER_TOUCH, // /user/hand/right/input/trigger/touch
|
||||||
RIGHT_THUMBREST_TOUCH, // /user/hand/right/input/thumbrest/touch
|
RIGHT_TRIGGER_PROXIMITY, // /user/hand/right/input/trigger/proximity
|
||||||
RIGHT_THUMBREST_FORCE, // /user/hand/right/input/thumbrest/force
|
RIGHT_TRIGGER_CURL, // /user/hand/right/input/trigger/curl_fb
|
||||||
RIGHT_THUMB_PROXIMITY, // /user/hand/right/input/thumb_resting_surfaces/proximity
|
RIGHT_TRIGGER_SLIDE, // /user/hand/right/input/trigger/slide_fb
|
||||||
RIGHT_TRACKPAD_X, // /user/hand/right/input/trackpad/x
|
RIGHT_TRIGGER_FORCE, // /user/hand/right/input/trigger/force
|
||||||
RIGHT_TRACKPAD_Y, // /user/hand/right/input/trackpad/y
|
RIGHT_THUMBSTICK_X, // /user/hand/right/input/thumbstick/x
|
||||||
RIGHT_TRACKPAD_CLICK, // /user/hand/right/input/trackpad/click
|
RIGHT_THUMBSTICK_Y, // /user/hand/right/input/thumbstick/y
|
||||||
RIGHT_TRACKPAD_TOUCH, // /user/hand/right/input/trackpad/touch
|
RIGHT_THUMBSTICK_CLICK, // /user/hand/right/input/thumbstick/click
|
||||||
RIGHT_TRACKPAD_FORCE, // /user/hand/right/input/trackpad/force
|
RIGHT_THUMBSTICK_TOUCH, // /user/hand/right/input/thumbstick/touch
|
||||||
RIGHT_STYLUS_FORCE, // /user/hand/right/input/stylus_fb/force
|
RIGHT_THUMBREST_TOUCH, // /user/hand/right/input/thumbrest/touch
|
||||||
EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose
|
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
|
enum class interaction_profile : uint8_t
|
||||||
{
|
{
|
||||||
none,
|
none,
|
||||||
khr_simple_controller,
|
khr_simple_controller,
|
||||||
|
ext_hand_interaction_ext,
|
||||||
bytedance_pico_neo3_controller,
|
bytedance_pico_neo3_controller,
|
||||||
bytedance_pico4_controller,
|
bytedance_pico4_controller,
|
||||||
bytedance_pico4s_controller,
|
bytedance_pico4s_controller,
|
||||||
@@ -600,9 +617,13 @@ struct tracking_control
|
|||||||
left_aim,
|
left_aim,
|
||||||
left_grip,
|
left_grip,
|
||||||
left_palm,
|
left_palm,
|
||||||
|
left_pinch,
|
||||||
|
left_poke,
|
||||||
right_aim,
|
right_aim,
|
||||||
right_grip,
|
right_grip,
|
||||||
right_palm,
|
right_palm,
|
||||||
|
right_pinch,
|
||||||
|
right_poke,
|
||||||
left_hand,
|
left_hand,
|
||||||
right_hand,
|
right_hand,
|
||||||
face,
|
face,
|
||||||
|
|||||||
Generated
+9
-9
@@ -5,11 +5,11 @@
|
|||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743550720,
|
"lastModified": 1751413152,
|
||||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
"narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
"rev": "77826244401ea9de6e3bac47c2db46005e1f30b5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1747744144,
|
"lastModified": 1751271578,
|
||||||
"narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=",
|
"narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f",
|
"rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743296961,
|
"lastModified": 1751159883,
|
||||||
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
|
"narHash": "sha256-urW/Ylk9FIfvXfliA1ywh75yszAbiTEVgpPeinFyVZo=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs.lib",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
|
"rev": "14a40a1d7fb9afa4739275ac642ed7301a9ba1ab",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -56,7 +56,29 @@
|
|||||||
];
|
];
|
||||||
}));
|
}));
|
||||||
in {
|
in {
|
||||||
packages.default = package;
|
packages = {
|
||||||
|
default = package;
|
||||||
|
dissector = package.overrideAttrs (oldAttrs: {
|
||||||
|
pname = "wivrn-dissector";
|
||||||
|
cmakeFlags = (lib.filter (flag: !(lib.hasPrefix "-DWIVRN_BUILD" flag)) oldAttrs.cmakeFlags) ++ [
|
||||||
|
(lib.cmakeBool "WIVRN_BUILD_CLIENT" false)
|
||||||
|
(lib.cmakeBool "WIVRN_BUILD_SERVER" false)
|
||||||
|
(lib.cmakeBool "WIVRN_BUILD_DASHBOARD" false)
|
||||||
|
(lib.cmakeBool "WIVRN_BUILD_WIVRNCTL" false)
|
||||||
|
(lib.cmakeBool "WIVRN_BUILD_DISSECTOR" true)
|
||||||
|
];
|
||||||
|
buildInputs = oldAttrs.buildInputs ++ [
|
||||||
|
(pkgs.symlinkJoin {
|
||||||
|
name = "wireshark-dev-out-combined";
|
||||||
|
paths = [
|
||||||
|
pkgs.wireshark.out
|
||||||
|
pkgs.wireshark.dev
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
preFixup = null;
|
||||||
|
});
|
||||||
|
};
|
||||||
devShells.default = package.overrideAttrs (oldAttrs: {
|
devShells.default = package.overrideAttrs (oldAttrs: {
|
||||||
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ devTools;
|
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ devTools;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ set(XRT_FEATURE_RENDERDOC ${WIVRN_FEATURE_RENDERDOC})
|
|||||||
set(XRT_FEATURE_OPENXR_FACE_TRACKING2_FB ON)
|
set(XRT_FEATURE_OPENXR_FACE_TRACKING2_FB ON)
|
||||||
set(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC ON)
|
set(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC ON)
|
||||||
set(XRT_FEATURE_OPENXR_HAND_TRACKING_EXT 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_EXT_PALM_POSE ON)
|
||||||
set(XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE ON)
|
set(XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE ON)
|
||||||
set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON)
|
set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON)
|
||||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PRO ON)
|
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PRO ON)
|
||||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PLUS 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_BLUETOOTH OFF)
|
||||||
set(XRT_HAVE_GST OFF)
|
set(XRT_HAVE_GST OFF)
|
||||||
@@ -94,6 +94,7 @@ if (WIVRN_BUILD_SERVER)
|
|||||||
driver/wivrn_pacer.cpp
|
driver/wivrn_pacer.cpp
|
||||||
driver/wivrn_comp_target.cpp
|
driver/wivrn_comp_target.cpp
|
||||||
driver/wivrn_controller.cpp
|
driver/wivrn_controller.cpp
|
||||||
|
driver/wivrn_hand_interaction.cpp
|
||||||
driver/wivrn_eye_tracker.cpp
|
driver/wivrn_eye_tracker.cpp
|
||||||
driver/wivrn_fb_face2_tracker.cpp
|
driver/wivrn_fb_face2_tracker.cpp
|
||||||
driver/wivrn_htc_face_tracker.cpp
|
driver/wivrn_htc_face_tracker.cpp
|
||||||
|
|||||||
@@ -131,5 +131,11 @@ public:
|
|||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
std::lock_guard lock(mutex);
|
||||||
|
data.fill({});
|
||||||
|
last_request = os_monotonic_get_ns();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace wivrn
|
|||||||
|
|
||||||
enum wivrn_controller_input_index
|
enum wivrn_controller_input_index
|
||||||
{
|
{
|
||||||
|
WIVRN_CONTROLLER_INPUT_INVALID = -1,
|
||||||
WIVRN_CONTROLLER_AIM_POSE,
|
WIVRN_CONTROLLER_AIM_POSE,
|
||||||
WIVRN_CONTROLLER_GRIP_POSE,
|
WIVRN_CONTROLLER_GRIP_POSE,
|
||||||
WIVRN_CONTROLLER_PALM_POSE,
|
WIVRN_CONTROLLER_PALM_POSE,
|
||||||
@@ -237,7 +238,13 @@ static input_data map_input(device_id id)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw std::range_error("bad input id " + std::to_string((int)id));
|
// If the headset supports hand_interaction_ext, upon switch
|
||||||
|
// to/from hand tracking we may get the inputs packet before
|
||||||
|
// the interaction profile change, so if we get a bad input
|
||||||
|
// just return an invalid index so we can ignore it
|
||||||
|
U_LOG_D("wivrn_controller: bad input id %s", std::string(magic_enum::enum_name(id)).c_str());
|
||||||
|
// the type here doesn't really matter
|
||||||
|
return {WIVRN_CONTROLLER_INPUT_INVALID, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_UNKNOWN};
|
||||||
}
|
}
|
||||||
|
|
||||||
static xrt_binding_input_pair simple_input_binding[] = {
|
static xrt_binding_input_pair simple_input_binding[] = {
|
||||||
@@ -873,4 +880,11 @@ xrt_result_t wivrn_controller::set_output(xrt_output_name name, const xrt_output
|
|||||||
}
|
}
|
||||||
return XRT_SUCCESS;
|
return XRT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wivrn_controller::reset_history()
|
||||||
|
{
|
||||||
|
grip.reset();
|
||||||
|
aim.reset();
|
||||||
|
palm.reset();
|
||||||
|
}
|
||||||
} // namespace wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -62,5 +62,7 @@ public:
|
|||||||
void set_derived_pose(const from_headset::derived_pose &);
|
void set_derived_pose(const from_headset::derived_pose &);
|
||||||
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||||
void update_hand_tracking(const from_headset::hand_tracking &, const clock_offset &);
|
void update_hand_tracking(const from_headset::hand_tracking &, const clock_offset &);
|
||||||
|
|
||||||
|
void reset_history();
|
||||||
};
|
};
|
||||||
} // namespace wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -0,0 +1,483 @@
|
|||||||
|
/*
|
||||||
|
* WiVRn VR streaming
|
||||||
|
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||||
|
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||||
|
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wivrn_hand_interaction.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
#include "driver/xrt_cast.h"
|
||||||
|
#include "math/m_api.h"
|
||||||
|
#include "utils/method.h"
|
||||||
|
#include "wivrn_session.h"
|
||||||
|
|
||||||
|
#include "util/u_logging.h"
|
||||||
|
#include <array>
|
||||||
|
#include <magic_enum.hpp>
|
||||||
|
#include <numbers>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "xrt/xrt_defines.h"
|
||||||
|
|
||||||
|
namespace wivrn
|
||||||
|
{
|
||||||
|
|
||||||
|
enum wivrn_hand_interaction_input_index
|
||||||
|
{
|
||||||
|
WIVRN_HAND_INTERACTION_INPUT_INVALID = -1,
|
||||||
|
WIVRN_HAND_INTERACTION_AIM_POSE,
|
||||||
|
WIVRN_HAND_INTERACTION_GRIP_POSE,
|
||||||
|
WIVRN_HAND_INTERACTION_PALM_POSE,
|
||||||
|
|
||||||
|
WIVRN_HAND_INTERACTION_PINCH_POSE, // /user/hand/XXXX/input/pinch_ext/pose
|
||||||
|
WIVRN_HAND_INTERACTION_PINCH_VALUE, // /user/hand/XXXX/input/pinch_ext/value
|
||||||
|
WIVRN_HAND_INTERACTION_PINCH_READY, // /user/hand/XXXX/input/pinch_ext/ready_ext
|
||||||
|
WIVRN_HAND_INTERACTION_POKE_POSE, // /user/hand/XXXX/input/poke_ext/pose
|
||||||
|
WIVRN_HAND_INTERACTION_AIM_ACTIVATE_VALUE, // /user/hand/XXXX/input/aim_activate_ext/value
|
||||||
|
WIVRN_HAND_INTERACTION_AIM_ACTIVATE_READY, // /user/hand/XXXX/input/aim_activate_ext/ready_ext
|
||||||
|
WIVRN_HAND_INTERACTION_GRASP_VALUE, // /user/hand/XXXX/input/grasp_ext/value
|
||||||
|
WIVRN_HAND_INTERACTION_GRASP_READY, // /user/hand/XXXX/input/ready_ext/value
|
||||||
|
|
||||||
|
WIVRN_HAND_INTERACTION_INPUT_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class wivrn_input_type
|
||||||
|
{
|
||||||
|
BOOL,
|
||||||
|
FLOAT,
|
||||||
|
VEC2_X,
|
||||||
|
VEC2_Y,
|
||||||
|
POSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct input_data
|
||||||
|
{
|
||||||
|
wivrn_hand_interaction_input_index index;
|
||||||
|
wivrn_input_type type;
|
||||||
|
xrt_device_type device;
|
||||||
|
};
|
||||||
|
|
||||||
|
static input_data map_input(device_id id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case device_id::LEFT_GRIP:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRIP_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_GRIP:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRIP_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_AIM:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_AIM:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_PALM:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PALM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_PALM:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PALM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
// XR_EXT_hand_interaction
|
||||||
|
case device_id::LEFT_PINCH_POSE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_PINCH_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_PINCH_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_PINCH_POSE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_PINCH_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_PINCH_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_PINCH_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_POKE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_POKE_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_POKE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_POKE_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_AIM_ACTIVATE_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_ACTIVATE_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_AIM_ACTIVATE_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_ACTIVATE_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_GRASP_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRASP_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::LEFT_GRASP_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRASP_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_AIM_ACTIVATE_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_ACTIVATE_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_AIM_ACTIVATE_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_AIM_ACTIVATE_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_GRASP_VALUE:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRASP_VALUE, wivrn_input_type::FLOAT, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
case device_id::RIGHT_GRASP_READY:
|
||||||
|
return {WIVRN_HAND_INTERACTION_GRASP_READY, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// If the headset supports hand_interaction_ext, upon switch
|
||||||
|
// to/from hand tracking we may get the inputs packet before
|
||||||
|
// the interaction profile change, so if we get a bad input
|
||||||
|
// just return an invalid index so we can ignore it
|
||||||
|
U_LOG_D("wivrn_hand_interaction: bad input id %s", std::string(magic_enum::enum_name(id)).c_str());
|
||||||
|
// the type here doesn't really matter
|
||||||
|
return {WIVRN_HAND_INTERACTION_INPUT_INVALID, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_UNKNOWN};
|
||||||
|
}
|
||||||
|
|
||||||
|
static xrt_binding_input_pair hand_interaction_input_binding[] = {
|
||||||
|
{XRT_INPUT_HAND_GRIP_POSE, XRT_INPUT_HAND_GRIP_POSE},
|
||||||
|
{XRT_INPUT_HAND_AIM_POSE, XRT_INPUT_HAND_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_profile wivrn_binding_profiles[] = {
|
||||||
|
{
|
||||||
|
.name = XRT_DEVICE_EXT_HAND_INTERACTION,
|
||||||
|
.inputs = hand_interaction_input_binding,
|
||||||
|
.input_count = std::size(hand_interaction_input_binding),
|
||||||
|
.outputs = nullptr,
|
||||||
|
.output_count = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct xrt_space_relation_csv_header
|
||||||
|
{};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation_csv_header &)
|
||||||
|
{
|
||||||
|
for (auto [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
|
||||||
|
{
|
||||||
|
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
|
||||||
|
{
|
||||||
|
name = name.substr(strlen("XRT_SPACE_RELATION_"));
|
||||||
|
name = name.substr(0, name.size() - strlen("_BIT"));
|
||||||
|
out << name << ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "x,y,z,";
|
||||||
|
out << "qw,qx,qy,qz";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation & rel)
|
||||||
|
{
|
||||||
|
const auto & pos = rel.pose.position;
|
||||||
|
const auto & o = rel.pose.orientation;
|
||||||
|
for (const auto & [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
|
||||||
|
{
|
||||||
|
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
|
||||||
|
out << bool(rel.relation_flags & value) << ',';
|
||||||
|
}
|
||||||
|
out << pos.x << ',' << pos.y << ',' << pos.z << ',';
|
||||||
|
out << o.w << ',' << o.x << ',' << o.y << ',' << o.z;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::mutex tracking_dump_mutex;
|
||||||
|
static std::ofstream & tracking_dump()
|
||||||
|
{
|
||||||
|
static auto res = [] {
|
||||||
|
std::ofstream res;
|
||||||
|
if (auto wivrn_dump = std::getenv("WIVRN_DUMP_TRACKING"))
|
||||||
|
{
|
||||||
|
res.open(wivrn_dump);
|
||||||
|
res << "device_id,"
|
||||||
|
"now_ns,"
|
||||||
|
"timestamp_ns,"
|
||||||
|
"extrapolation_ns,"
|
||||||
|
"receive/get,"
|
||||||
|
<< xrt_space_relation_csv_header{} << std::endl;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
wivrn_hand_interaction::wivrn_hand_interaction(int hand_id,
|
||||||
|
xrt_device * hmd,
|
||||||
|
wivrn::wivrn_session * cnx) :
|
||||||
|
xrt_device{
|
||||||
|
.name = XRT_DEVICE_EXT_HAND_INTERACTION,
|
||||||
|
.device_type = hand_id == 0 ? XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER : XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER,
|
||||||
|
.hmd = nullptr,
|
||||||
|
.tracking_origin = hmd->tracking_origin,
|
||||||
|
.binding_profile_count = std::size(wivrn_binding_profiles),
|
||||||
|
.binding_profiles = wivrn_binding_profiles,
|
||||||
|
.input_count = WIVRN_HAND_INTERACTION_INPUT_COUNT,
|
||||||
|
.supported = {
|
||||||
|
.orientation_tracking = true,
|
||||||
|
.position_tracking = true,
|
||||||
|
},
|
||||||
|
.update_inputs = method_pointer<&wivrn_hand_interaction::update_inputs>,
|
||||||
|
.get_tracked_pose = method_pointer<&wivrn_hand_interaction::get_tracked_pose>,
|
||||||
|
.destroy = [](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),
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
inputs = inputs_array.data();
|
||||||
|
|
||||||
|
// Setup input.
|
||||||
|
#define SET_INPUT(VENDOR, NAME) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
inputs[WIVRN_HAND_INTERACTION_##NAME].name = XRT_INPUT_##VENDOR##_##NAME; \
|
||||||
|
inputs[WIVRN_HAND_INTERACTION_##NAME].active = true; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
if (auto grip_surface = configuration().grip_surface)
|
||||||
|
{
|
||||||
|
std::array<float, 3> angles = grip_surface.value();
|
||||||
|
float deg_2_rad = std::numbers::pi / 180.0;
|
||||||
|
xrt_vec3 rotation_angles{angles[0] * deg_2_rad, angles[1] * deg_2_rad, angles[2] * deg_2_rad};
|
||||||
|
xrt_pose offset = XRT_POSE_IDENTITY;
|
||||||
|
math_quat_from_euler_angles(&rotation_angles, &offset.orientation);
|
||||||
|
|
||||||
|
palm.set_derived(&grip, offset, true);
|
||||||
|
cnx->set_enabled(palm.device, false);
|
||||||
|
}
|
||||||
|
else if (not cnx->get_info().palm_pose)
|
||||||
|
{
|
||||||
|
palm.set_derived(&grip, XRT_POSE_IDENTITY, false);
|
||||||
|
cnx->set_enabled(palm.device, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_INPUT(HAND, AIM_POSE);
|
||||||
|
SET_INPUT(HAND, GRIP_POSE);
|
||||||
|
SET_INPUT(GENERIC, PALM_POSE);
|
||||||
|
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);
|
||||||
|
|
||||||
|
#undef SET_INPUT
|
||||||
|
inputs_staging = inputs_array;
|
||||||
|
|
||||||
|
// Make sure everything is mapped
|
||||||
|
for (const auto & item: inputs_array)
|
||||||
|
{
|
||||||
|
assert(item.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
outputs = nullptr;
|
||||||
|
output_count = 0;
|
||||||
|
|
||||||
|
switch (hand_id)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// Print name.
|
||||||
|
strcpy(str, "WiVRn left hand interaction");
|
||||||
|
strcpy(serial, "WiVRn left hand interaction");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// Print name.
|
||||||
|
strcpy(str, "WiVRn right hand interaction");
|
||||||
|
strcpy(serial, "WiVRn right hand interaction");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("Invalid hand ID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xrt_result_t wivrn_hand_interaction::update_inputs()
|
||||||
|
{
|
||||||
|
std::lock_guard _{mutex};
|
||||||
|
inputs_array = inputs_staging;
|
||||||
|
return XRT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wivrn_hand_interaction::set_inputs(const from_headset::inputs & inputs, const clock_offset & clock_offset)
|
||||||
|
{
|
||||||
|
std::lock_guard lock{mutex};
|
||||||
|
for (auto & input: inputs_staging)
|
||||||
|
{
|
||||||
|
switch (XRT_GET_INPUT_TYPE(input.name))
|
||||||
|
{
|
||||||
|
case XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE:
|
||||||
|
case XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE:
|
||||||
|
case XRT_INPUT_TYPE_VEC2_MINUS_ONE_TO_ONE:
|
||||||
|
case XRT_INPUT_TYPE_VEC3_MINUS_ONE_TO_ONE:
|
||||||
|
case XRT_INPUT_TYPE_BOOLEAN:
|
||||||
|
input.active = false;
|
||||||
|
case XRT_INPUT_TYPE_POSE:
|
||||||
|
case XRT_INPUT_TYPE_HAND_TRACKING:
|
||||||
|
case XRT_INPUT_TYPE_FACE_TRACKING:
|
||||||
|
case XRT_INPUT_TYPE_BODY_TRACKING:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto & input: inputs.values)
|
||||||
|
{
|
||||||
|
int64_t last_change_time = input.last_change_time ? clock_offset.from_headset(input.last_change_time) : 0;
|
||||||
|
auto [index, type, device] = map_input(input.id);
|
||||||
|
if (device != device_type)
|
||||||
|
continue;
|
||||||
|
assert(index > 0 and index < input_count);
|
||||||
|
inputs_staging[index].timestamp = last_change_time;
|
||||||
|
inputs_staging[index].active = true;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case wivrn_input_type::BOOL:
|
||||||
|
inputs_staging[index].value.boolean = (input.value != 0);
|
||||||
|
break;
|
||||||
|
case wivrn_input_type::FLOAT:
|
||||||
|
inputs_staging[index].value.vec1.x = input.value;
|
||||||
|
break;
|
||||||
|
case wivrn_input_type::VEC2_X:
|
||||||
|
inputs_staging[index].value.vec2.x = input.value;
|
||||||
|
break;
|
||||||
|
case wivrn_input_type::VEC2_Y:
|
||||||
|
inputs_staging[index].value.vec2.y = input.value;
|
||||||
|
break;
|
||||||
|
case wivrn_input_type::POSE:
|
||||||
|
// Pose should not be in the inputs array
|
||||||
|
U_LOG_W("Unexpected input id %d", int(input.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xrt_result_t wivrn_hand_interaction::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * res)
|
||||||
|
{
|
||||||
|
std::chrono::nanoseconds extrapolation_time;
|
||||||
|
device_id device;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case XRT_INPUT_HAND_AIM_POSE:
|
||||||
|
std::tie(extrapolation_time, *res, device) = aim.get_pose_at(at_timestamp_ns);
|
||||||
|
cnx->set_enabled(device, true);
|
||||||
|
break;
|
||||||
|
case XRT_INPUT_HAND_GRIP_POSE:
|
||||||
|
std::tie(extrapolation_time, *res, device) = grip.get_pose_at(at_timestamp_ns);
|
||||||
|
cnx->set_enabled(device, true);
|
||||||
|
break;
|
||||||
|
case XRT_INPUT_GENERIC_PALM_POSE:
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
cnx->add_predict_offset(extrapolation_time);
|
||||||
|
if (auto & out = tracking_dump())
|
||||||
|
{
|
||||||
|
std::lock_guard lock{tracking_dump_mutex};
|
||||||
|
auto device = [&] {
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case XRT_INPUT_HAND_AIM_POSE: return aim.device;
|
||||||
|
case XRT_INPUT_HAND_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();
|
||||||
|
} }();
|
||||||
|
out << magic_enum::enum_name(device) << ','
|
||||||
|
<< os_monotonic_get_ns() << ','
|
||||||
|
<< at_timestamp_ns << ','
|
||||||
|
<< extrapolation_time.count() << ','
|
||||||
|
<< "g,"
|
||||||
|
<< *res << std::endl;
|
||||||
|
;
|
||||||
|
}
|
||||||
|
return XRT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wivrn_hand_interaction::set_derived_pose(const from_headset::derived_pose & derived)
|
||||||
|
{
|
||||||
|
auto list = [this](device_id id) -> pose_list * {
|
||||||
|
for (auto item: {&grip, &aim, &palm})
|
||||||
|
{
|
||||||
|
if (item->device == id)
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
auto source = list(derived.source);
|
||||||
|
auto target = list(derived.target);
|
||||||
|
if (source and target)
|
||||||
|
{
|
||||||
|
target->set_derived(source, xrt_cast(derived.relation));
|
||||||
|
if (source != target)
|
||||||
|
cnx->set_enabled(derived.target, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wivrn_hand_interaction::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||||
|
{
|
||||||
|
if (not aim.update_tracking(tracking, offset))
|
||||||
|
cnx->set_enabled(aim.device, false);
|
||||||
|
if (not grip.update_tracking(tracking, offset))
|
||||||
|
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};
|
||||||
|
auto now = os_monotonic_get_ns();
|
||||||
|
for (const auto & pose: tracking.device_poses)
|
||||||
|
{
|
||||||
|
if (pose.device == aim.device or pose.device == grip.device or pose.device == palm.device)
|
||||||
|
out << magic_enum::enum_name(pose.device) << ','
|
||||||
|
<< now << ','
|
||||||
|
<< offset.from_headset(tracking.timestamp) << ','
|
||||||
|
<< tracking.timestamp - tracking.production_timestamp << ','
|
||||||
|
<< "r,"
|
||||||
|
<< pose_list::convert_pose(pose) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wivrn_hand_interaction::reset_history()
|
||||||
|
{
|
||||||
|
aim.reset();
|
||||||
|
grip.reset();
|
||||||
|
palm.reset();
|
||||||
|
pinch_ext.reset();
|
||||||
|
poke_ext.reset();
|
||||||
|
}
|
||||||
|
} // namespace wivrn
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* WiVRn VR streaming
|
||||||
|
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||||
|
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||||
|
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "xrt/xrt_device.h"
|
||||||
|
|
||||||
|
#include "hand_joints_list.h"
|
||||||
|
#include "pose_list.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace wivrn
|
||||||
|
{
|
||||||
|
class wivrn_session;
|
||||||
|
|
||||||
|
class wivrn_hand_interaction : public xrt_device
|
||||||
|
{
|
||||||
|
std::mutex mutex;
|
||||||
|
|
||||||
|
pose_list grip;
|
||||||
|
pose_list aim;
|
||||||
|
pose_list palm;
|
||||||
|
pose_list pinch_ext;
|
||||||
|
pose_list poke_ext;
|
||||||
|
|
||||||
|
std::vector<xrt_input> inputs_staging;
|
||||||
|
std::vector<xrt_input> inputs_array;
|
||||||
|
|
||||||
|
wivrn::wivrn_session * cnx;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using base = xrt_device;
|
||||||
|
wivrn_hand_interaction(int hand_id, xrt_device * hmd, wivrn::wivrn_session * cnx);
|
||||||
|
|
||||||
|
xrt_result_t update_inputs();
|
||||||
|
|
||||||
|
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation);
|
||||||
|
|
||||||
|
void set_inputs(const from_headset::inputs &, const clock_offset &);
|
||||||
|
|
||||||
|
void set_derived_pose(const from_headset::derived_pose &);
|
||||||
|
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||||
|
|
||||||
|
void reset_history();
|
||||||
|
};
|
||||||
|
} // namespace wivrn
|
||||||
@@ -146,8 +146,10 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
|
|||||||
connection(std::move(connection)),
|
connection(std::move(connection)),
|
||||||
xrt_system(system),
|
xrt_system(system),
|
||||||
hmd(this, get_info()),
|
hmd(this, get_info()),
|
||||||
left_hand(0, &hmd, this),
|
left_controller(0, &hmd, this),
|
||||||
right_hand(1, &hmd, this)
|
left_hand_interaction(0, &hmd, this),
|
||||||
|
right_controller(1, &hmd, this),
|
||||||
|
right_hand_interaction(1, &hmd, this)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -172,11 +174,13 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
|
|||||||
if (hmd.supported.face_tracking)
|
if (hmd.supported.face_tracking)
|
||||||
static_roles.face = &hmd;
|
static_roles.face = &hmd;
|
||||||
|
|
||||||
roles.left = xdev_count;
|
roles.left = left_controller_index = xdev_count++;
|
||||||
static_roles.hand_tracking.left = xdevs[xdev_count++] = &left_hand;
|
static_roles.hand_tracking.left = xdevs[left_controller_index] = &left_controller;
|
||||||
|
xdevs[left_hand_interaction_index = xdev_count++] = &left_hand_interaction;
|
||||||
|
|
||||||
roles.right = xdev_count;
|
roles.right = right_controller_index = xdev_count++;
|
||||||
static_roles.hand_tracking.right = xdevs[xdev_count++] = &right_hand;
|
static_roles.hand_tracking.right = xdevs[right_controller_index] = &right_controller;
|
||||||
|
xdevs[right_hand_interaction_index = xdev_count++] = &right_hand_interaction;
|
||||||
|
|
||||||
#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
|
#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
|
||||||
auto use_steamvr_lh = configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH");
|
auto use_steamvr_lh = configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH");
|
||||||
@@ -314,8 +318,8 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
|||||||
u_builder_create_space_overseer_legacy(
|
u_builder_create_space_overseer_legacy(
|
||||||
&self->xrt_system.broadcast,
|
&self->xrt_system.broadcast,
|
||||||
&self->hmd,
|
&self->hmd,
|
||||||
&self->left_hand,
|
&self->left_controller,
|
||||||
&self->right_hand,
|
&self->right_controller,
|
||||||
nullptr,
|
nullptr,
|
||||||
self->xdevs,
|
self->xdevs,
|
||||||
self->xdev_count,
|
self->xdev_count,
|
||||||
@@ -364,6 +368,8 @@ static xrt_device_name get_name(interaction_profile profile)
|
|||||||
return XRT_DEVICE_INVALID;
|
return XRT_DEVICE_INVALID;
|
||||||
case interaction_profile::khr_simple_controller:
|
case interaction_profile::khr_simple_controller:
|
||||||
return XRT_DEVICE_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:
|
case interaction_profile::bytedance_pico_neo3_controller:
|
||||||
return XRT_DEVICE_PICO_NEO3_CONTROLLER;
|
return XRT_DEVICE_PICO_NEO3_CONTROLLER;
|
||||||
case interaction_profile::bytedance_pico4_controller:
|
case interaction_profile::bytedance_pico4_controller:
|
||||||
@@ -408,8 +414,8 @@ static xrt_device_name get_name(interaction_profile profile)
|
|||||||
}
|
}
|
||||||
void wivrn_session::operator()(from_headset::trackings && tracking)
|
void wivrn_session::operator()(from_headset::trackings && tracking)
|
||||||
{
|
{
|
||||||
auto left = xdevs[roles.left] == &left_hand ? get_name(tracking.interaction_profiles[0]) : XRT_DEVICE_INVALID;
|
auto left = (roles.left == left_controller_index || roles.left == left_hand_interaction_index) ? get_name(tracking.interaction_profiles[0]) : XRT_DEVICE_INVALID;
|
||||||
auto right = xdevs[roles.right] == &right_hand ? get_name(tracking.interaction_profiles[1]) : XRT_DEVICE_INVALID;
|
auto right = (roles.right == right_controller_index || roles.right == right_hand_interaction_index) ? get_name(tracking.interaction_profiles[1]) : XRT_DEVICE_INVALID;
|
||||||
if (left != roles.left_profile or right != roles.right_profile)
|
if (left != roles.left_profile or right != roles.right_profile)
|
||||||
{
|
{
|
||||||
U_LOG_I("Updating interaction profiles: from \n"
|
U_LOG_I("Updating interaction profiles: from \n"
|
||||||
@@ -420,8 +426,42 @@ void wivrn_session::operator()(from_headset::trackings && tracking)
|
|||||||
std::string(magic_enum::enum_name(roles.right_profile)).c_str(),
|
std::string(magic_enum::enum_name(roles.right_profile)).c_str(),
|
||||||
std::string(magic_enum::enum_name(right)).c_str());
|
std::string(magic_enum::enum_name(right)).c_str());
|
||||||
std::lock_guard lock(roles_mutex);
|
std::lock_guard lock(roles_mutex);
|
||||||
|
|
||||||
|
// don't change role when hand from other driver is used
|
||||||
|
if (roles.left == left_hand_interaction_index || roles.left == left_controller_index)
|
||||||
|
{
|
||||||
|
if (left == XRT_DEVICE_EXT_HAND_INTERACTION)
|
||||||
|
{
|
||||||
|
left_hand_interaction.reset_history();
|
||||||
|
roles.left = left_hand_interaction_index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
left_controller.reset_history();
|
||||||
|
roles.left = left_controller_index;
|
||||||
|
set_enabled(device_id::LEFT_PINCH_POSE, false);
|
||||||
|
set_enabled(device_id::LEFT_POKE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
roles.left_profile = left;
|
roles.left_profile = left;
|
||||||
|
|
||||||
|
if (roles.right == right_hand_interaction_index || roles.right == right_controller_index)
|
||||||
|
{
|
||||||
|
if (right == XRT_DEVICE_EXT_HAND_INTERACTION)
|
||||||
|
{
|
||||||
|
right_hand_interaction.reset_history();
|
||||||
|
roles.right = right_hand_interaction_index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
right_controller.reset_history();
|
||||||
|
roles.right = right_controller_index;
|
||||||
|
set_enabled(device_id::RIGHT_PINCH_POSE, false);
|
||||||
|
set_enabled(device_id::RIGHT_POKE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
roles.right_profile = right;
|
roles.right_profile = right;
|
||||||
|
|
||||||
++roles.generation_id;
|
++roles.generation_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,8 +480,16 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
|
|||||||
auto offset = offset_est.get_offset();
|
auto offset = offset_est.get_offset();
|
||||||
|
|
||||||
hmd.update_tracking(tracking, offset);
|
hmd.update_tracking(tracking, offset);
|
||||||
left_hand.update_tracking(tracking, offset);
|
if (roles.left == left_hand_interaction_index)
|
||||||
right_hand.update_tracking(tracking, offset);
|
left_hand_interaction.update_tracking(tracking, offset);
|
||||||
|
else
|
||||||
|
left_controller.update_tracking(tracking, offset);
|
||||||
|
|
||||||
|
if (roles.right == right_hand_interaction_index)
|
||||||
|
right_hand_interaction.update_tracking(tracking, offset);
|
||||||
|
else
|
||||||
|
right_controller.update_tracking(tracking, offset);
|
||||||
|
|
||||||
if (eye_tracker)
|
if (eye_tracker)
|
||||||
eye_tracker->update_tracking(tracking, offset);
|
eye_tracker->update_tracking(tracking, offset);
|
||||||
{
|
{
|
||||||
@@ -458,16 +506,19 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
|
|||||||
|
|
||||||
void wivrn_session::operator()(from_headset::derived_pose && derived)
|
void wivrn_session::operator()(from_headset::derived_pose && derived)
|
||||||
{
|
{
|
||||||
left_hand.set_derived_pose(derived);
|
left_controller.set_derived_pose(derived);
|
||||||
right_hand.set_derived_pose(derived);
|
left_hand_interaction.set_derived_pose(derived);
|
||||||
|
|
||||||
|
right_controller.set_derived_pose(derived);
|
||||||
|
right_hand_interaction.set_derived_pose(derived);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wivrn_session::operator()(from_headset::hand_tracking && hand_tracking)
|
void wivrn_session::operator()(from_headset::hand_tracking && hand_tracking)
|
||||||
{
|
{
|
||||||
auto offset = offset_est.get_offset();
|
auto offset = offset_est.get_offset();
|
||||||
|
|
||||||
left_hand.update_hand_tracking(hand_tracking, offset);
|
left_controller.update_hand_tracking(hand_tracking, offset);
|
||||||
right_hand.update_hand_tracking(hand_tracking, offset);
|
right_controller.update_hand_tracking(hand_tracking, offset);
|
||||||
}
|
}
|
||||||
void wivrn_session::operator()(from_headset::body_tracking && body_tracking)
|
void wivrn_session::operator()(from_headset::body_tracking && body_tracking)
|
||||||
{
|
{
|
||||||
@@ -486,8 +537,15 @@ void wivrn_session::operator()(from_headset::inputs && inputs)
|
|||||||
{
|
{
|
||||||
auto offset = get_offset();
|
auto offset = get_offset();
|
||||||
|
|
||||||
left_hand.set_inputs(inputs, offset);
|
if (roles.left == left_hand_interaction_index)
|
||||||
right_hand.set_inputs(inputs, offset);
|
left_hand_interaction.set_inputs(inputs, offset);
|
||||||
|
else if (roles.left == left_controller_index)
|
||||||
|
left_controller.set_inputs(inputs, offset);
|
||||||
|
|
||||||
|
if (roles.right == right_hand_interaction_index)
|
||||||
|
right_hand_interaction.set_inputs(inputs, offset);
|
||||||
|
else if (roles.right == right_controller_index)
|
||||||
|
right_controller.set_inputs(inputs, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wivrn_session::operator()(from_headset::timesync_response && timesync)
|
void wivrn_session::operator()(from_headset::timesync_response && timesync)
|
||||||
@@ -506,12 +564,20 @@ static auto to_tracking_control(device_id id)
|
|||||||
return tid::left_grip;
|
return tid::left_grip;
|
||||||
case device_id::LEFT_PALM:
|
case device_id::LEFT_PALM:
|
||||||
return tid::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:
|
case device_id::RIGHT_AIM:
|
||||||
return tid::right_aim;
|
return tid::right_aim;
|
||||||
case device_id::RIGHT_GRIP:
|
case device_id::RIGHT_GRIP:
|
||||||
return tid::right_grip;
|
return tid::right_grip;
|
||||||
case device_id::RIGHT_PALM:
|
case device_id::RIGHT_PALM:
|
||||||
return tid::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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "driver/app_pacer.h"
|
#include "driver/app_pacer.h"
|
||||||
#include "wivrn_connection.h"
|
#include "wivrn_connection.h"
|
||||||
#include "wivrn_controller.h"
|
#include "wivrn_controller.h"
|
||||||
|
#include "wivrn_hand_interaction.h"
|
||||||
#include "wivrn_hmd.h"
|
#include "wivrn_hmd.h"
|
||||||
#include "wivrn_ipc.h"
|
#include "wivrn_ipc.h"
|
||||||
#include "wivrn_packets.h"
|
#include "wivrn_packets.h"
|
||||||
@@ -105,8 +106,14 @@ class wivrn_session : public xrt_system_devices
|
|||||||
};
|
};
|
||||||
|
|
||||||
wivrn_hmd hmd;
|
wivrn_hmd hmd;
|
||||||
wivrn_controller left_hand;
|
wivrn_controller left_controller;
|
||||||
wivrn_controller right_hand;
|
int32_t left_controller_index;
|
||||||
|
wivrn_hand_interaction left_hand_interaction;
|
||||||
|
int32_t left_hand_interaction_index;
|
||||||
|
wivrn_controller right_controller;
|
||||||
|
int32_t right_controller_index;
|
||||||
|
wivrn_hand_interaction right_hand_interaction;
|
||||||
|
int32_t right_hand_interaction_index;
|
||||||
std::unique_ptr<wivrn_eye_tracker> eye_tracker;
|
std::unique_ptr<wivrn_eye_tracker> eye_tracker;
|
||||||
std::unique_ptr<wivrn_fb_face2_tracker> fb_face2_tracker;
|
std::unique_ptr<wivrn_fb_face2_tracker> fb_face2_tracker;
|
||||||
std::unique_ptr<wivrn_htc_face_tracker> htc_face_tracker;
|
std::unique_ptr<wivrn_htc_face_tracker> htc_face_tracker;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ set_target_properties(wivrn-dissector PROPERTIES
|
|||||||
target_link_libraries(wivrn-dissector PRIVATE epan wivrn-common)
|
target_link_libraries(wivrn-dissector PRIVATE epan wivrn-common)
|
||||||
set_target_properties(wivrn-dissector PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
set_target_properties(wivrn-dissector PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
if (OPENXR_FOUND)
|
if (OpenXR_FOUND)
|
||||||
target_link_libraries(wivrn-dissector PRIVATE OpenXR::headers)
|
target_link_libraries(wivrn-dissector PRIVATE OpenXR::headers)
|
||||||
else()
|
else()
|
||||||
FetchContent_MakeAvailable(openxr_loader)
|
FetchContent_MakeAvailable(openxr_loader)
|
||||||
|
|||||||
Reference in New Issue
Block a user