Rebase almost everything to Master

This commit is contained in:
Vindicus999
2025-09-25 09:16:54 -04:00
parent 492ed88ae2
commit cf3c364b42
129 changed files with 13067 additions and 4431 deletions
+68 -34
View File
@@ -35,11 +35,13 @@
#include "utils/overloaded.h"
#include "utils/ranges.h"
#include "version.h"
#include "xr/body_tracker.h"
#include <algorithm>
#include <cassert>
#include <chrono>
#include <filesystem>
#include <glm/gtc/quaternion.hpp>
#include <imspinner.h>
#include <ranges>
#include <spdlog/fmt/fmt.h>
#include <string>
@@ -246,6 +248,7 @@ void scenes::lobby::gui_connecting(locked_notifiable<pin_request_data> & pin_req
if (next_scene)
{
current_tab = tab::connected;
timestamp_start_application.reset();
ImGui::CloseCurrentPopup();
return;
}
@@ -376,7 +379,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
imgui_ctx->vibrate_on_hover();
}
void scenes::lobby::gui_connected()
void scenes::lobby::gui_connected(XrTime predicted_display_time)
{
if (not next_scene)
{
@@ -401,14 +404,17 @@ void scenes::lobby::gui_connected()
auto apps = next_scene->get_applications();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {20, 20});
if (apps->applications.empty())
if (apps->empty())
{
CenterTextHV(_("Start an application on the server to start streaming."));
}
else
{
bool app_starting = timestamp_start_application and (predicted_display_time - *timestamp_start_application < 10'000'000'000);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {20, 0});
ImGui::BeginChild("Main", ImGui::GetWindowSize() - ImGui::GetCursorPos() - ImVec2(0, disconnect_size.y + 80), 0);
ImGui::BeginDisabled(app_starting);
ImGui::BeginChild("Main", ImGui::GetWindowSize() - ImGui::GetCursorPos() - ImVec2(0, disconnect_size.y + 80), 0, app_starting ? ImGuiWindowFlags_NoScrollWithMouse : 0);
ImGui::Indent(20);
if (server_name.empty())
@@ -427,7 +433,7 @@ void scenes::lobby::gui_connected()
ImGui::Indent((usable_window_width - icon_line_width) / 2);
auto t0 = std::chrono::steady_clock::now();
for (const auto [index, app]: utils::enumerate(apps->applications))
for (const auto [index, app]: utils::enumerate(*apps))
{
ImTextureID texture = [&]() -> ImTextureID {
if (app.image.empty())
@@ -458,8 +464,11 @@ void scenes::lobby::gui_connected()
}();
ImGui::PushStyleColor(ImGuiCol_Button, 0);
if (icon(app.name + "##" + app.id, texture, {256, 256}, 0, {icon_width, 0}))
if (icon(app.name + "##" + app.id, texture, {256, 256}, ImGuiButtonFlags_PressedOnClickRelease, {icon_width, 0}))
{
timestamp_start_application = predicted_display_time;
next_scene->start_application(app.id);
}
imgui_ctx->vibrate_on_hover();
ImGui::PopStyleColor(); // ImGuiCol_Button
@@ -471,7 +480,7 @@ void scenes::lobby::gui_connected()
std::vector<std::pair<std::string, ImTextureID>> to_be_removed;
for (const auto & [app_id, app_icon]: app_icons)
{
if (not std::ranges::contains(apps->applications, app_id, &to_headset::application_list::application::id))
if (not std::ranges::contains(*apps, app_id, &scenes::stream::app::id))
to_be_removed.emplace_back(app_id, app_icon);
}
for (const auto & [app_id, app_icon]: to_be_removed)
@@ -482,12 +491,26 @@ void scenes::lobby::gui_connected()
ScrollWhenDragging();
ImGui::EndChild();
ImGui::EndDisabled();
if (app_starting)
{
ImGui::SetCursorPos(ImGui::GetWindowSize() / 2 - ImVec2{200, 200} - ImGui::GetStyle().FramePadding);
ImSpinner::SpinnerAng("App starting spinner",
200, // Radius
40, // Thickness
ImColor{1.f, 1.f, 1.f, 1.f}, // Colour
ImColor{1.f, 1.f, 1.f, 0.f}, // Background
6, // Velocity
0.75f * 2 * M_PI // Angle
);
}
ImGui::PopStyleVar(); // ImGuiStyleVar_WindowPadding
}
ImGui::PopStyleVar();
ImGui::SetCursorPosX(ImGui::GetWindowSize().x - disconnect_size.x - 50);
ImGui::SetCursorPosY(ImGui::GetWindowSize().y - disconnect_size.y - 50);
ImGui::SetCursorPos(ImGui::GetWindowSize() - disconnect_size - ImVec2{50, 50});
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.2f, 0.2f, 0.40f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.2f, 0.2f, 1.00f));
@@ -905,7 +928,7 @@ void scenes::lobby::gui_settings()
ImGui::EndDisabled();
}
{
ImGui::BeginDisabled(not application::get_hand_tracking_supported());
ImGui::BeginDisabled(not system.hand_tracking_supported());
bool enabled = config.check_feature(feature::hand_tracking);
if (ImGui::Checkbox(_S("Enable hand tracking"), &enabled))
{
@@ -929,7 +952,7 @@ void scenes::lobby::gui_settings()
ImGui::EndDisabled();
}
{
ImGui::BeginDisabled(not application::get_face_tracking_supported());
ImGui::BeginDisabled(std::holds_alternative<std::monostate>(face_tracker));
bool enabled = config.check_feature(feature::face_tracking);
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
{
@@ -941,8 +964,9 @@ void scenes::lobby::gui_settings()
imgui_ctx->vibrate_on_hover();
}
auto body_tracker = system.body_tracker_supported();
{
ImGui::BeginDisabled(not application::get_body_tracking_supported());
ImGui::BeginDisabled(body_tracker == xr::body_tracker_type::none);
bool enabled = config.check_feature(feature::body_tracking);
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
{
@@ -957,19 +981,14 @@ void scenes::lobby::gui_settings()
}
else
{
std::visit(utils::overloaded{
[](auto &) {},
[this](xr::fb_body_tracker &) {
imgui_ctx->tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
},
},
application::get_body_tracker());
if (body_tracker == xr::body_tracker_type::fb)
imgui_ctx->tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
}
}
imgui_ctx->vibrate_on_hover();
}
if (std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
if (body_tracker == xr::body_tracker_type::fb)
{
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
ImGui::Indent();
@@ -995,7 +1014,7 @@ void scenes::lobby::gui_settings()
ImGui::EndDisabled();
}
ImGui::BeginDisabled(passthrough_supported == xr::system::passthrough_type::no_passthrough);
ImGui::BeginDisabled(system.passthrough_supported() == xr::passthrough_type::none);
if (ImGui::Checkbox(_S("Enable video passthrough in lobby"), &config.passthrough_enabled))
{
setup_passthrough();
@@ -1006,6 +1025,13 @@ void scenes::lobby::gui_settings()
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
ImGui::EndDisabled();
{
ImGui::Checkbox(_S("Enable in-stream window"), &config.enable_stream_gui);
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Enables the configuration window to be shown while the game is streaming.\nIf enabled, the window is activated by pressing both thumbsticks."));
}
ImGui::PopStyleVar(); // ImGuiStyleVar_ItemSpacing
}
@@ -1237,12 +1263,12 @@ void scenes::lobby::gui_first_run()
item{
.f = feature::face_tracking,
.text = _S("Enable face tracking?"),
.supported = application::get_face_tracking_supported(),
.supported = not std::holds_alternative<std::monostate>(face_tracker),
},
item{
.f = feature::body_tracking,
.text = _S("Enable body tracking?"),
.supported = application::get_body_tracking_supported(),
.supported = system.body_tracker_supported() != xr::body_tracker_type::none,
},
};
@@ -1572,11 +1598,22 @@ static auto face_weights()
return res;
}
static const char * get_face_icon(XrTime predicted_display_time)
static const char * get_face_icon(XrTime predicted_display_time, xr::face_tracker & face_tracker)
{
static const auto w = face_weights();
wivrn::from_headset::tracking::fb_face2 expression;
std::get<xr::fb_face_tracker2>(application::get_face_tracker()).get_weights(predicted_display_time, expression);
const char * result = nullptr;
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](xr::htc_face_tracker &) { result = ICON_FA_FACE_SMILE_WINK; },
[&](auto & ft) {
ft.get_weights(predicted_display_time, expression);
},
},
face_tracker);
if (result)
return result;
if (not expression.is_valid)
return ICON_FA_FACE_MEH;
@@ -1619,7 +1656,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
.icon_disabled = ICON_FA_MICROPHONE_SLASH,
});
if (application::get_hand_tracking_supported())
if (system.hand_tracking_supported())
{
items.push_back({
.f = feature::hand_tracking,
@@ -1640,21 +1677,18 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
});
}
if (application::get_face_tracking_supported())
if (not std::holds_alternative<std::monostate>(face_tracker))
{
const char * icon_enabled = std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker())
? get_face_icon(predicted_display_time)
: ICON_FA_FACE_KISS_WINK_HEART;
items.push_back({
.f = feature::face_tracking,
.tooltip_enabled = _("Face tracking is enabled"),
.tooltip_disabled = _("Face tracking is disabled"),
.icon_enabled = icon_enabled,
.icon_enabled = get_face_icon(predicted_display_time, face_tracker),
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
});
}
if (application::get_body_tracking_supported())
if (system.body_tracker_supported() != xr::body_tracker_type::none)
{
items.push_back({
.f = feature::body_tracking,
@@ -1728,7 +1762,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
if (*status.charge > 0.995)
icon_nr = 5;
else
icon_nr = application::now() / 500'000'000 % 5;
icon_nr = instance.now() / 500'000'000 % 5;
}
else
icon_nr = std::round((*status.charge) * 4);
@@ -1845,7 +1879,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {10, 10});
ImGui::Begin("WiVRn", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
gui_connected();
gui_connected(predicted_display_time);
ImGui::End();
ImGui::PopStyleVar(3); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding, ImGuiStyleVar_FramePadding
}
@@ -1957,7 +1991,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
if (not is_gui_visible(*imgui_ctx, predicted_display_time))
{
if (application::get_hand_tracking_supported())
if (system.hand_tracking_supported())
display_recentering_tip(*imgui_ctx, _("Press the grip button or put your palm up\nto move the main window"));
else
display_recentering_tip(*imgui_ctx, _("Press the grip button to move the main window"));