Add toggle action for plots

This commit is contained in:
Patrick Nicolas
2024-06-10 11:55:18 +02:00
parent 00671dbb94
commit 0f77142b9d
4 changed files with 80 additions and 13 deletions
+13 -9
View File
@@ -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"
+2
View File
@@ -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();
+62 -4
View File
@@ -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<XrCompositionLayerBaseHeader *>(&layer));
if (imgui_ctx)
if (imgui_ctx and plots_visible)
layers_base.push_back(reinterpret_cast<XrCompositionLayerBaseHeader *>(&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;
}
+3
View File
@@ -111,6 +111,9 @@ private:
std::optional<audio> audio_handle;
std::optional<imgui_context> imgui_ctx;
bool plots_visible = true;
XrAction plots_toggle_1 = XR_NULL_HANDLE;
XrAction plots_toggle_2 = XR_NULL_HANDLE;
// Keep a reference to the resources needed to blit the images until vkWaitForFences
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> current_blit_handles;