Forward XR_EXT_hand_interaction
* Fix binds * hand_interaction tids
This commit is contained in:
@@ -234,31 +234,6 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
|
||||
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>
|
||||
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;
|
||||
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<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)))
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user