From 0f77142b9df98fa4207c20f5dde090b185d4b874 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Mon, 10 Jun 2024 11:46:58 +0200 Subject: [PATCH] Add toggle action for plots --- client/locale/fr/wivrn.po | 22 ++++++++----- client/scenes/lobby_gui.cpp | 2 ++ client/scenes/stream.cpp | 66 ++++++++++++++++++++++++++++++++++--- client/scenes/stream.h | 3 ++ 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/client/locale/fr/wivrn.po b/client/locale/fr/wivrn.po index dd7ba98a..dcd8205b 100644 --- a/client/locale/fr/wivrn.po +++ b/client/locale/fr/wivrn.po @@ -124,41 +124,45 @@ msgstr "Activer la vue réelle dans l'accueil" msgid "Show performance metrics" msgstr "Afficher les métriques de performances" -#: client/scenes/lobby_gui.cpp:454 client/scenes/lobby_gui.cpp:462 +#: client/scenes/lobby_gui.cpp:426 +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:456 client/scenes/lobby_gui.cpp:464 #: client/scenes/stream_stats.cpp:144 msgid "CPU time" msgstr "Temps CPU" -#: client/scenes/lobby_gui.cpp:458 +#: client/scenes/lobby_gui.cpp:460 msgid "CPU time [ms]" msgstr "Temps CPU [ms]" -#: client/scenes/lobby_gui.cpp:468 client/scenes/lobby_gui.cpp:476 +#: client/scenes/lobby_gui.cpp:470 client/scenes/lobby_gui.cpp:478 #: client/scenes/stream_stats.cpp:146 msgid "GPU time" msgstr "Temps GPU" -#: client/scenes/lobby_gui.cpp:472 +#: client/scenes/lobby_gui.cpp:474 msgid "GPU time [ms]" msgstr "Temps GPU [ms]" -#: client/scenes/lobby_gui.cpp:500 client/scenes/lobby_gui.cpp:693 +#: client/scenes/lobby_gui.cpp:502 client/scenes/lobby_gui.cpp:695 msgid "Licenses" msgstr "Licences" -#: client/scenes/lobby_gui.cpp:683 +#: client/scenes/lobby_gui.cpp:685 msgid "Server list" msgstr "Serveurs" -#: client/scenes/lobby_gui.cpp:686 +#: client/scenes/lobby_gui.cpp:688 msgid "Settings" msgstr "Paramètres" -#: client/scenes/lobby_gui.cpp:690 +#: client/scenes/lobby_gui.cpp:692 msgid "About" msgstr "À propos" -#: client/scenes/lobby_gui.cpp:696 +#: client/scenes/lobby_gui.cpp:698 msgid "Exit" msgstr "Quitter" diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index a77c4b36..5f9c573f 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -422,6 +422,8 @@ void scenes::lobby::gui_settings() if (ImGui::Checkbox(_S("Show performance metrics"), &config.show_performance_metrics)) config.save(); vibrate_on_hover(); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("%s", _S("Overlay can be toggled by pressing both thumbsticks")); ImGui::PopStyleVar(); diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index 464058ec..27070515 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -208,6 +208,8 @@ void scenes::stream::on_focused() glm::vec2{1.0, 0.6666}); imgui_ctx->set_position({0, 0, -1}, {1, 0, 0, 0}); + plots_toggle_1 = get_action("plots_toggle_1").first; + plots_toggle_2 = get_action("plots_toggle_2").first; } wifi_lock::want_low_latency(true); @@ -699,7 +701,7 @@ void scenes::stream::render(const XrFrameState & frame_state) }; XrCompositionLayerQuad imgui_layer; - if (imgui_ctx) + if (imgui_ctx and plots_visible) { accumulate_metrics(frame_state.predictedDisplayTime, current_blit_handles, timestamps); imgui_layer = plot_performance_metrics(frame_state.predictedDisplayTime); @@ -707,7 +709,7 @@ void scenes::stream::render(const XrFrameState & frame_state) layers_base.push_back(reinterpret_cast(&layer)); - if (imgui_ctx) + if (imgui_ctx and plots_visible) layers_base.push_back(reinterpret_cast(&imgui_layer)); session.end_frame(frame_state.predictedDisplayTime, layers_base); @@ -717,6 +719,24 @@ void scenes::stream::render(const XrFrameState & frame_state) send_feedback(handle->feedback); read_actions(); + + if (plots_toggle_1 and plots_toggle_2) + { + XrActionStateGetInfo get_info{ + .type = XR_TYPE_ACTION_STATE_GET_INFO, + .action = plots_toggle_1, + }; + + XrActionStateBoolean state_1{XR_TYPE_ACTION_STATE_BOOLEAN}; + CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_1)); + get_info.action = plots_toggle_2; + XrActionStateBoolean state_2{XR_TYPE_ACTION_STATE_BOOLEAN}; + CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_2)); + + if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync)) + plots_visible = not plots_visible; + } + query_pool_filled = true; } @@ -907,8 +927,46 @@ void scenes::stream::setup_reprojection_swapchain() scene::meta & scenes::stream::get_meta_scene() { static meta m{ - "Stream", - {}}; + .name = "Stream", + .actions = { + {"plots_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT}, + {"plots_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT}, + }, + .bindings = { + suggested_binding{ + "/interaction_profiles/oculus/touch_controller", + { + {"plots_toggle_1", "/user/hand/left/input/thumbstick/click"}, + {"plots_toggle_2", "/user/hand/right/input/thumbstick/click"}, + }, + }, + suggested_binding{ + "/interaction_profiles/bytedance/pico_neo3_controller", + { + {"plots_toggle_1", "/user/hand/left/input/thumbstick/click"}, + {"plots_toggle_2", "/user/hand/right/input/thumbstick/click"}, + }, + }, + suggested_binding{ + "/interaction_profiles/bytedance/pico4_controller", + { + {"plots_toggle_1", "/user/hand/left/input/thumbstick/click"}, + {"plots_toggle_2", "/user/hand/right/input/thumbstick/click"}, + }, + }, + suggested_binding{ + "/interaction_profiles/htc/vive_focus3_controller", + { + {"plots_toggle_1", "/user/hand/left/input/thumbstick/click"}, + {"plots_toggle_2", "/user/hand/right/input/thumbstick/click"}, + }, + }, + suggested_binding{ + "/interaction_profiles/khr/simple_controller", + {}, + }, + }, + }; return m; } diff --git a/client/scenes/stream.h b/client/scenes/stream.h index ea21ea05..58a68a79 100644 --- a/client/scenes/stream.h +++ b/client/scenes/stream.h @@ -111,6 +111,9 @@ private: std::optional