Allow opt out of hand tracking

This commit is contained in:
Patrick Nicolas
2024-10-22 10:36:27 +02:00
parent 08d19bd94d
commit 281b04cbc2
9 changed files with 95 additions and 47 deletions
+28 -1
View File
@@ -389,6 +389,17 @@ void scenes::lobby::gui_settings()
}
vibrate_on_hover();
}
{
ImGui::BeginDisabled(not application::get_hand_tracking_supported());
bool enabled = config.check_feature(feature::hand_tracking);
if (ImGui::Checkbox(_S("Enable hand tracking"), &enabled))
{
config.set_feature(feature::hand_tracking, enabled);
config.save();
}
vibrate_on_hover();
ImGui::EndDisabled();
}
{
ImGui::BeginDisabled(not application::get_eye_gaze_supported());
bool enabled = config.check_feature(feature::eye_gaze);
@@ -822,7 +833,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
{
feature f;
const char * icon_enabled;
const char * icon_disabled;
const char * icon_disabled = ICON_FA_SLASH;
bool enabled;
float w;
};
@@ -834,6 +845,14 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
.icon_disabled = ICON_FA_MICROPHONE_SLASH,
});
if (application::get_hand_tracking_supported())
{
items.push_back({
.f = feature::hand_tracking,
.icon_enabled = ICON_FA_HAND,
});
}
if (application::get_eye_gaze_supported())
{
items.push_back({
@@ -870,12 +889,20 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
ImGui::PushStyleColor(ImGuiCol_Text, i.enabled ? ImGui::GetColorU32(ImGuiCol_Text) : IM_COL32(255, 0, 0, 255));
if (&i != &items.front())
ImGui::SameLine();
auto pos = ImGui::GetCursorPos();
if (ImGui::Button(i.enabled ? i.icon_enabled : i.icon_disabled))
{
// button doesn't alter the bool
config.set_feature(i.f, not i.enabled);
config.save();
}
if (i.icon_disabled == std::string_view(ICON_FA_SLASH) and not i.enabled)
{
auto save = ImGui::GetCursorPos();
ImGui::SetCursorPos(pos + ImGui::GetStyle().FramePadding);
ImGui::Text("%s", i.icon_enabled);
ImGui::SetCursorPos(save);
}
vibrate_on_hover();
ImGui::PopStyleColor(2);
ImGui::PopStyleVar();
+1 -1
View File
@@ -123,7 +123,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (info.available_refresh_rates.empty())
spdlog::warn("Unable to detect refresh rates");
info.hand_tracking = application::get_hand_tracking_supported();
info.hand_tracking = config.check_feature(feature::hand_tracking);
info.eye_gaze = config.check_feature(feature::eye_gaze);
info.face_tracking2_fb = config.check_feature(feature::face_tracking);
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
+8 -3
View File
@@ -191,7 +191,9 @@ void scenes::stream::tracking()
if (XrSpace palm = application::space(xr::spaces::palm_right))
spaces.emplace_back(device_id::RIGHT_PALM, palm);
if (application::get_eye_gaze_supported())
const auto & config = application::get_config();
if (config.check_feature(feature::eye_gaze))
spaces.push_back({device_id::EYE_GAZE, application::space(xr::spaces::eye_gaze)});
XrSpace view_space = application::space(xr::spaces::view);
@@ -204,6 +206,9 @@ void scenes::stream::tracking()
std::vector<from_headset::hand_tracking> hands;
int skip_samples = 0;
const bool hand_tracking = config.check_feature(feature::hand_tracking);
const bool face_tracking = config.check_feature(feature::face_tracking);
while (not exiting)
{
try
@@ -259,7 +264,7 @@ void scenes::stream::tracking()
packet.device_poses.push_back(locate_space(device, space, world_space, t0 + Δt));
}
if (application::get_hand_tracking_supported())
if (hand_tracking)
{
if (control.enabled[size_t(tid::left_hand)])
hands.emplace_back(
@@ -276,7 +281,7 @@ void scenes::stream::tracking()
locate_hands(application::get_right_hand(), world_space, t0 + Δt));
}
if (application::get_fb_face_tracking2_supported() and control.enabled[size_t(tid::face)])
if (face_tracking and control.enabled[size_t(tid::face)])
{
application::get_fb_face_tracker2().get_weights(t0 + Δt, packet.face.emplace());
}