From 281b04cbc2ad76542220d338ab547709afd1223b Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Mon, 21 Oct 2024 23:00:50 +0200 Subject: [PATCH] Allow opt out of hand tracking --- client/configuration.cpp | 5 ++++ client/hardware.cpp | 2 ++ client/hardware.h | 1 + client/locale/fr/wivrn.po | 44 ++++++++++++++++-------------- client/locale/it/wivrn.po | 44 ++++++++++++++++-------------- client/scenes/lobby_gui.cpp | 29 +++++++++++++++++++- client/scenes/stream.cpp | 2 +- client/scenes/stream_tracking.cpp | 11 ++++++-- server/driver/wivrn_controller.cpp | 4 +-- 9 files changed, 95 insertions(+), 47 deletions(-) diff --git a/client/configuration.cpp b/client/configuration.cpp index 38719607..191d3d13 100644 --- a/client/configuration.cpp +++ b/client/configuration.cpp @@ -95,6 +95,10 @@ bool configuration::check_feature(feature f) const { case feature::microphone: break; + case feature::hand_tracking: + if (not application::get_hand_tracking_supported()) + return false; + break; case feature::eye_gaze: if (not application::get_eye_gaze_supported()) return false; @@ -138,6 +142,7 @@ void configuration::set_feature(feature f, bool state) configuration::configuration(xr::system & system) { passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color; + features[feature::hand_tracking] = application::get_hand_tracking_supported(); try { simdjson::dom::parser parser; diff --git a/client/hardware.cpp b/client/hardware.cpp index 21c4bef2..b798ddf6 100644 --- a/client/hardware.cpp +++ b/client/hardware.cpp @@ -159,6 +159,8 @@ const char * permission_name(feature f) { case feature::microphone: return "android.permission.RECORD_AUDIO"; + case feature::hand_tracking: + return nullptr; case feature::eye_gaze: switch (guess_model()) { diff --git a/client/hardware.h b/client/hardware.h index 228fb428..66061c8a 100644 --- a/client/hardware.h +++ b/client/hardware.h @@ -37,6 +37,7 @@ enum class model enum class feature { microphone, + hand_tracking, eye_gaze, face_tracking, }; diff --git a/client/locale/fr/wivrn.po b/client/locale/fr/wivrn.po index 2e93126d..3f248ef4 100644 --- a/client/locale/fr/wivrn.po +++ b/client/locale/fr/wivrn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WiVRn 0.15\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-21 16:13+0200\n" +"POT-Creation-Date: 2024-10-21 22:59+0200\n" "PO-Revision-Date: 2024-05-20 13:00+0200\n" "Last-Translator: Guillaume Meunier \n" "Language: French\n" @@ -10,31 +10,31 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: client/scenes/lobby.cpp:143 +#: client/scenes/lobby.cpp:142 msgid "No supported swapchain format" msgstr "Aucun format de swapchain supporté" -#: client/scenes/lobby.cpp:178 +#: client/scenes/lobby.cpp:177 msgid "Incompatible WiVRn server: no protocol field in TXT" msgstr "Serveur WiVRn incompatible : pas de champ protocol dans le TXT" -#: client/scenes/lobby.cpp:181 +#: client/scenes/lobby.cpp:180 #, c++-format msgid "Incompatible WiVRn server protocol (client: {}, server: {})" msgstr "" "Version du protocole WiVRn du serveur incompatible (client: {}, serveur: {})" -#: client/scenes/lobby.cpp:196 +#: client/scenes/lobby.cpp:195 #, c++-format msgid "Cannot resolve hostname: {}" msgstr "Impossible de résoudre le nom: {}" -#: client/scenes/lobby.cpp:235 +#: client/scenes/lobby.cpp:234 #, c++-format msgid "Cannot connect to {} ({}): {}" msgstr "Impossible de se connecter à {} ({}): {}" -#: client/scenes/lobby.cpp:347 +#: client/scenes/lobby.cpp:346 msgid "Waiting for connection" msgstr "Attente de connexion" @@ -122,60 +122,64 @@ msgid "Enable microphone" msgstr "Activer le micro" #: client/scenes/lobby_gui.cpp:395 +msgid "Enable hand tracking" +msgstr "Activer le suivi des mains" + +#: client/scenes/lobby_gui.cpp:406 msgid "Enable eye tracking" msgstr "Activer le suivi des yeux" -#: client/scenes/lobby_gui.cpp:406 +#: client/scenes/lobby_gui.cpp:417 msgid "Enable face tracking" msgstr "Activer le suivi du visage" -#: client/scenes/lobby_gui.cpp:416 +#: client/scenes/lobby_gui.cpp:427 msgid "Enable video passthrough in lobby" msgstr "Activer la vue réelle dans l'accueil" -#: client/scenes/lobby_gui.cpp:424 +#: client/scenes/lobby_gui.cpp:435 msgid "Show performance metrics" msgstr "Afficher les métriques de performances" -#: client/scenes/lobby_gui.cpp:428 +#: client/scenes/lobby_gui.cpp:439 msgid "Overlay can be toggled by pressing both thumbsticks" msgstr "L'affichage peut être basculé en appuyant sur les deux joysticks" -#: client/scenes/lobby_gui.cpp:458 client/scenes/lobby_gui.cpp:466 +#: client/scenes/lobby_gui.cpp:469 client/scenes/lobby_gui.cpp:477 #: client/scenes/stream_stats.cpp:147 msgid "CPU time" msgstr "Temps CPU" -#: client/scenes/lobby_gui.cpp:462 +#: client/scenes/lobby_gui.cpp:473 msgid "CPU time [ms]" msgstr "Temps CPU [ms]" -#: client/scenes/lobby_gui.cpp:472 client/scenes/lobby_gui.cpp:480 +#: client/scenes/lobby_gui.cpp:483 client/scenes/lobby_gui.cpp:491 #: client/scenes/stream_stats.cpp:149 msgid "GPU time" msgstr "Temps GPU" -#: client/scenes/lobby_gui.cpp:476 +#: client/scenes/lobby_gui.cpp:487 msgid "GPU time [ms]" msgstr "Temps GPU [ms]" -#: client/scenes/lobby_gui.cpp:504 client/scenes/lobby_gui.cpp:773 +#: client/scenes/lobby_gui.cpp:515 client/scenes/lobby_gui.cpp:1004 msgid "Licenses" msgstr "Licences" -#: client/scenes/lobby_gui.cpp:763 +#: client/scenes/lobby_gui.cpp:994 msgid "Server list" msgstr "Serveurs" -#: client/scenes/lobby_gui.cpp:766 +#: client/scenes/lobby_gui.cpp:997 msgid "Settings" msgstr "Paramètres" -#: client/scenes/lobby_gui.cpp:770 +#: client/scenes/lobby_gui.cpp:1001 msgid "About" msgstr "À propos" -#: client/scenes/lobby_gui.cpp:776 +#: client/scenes/lobby_gui.cpp:1007 msgid "Exit" msgstr "Quitter" diff --git a/client/locale/it/wivrn.po b/client/locale/it/wivrn.po index 3e66dcc9..88aa8ee2 100644 --- a/client/locale/it/wivrn.po +++ b/client/locale/it/wivrn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WiVRn 0.15\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-21 16:13+0200\n" +"POT-Creation-Date: 2024-10-21 22:59+0200\n" "PO-Revision-Date: 2024-10-15 20:16+0100\n" "Last-Translator: Albano Battistella \n" "Language: Italian\n" @@ -10,30 +10,30 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: client/scenes/lobby.cpp:143 +#: client/scenes/lobby.cpp:142 msgid "No supported swapchain format" msgstr "Nessun formato swapchain supportato" -#: client/scenes/lobby.cpp:178 +#: client/scenes/lobby.cpp:177 msgid "Incompatible WiVRn server: no protocol field in TXT" msgstr "Server WiVRn incompatibile: nessun campo protocollo in TXT" -#: client/scenes/lobby.cpp:181 +#: client/scenes/lobby.cpp:180 #, c++-format msgid "Incompatible WiVRn server protocol (client: {}, server: {})" msgstr "Protocollo server WiVRn incompatibile (client: {}, server: {})" -#: client/scenes/lobby.cpp:196 +#: client/scenes/lobby.cpp:195 #, c++-format msgid "Cannot resolve hostname: {}" msgstr "Impossibile risolvere il nome host: {}" -#: client/scenes/lobby.cpp:235 +#: client/scenes/lobby.cpp:234 #, c++-format msgid "Cannot connect to {} ({}): {}" msgstr "Impossibile connettersi a {} ({}): {}" -#: client/scenes/lobby.cpp:347 +#: client/scenes/lobby.cpp:346 msgid "Waiting for connection" msgstr "In attesa di connessione" @@ -121,60 +121,64 @@ msgid "Enable microphone" msgstr "Attiva il microfono" #: client/scenes/lobby_gui.cpp:395 +msgid "Enable hand tracking" +msgstr "Abilita il tracciamento delle mani" + +#: client/scenes/lobby_gui.cpp:406 msgid "Enable eye tracking" msgstr "Abilita il tracciamento oculare" -#: client/scenes/lobby_gui.cpp:406 +#: client/scenes/lobby_gui.cpp:417 msgid "Enable face tracking" msgstr "Abilita il tracciamento facciale" -#: client/scenes/lobby_gui.cpp:416 +#: client/scenes/lobby_gui.cpp:427 msgid "Enable video passthrough in lobby" msgstr "Abilita la visualizzazione reale in ingresso" -#: client/scenes/lobby_gui.cpp:424 +#: client/scenes/lobby_gui.cpp:435 msgid "Show performance metrics" msgstr "Mostra metriche delle prestazioni" -#: client/scenes/lobby_gui.cpp:428 +#: client/scenes/lobby_gui.cpp:439 msgid "Overlay can be toggled by pressing both thumbsticks" msgstr "È possibile alternare la visualizzazione premendo entrambi i joystick" -#: client/scenes/lobby_gui.cpp:458 client/scenes/lobby_gui.cpp:466 +#: client/scenes/lobby_gui.cpp:469 client/scenes/lobby_gui.cpp:477 #: client/scenes/stream_stats.cpp:147 msgid "CPU time" msgstr "Tempo CPU" -#: client/scenes/lobby_gui.cpp:462 +#: client/scenes/lobby_gui.cpp:473 msgid "CPU time [ms]" msgstr "Tempo CPU [ms]" -#: client/scenes/lobby_gui.cpp:472 client/scenes/lobby_gui.cpp:480 +#: client/scenes/lobby_gui.cpp:483 client/scenes/lobby_gui.cpp:491 #: client/scenes/stream_stats.cpp:149 msgid "GPU time" msgstr "Tempo GPU" -#: client/scenes/lobby_gui.cpp:476 +#: client/scenes/lobby_gui.cpp:487 msgid "GPU time [ms]" msgstr "Tempo GPU [ms]" -#: client/scenes/lobby_gui.cpp:504 client/scenes/lobby_gui.cpp:773 +#: client/scenes/lobby_gui.cpp:515 client/scenes/lobby_gui.cpp:1004 msgid "Licenses" msgstr "Licenze" -#: client/scenes/lobby_gui.cpp:763 +#: client/scenes/lobby_gui.cpp:994 msgid "Server list" msgstr "Elenco dei server" -#: client/scenes/lobby_gui.cpp:766 +#: client/scenes/lobby_gui.cpp:997 msgid "Settings" msgstr "Impostazioni" -#: client/scenes/lobby_gui.cpp:770 +#: client/scenes/lobby_gui.cpp:1001 msgid "About" msgstr "Informazioni" -#: client/scenes/lobby_gui.cpp:776 +#: client/scenes/lobby_gui.cpp:1007 msgid "Exit" msgstr "Esci" diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index e2993fd8..22a26e9e 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -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(); diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index e5ee759b..46f44724 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -123,7 +123,7 @@ std::shared_ptr scenes::stream::create(std::unique_ptr 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()); } diff --git a/server/driver/wivrn_controller.cpp b/server/driver/wivrn_controller.cpp index 3b64af5b..85ba56b7 100644 --- a/server/driver/wivrn_controller.cpp +++ b/server/driver/wivrn_controller.cpp @@ -171,7 +171,7 @@ wivrn_controller::wivrn_controller(int hand_id, base->name = XRT_DEVICE_TOUCH_CONTROLLER; base->orientation_tracking_supported = true; - base->hand_tracking_supported = true; + base->hand_tracking_supported = cnx->get_info().hand_tracking; base->position_tracking_supported = true; base->tracking_origin = hmd->tracking_origin; @@ -214,7 +214,7 @@ wivrn_controller::wivrn_controller(int hand_id, SET_INPUT(THUMBREST_TOUCH); 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_HAND_TRACKER].active = hand_tracking_supported; inputs[WIVRN_CONTROLLER_PALM_POSE].name = XRT_INPUT_GENERIC_PALM_POSE; inputs[WIVRN_CONTROLLER_PALM_POSE].active = cnx->get_info().palm_pose;