Hide GUI and use thumbstick for in-stream bitrate adjustment
This commit is contained in:
@@ -481,7 +481,7 @@ void scenes::stream::on_focused()
|
||||
}
|
||||
recenter_left = get_action("recenter_left").first;
|
||||
recenter_right = get_action("recenter_right").first;
|
||||
foveation_pitch = get_action("foveation_pitch").first;
|
||||
settings_adjust = get_action("settings_adjust").first;
|
||||
foveation_distance = get_action("foveation_distance").first;
|
||||
foveation_ok = get_action("foveation_ok").first;
|
||||
foveation_cancel = get_action("foveation_cancel").first;
|
||||
@@ -741,6 +741,7 @@ bool scenes::stream::is_gui_interactable() const
|
||||
{
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
@@ -1010,6 +1011,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::compact:
|
||||
case gui_status::overlay_only:
|
||||
@@ -1109,6 +1111,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
@@ -1207,7 +1210,7 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
{"recenter_left", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
{"recenter_right", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
|
||||
{"foveation_pitch", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||
{"settings_adjust", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||
{"foveation_distance", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||
{"foveation_ok", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
{"foveation_cancel", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
@@ -1239,7 +1242,7 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
|
||||
{"recenter_left", "/user/hand/left/input/squeeze/value"},
|
||||
{"recenter_right", "/user/hand/right/input/squeeze/value"},
|
||||
{"foveation_pitch", "/user/hand/right/input/thumbstick/y"},
|
||||
{"settings_adjust", "/user/hand/right/input/thumbstick/y"},
|
||||
{"foveation_distance", "/user/hand/left/input/thumbstick/y"},
|
||||
{"foveation_ok", "/user/hand/right/input/a/click"},
|
||||
{"foveation_cancel", "/user/hand/right/input/b/click"},
|
||||
|
||||
@@ -132,6 +132,7 @@ private:
|
||||
compact,
|
||||
stats,
|
||||
settings,
|
||||
bitrate_settings,
|
||||
foveation_settings,
|
||||
applications,
|
||||
application_launcher,
|
||||
@@ -149,7 +150,7 @@ private:
|
||||
XrAction plots_toggle_2 = XR_NULL_HANDLE;
|
||||
XrAction recenter_left = XR_NULL_HANDLE;
|
||||
XrAction recenter_right = XR_NULL_HANDLE;
|
||||
XrAction foveation_pitch = XR_NULL_HANDLE;
|
||||
XrAction settings_adjust = XR_NULL_HANDLE;
|
||||
XrAction foveation_distance = XR_NULL_HANDLE;
|
||||
XrAction foveation_ok = XR_NULL_HANDLE;
|
||||
XrAction foveation_cancel = XR_NULL_HANDLE;
|
||||
@@ -315,6 +316,7 @@ private:
|
||||
void gui_performance_metrics();
|
||||
void gui_compact_view();
|
||||
void gui_settings(float predicted_display_period);
|
||||
void gui_bitrate_settings(float predicted_display_period);
|
||||
void gui_foveation_settings(float predicted_display_period);
|
||||
void gui_applications();
|
||||
void draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period);
|
||||
|
||||
@@ -404,6 +404,7 @@ static void send_settings_changed_packet(xr::session & session, wivrn_session *
|
||||
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag); // TODO declaration in a .h file
|
||||
void scenes::stream::gui_settings(float predicted_display_period)
|
||||
{
|
||||
const ImGuiStyle & style = ImGui::GetStyle();
|
||||
auto & config = application::get_config();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20, 20));
|
||||
@@ -460,11 +461,18 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
}
|
||||
}
|
||||
|
||||
int bitrate_ = bitrate.load() / 10'000'000;
|
||||
if (ImGui::SliderInt(_S("Bitrate (Mbps)"), &bitrate_, 1, 20, "%d0"))
|
||||
{
|
||||
bitrate.store(bitrate_ * 10'000'000);
|
||||
send_settings_changed_packet(session, network_session.get(), config, bitrate_ * 10'000'000, predicted_display_period);
|
||||
const auto text = _("Bitrate:");
|
||||
const auto size = ImGui::CalcTextSize(text.c_str());
|
||||
ImGui::Text("%s", text.c_str());
|
||||
|
||||
ImGui::SameLine(0.f, 10.f);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (size.y / 4.f) - style.FramePadding.y * 3.f);
|
||||
if (ImGui::Button(fmt::format("{}Mbit/s", bitrate / 1'000'000).c_str()))
|
||||
gui_status = gui_status::bitrate_settings;
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
imgui_ctx->tooltip(_("Click to adjust bitrate"));
|
||||
}
|
||||
|
||||
if (application::get_openxr_post_processing_supported())
|
||||
@@ -580,6 +588,27 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void scenes::stream::gui_bitrate_settings(float predicted_display_period)
|
||||
{
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
ImGui::Text("%s", _S("Use the right thumbstick to adjust the bitrate"));
|
||||
ImGui::Text("%s", _S("Press A to go back"));
|
||||
ImGui::Text("%s", fmt::format(_F("Bitrate: {}Mbit/s"), bitrate / 1'000'000).c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
// Maximum speed of 20Mbit/s
|
||||
float delta = application::read_action_float(settings_adjust).value_or(std::pair{0, 0}).second * 20'000'000.f * predicted_display_period;
|
||||
|
||||
bitrate = std::clamp(bitrate + static_cast<int32_t>(delta), 1'000'000u, 200'000'000u);
|
||||
|
||||
bool ok = application::read_action_bool(foveation_ok).value_or(std::pair{0, false}).second;
|
||||
|
||||
if (ok)
|
||||
gui_status = gui_status::settings;
|
||||
|
||||
send_settings_changed_packet(session, network_session.get(), application::get_config(), bitrate, predicted_display_period);
|
||||
}
|
||||
|
||||
void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
{
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
@@ -590,7 +619,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
ImGui::PopFont();
|
||||
|
||||
// Maximum speed 1 rad/s
|
||||
float delta_pitch = application::read_action_float(foveation_pitch).value_or(std::pair{0, 0}).second * predicted_display_period;
|
||||
float delta_pitch = application::read_action_float(settings_adjust).value_or(std::pair{0, 0}).second * predicted_display_period;
|
||||
|
||||
// Maximum speed 2m/s @ 1m
|
||||
float delta_distance = std::exp(std::log(2) * application::read_action_float(foveation_distance).value_or(std::pair{0, 0}).second * predicted_display_period);
|
||||
@@ -735,6 +764,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::overlay_only:
|
||||
case gui_status::compact:
|
||||
@@ -797,6 +827,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
glm::mat3 M = glm::mat3_cast(head_position->second);
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
imgui_ctx->layers()[0].orientation = head_position->second;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, -override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
|
||||
@@ -840,6 +871,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
break;
|
||||
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Size / 2, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
always_auto_resize = true;
|
||||
@@ -914,6 +946,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::bitrate_settings:
|
||||
gui_bitrate_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
|
||||
case gui_status::foveation_settings:
|
||||
gui_foveation_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user