From b29abf073ed7eb94fb34210328d395d670aec7bb Mon Sep 17 00:00:00 2001 From: Sapphire Date: Tue, 20 May 2025 15:37:23 -0500 Subject: [PATCH] Fix call to ipc_server_main, add config options for debug GUI and steamvr_lh * Add config option for SteamVR lighthouse device support * Add dashboard toggles for debug window and steamvr_lh * clang-format * Hide advanced toggles if not enabled during build --- dashboard/gui_config.h.in | 3 +++ dashboard/qml/SettingsPage.qml | 23 ++++++++++++++++++ dashboard/settings.cpp | 42 +++++++++++++++++++++++++++++++++ dashboard/settings.h | 8 +++++++ server/driver/configuration.cpp | 6 +++++ server/driver/configuration.h | 2 ++ server/driver/wivrn_session.cpp | 3 ++- server/main.cpp | 21 ++++++++++++----- 8 files changed, 101 insertions(+), 7 deletions(-) diff --git a/dashboard/gui_config.h.in b/dashboard/gui_config.h.in index 7b087278..64c52003 100644 --- a/dashboard/gui_config.h.in +++ b/dashboard/gui_config.h.in @@ -21,6 +21,9 @@ #cmakedefine01 WIVRN_CHECK_CAPSYSNICE +#cmakedefine01 WIVRN_FEATURE_DEBUG_GUI +#cmakedefine01 WIVRN_FEATURE_STEAMVR_LIGHTHOUSE + #cmakedefine01 WIVRN_USE_NVENC #cmakedefine01 WIVRN_USE_VAAPI #cmakedefine01 WIVRN_USE_VULKAN_ENCODE diff --git a/dashboard/qml/SettingsPage.qml b/dashboard/qml/SettingsPage.qml index edeb59fa..78c87ac8 100644 --- a/dashboard/qml/SettingsPage.qml +++ b/dashboard/qml/SettingsPage.qml @@ -316,6 +316,22 @@ Kirigami.ScrollablePage { Kirigami.FormData.isSection: true } + Kirigami.Heading { + text: i18n("Advanced options") + level: 1 + type: Kirigami.Heading.Type.Primary + } + Controls.CheckBox { + id: debug_gui + text: i18n("Enable debug window") + visible: config.debug_gui_supported + } + Controls.CheckBox { + id: steamvr_lh + text: i18n("Enable SteamVR tracked devices support") + visible: config.steamvr_lh_supported + } + Controls.CheckBox { id: adb_custom Layout.row: 0 @@ -452,6 +468,9 @@ Kirigami.ScrollablePage { settings.adb_custom = adb_custom.checked; settings.adb_location = adb_location.text; Adb.setPath(adb_custom.checked ? adb_location.text : "adb"); + + config.debugGui = debug_gui.checked; + config.steamVrLh = steamvr_lh.checked; } function load() { @@ -471,6 +490,10 @@ Kirigami.ScrollablePage { // auto_encoders.checked = true; encoder_layout.currentIndex = 0; } + + debug_gui.checked = config.debugGui; + steamvr_lh.checked = config.steamVrLh; + openvr_combobox.load() adb_custom.checked = settings.adb_custom; diff --git a/dashboard/settings.cpp b/dashboard/settings.cpp index 7dbecc50..b0e59d1b 100644 --- a/dashboard/settings.cpp +++ b/dashboard/settings.cpp @@ -19,6 +19,7 @@ #include "settings.h" #include "escape_string.h" +#include "gui_config.h" #include "utils/flatpak.h" #include "wivrn_server.h" #include @@ -213,6 +214,25 @@ void Settings::load(const wivrn_server * server) set_application(""); } + // Advanced options (debug window, steamvr_lh) + try + { + set_debugGui(json_doc.value("debug-gui", false)); + } + catch (...) + { + set_debugGui(false); + } + + try + { + set_steamVrLh(json_doc.value("use-steamvr-lh", false)); + } + catch (...) + { + set_steamVrLh(false); + } + // OpenVR compat library try { @@ -298,6 +318,9 @@ void Settings::save(wivrn_server * server) if (application() != "") json_doc["application"] = unescape_string(application()); + json_doc["debug-gui"] = debugGui(); + json_doc["use-steamvr-lh"] = steamVrLh(); + if (openvr() == "-") json_doc["openvr-compat-path"] = nullptr; else if (openvr() == "") @@ -315,6 +338,8 @@ void Settings::restore_defaults() set_bitrate(50'000'000); set_scale(-1); set_application(""); + set_debugGui(false); + set_steamVrLh(false); set_tcpOnly(false); } @@ -347,4 +372,21 @@ bool Settings::flatpak() const return wivrn::is_flatpak(); } +bool Settings::debug_gui() const +{ +#if WIVRN_FEATURE_DEBUG_GUI + return true; +#else + return false; +#endif +} +bool Settings::steamvr_lh() const +{ +#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE + return true; +#else + return false; +#endif +} + #include "moc_settings.cpp" diff --git a/dashboard/settings.h b/dashboard/settings.h index 11948896..9a5e667c 100644 --- a/dashboard/settings.h +++ b/dashboard/settings.h @@ -122,10 +122,14 @@ class Settings : public QObject Q_PROPERTY(int bitrate READ bitrate WRITE set_bitrate NOTIFY bitrateChanged) Q_PROPERTY(float scale READ scale WRITE set_scale NOTIFY scaleChanged) Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged) + Q_PROPERTY(bool debugGui READ debugGui WRITE set_debugGui NOTIFY debugGuiChanged) + Q_PROPERTY(bool steamVrLh READ steamVrLh WRITE set_steamVrLh NOTIFY steamVrLhChanged) Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged) Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged) Q_PROPERTY(bool flatpak READ flatpak CONSTANT) + Q_PROPERTY(bool debug_gui_supported READ debug_gui CONSTANT) + Q_PROPERTY(bool steamvr_lh_supported READ steamvr_lh CONSTANT) SETTER_GETTER_NOTIFY(bool, manualEncoders) SETTER_GETTER_NOTIFY(std::vector, encoders) @@ -133,6 +137,8 @@ class Settings : public QObject SETTER_GETTER_NOTIFY(int, bitrate) SETTER_GETTER_NOTIFY(float, scale) SETTER_GETTER_NOTIFY(QString, application) + SETTER_GETTER_NOTIFY(bool, debugGui) + SETTER_GETTER_NOTIFY(bool, steamVrLh) SETTER_GETTER_NOTIFY(bool, tcpOnly) SETTER_GETTER_NOTIFY(QString, openvr) @@ -146,6 +152,8 @@ public: Q_INVOKABLE void set_encoder_preset(QJSValue preset); bool flatpak() const; + bool debug_gui() const; + bool steamvr_lh() const; static std::optional encoder_id_from_string(std::string_view s); static std::optional codec_id_from_string(std::string_view s); diff --git a/server/driver/configuration.cpp b/server/driver/configuration.cpp index 7839b28d..2f7fc4b6 100644 --- a/server/driver/configuration.cpp +++ b/server/driver/configuration.cpp @@ -140,6 +140,12 @@ configuration configuration::read_user_configuration() } } + if (auto it = json.find("debug-gui"); it != json.end()) + result.debug_gui = *it; + + if (auto it = json.find("use-steamvr-lh"); it != json.end()) + result.use_steamvr_lh = *it; + if (auto it = json.find("tcp-only"); it != json.end()) result.tcp_only = *it; else if (auto it = json.find("tcp_only"); it != json.end()) diff --git a/server/driver/configuration.h b/server/driver/configuration.h index d3363b60..86eea9de 100644 --- a/server/driver/configuration.h +++ b/server/driver/configuration.h @@ -59,6 +59,8 @@ struct configuration std::optional> scale; std::optional> grip_surface; std::vector application; + bool debug_gui = false; + bool use_steamvr_lh = false; bool tcp_only = false; service_publication publication = service_publication::avahi; diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 65833517..e884ff02 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -20,6 +20,7 @@ #include "wivrn_session.h" #include "accept_connection.h" +#include "configuration.h" #include "driver/app_pacer.h" #include "main/comp_compositor.h" #include "main/comp_main_interface.h" @@ -169,7 +170,7 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr connection static_roles.hand_tracking.right = xdevs[xdev_count++] = &right_hand; #if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE - auto use_steamvr_lh = std::getenv("WIVRN_USE_STEAMVR_LH"); + auto use_steamvr_lh = configuration::read_user_configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH"); xrt_system_devices * lhdevs = NULL; if (use_steamvr_lh && steamvr_lh_create_devices(&lhdevs) == XRT_SUCCESS) diff --git a/server/main.cpp b/server/main.cpp index 410afbd2..22e90386 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -57,9 +58,6 @@ U_TRACE_TARGET_SETUP(U_TRACE_WHICH_SERVICE) extern "C" { - int - ipc_server_main(int argc, char * argv[]); - int listen_socket = -1; } @@ -267,7 +265,7 @@ void start_app() } } -void start_server() +void start_server(configuration config) { server_pid = do_fork ? fork() : 0; @@ -298,9 +296,20 @@ void start_server() setenv("AMD_DEBUG", "lowlatencyenc", false); + ipc_server_main_info server_info{ + .udgci = { + .window_title = "WiVRn", +#if WIVRN_FEATURE_DEBUG_GUI + .open = config.debug_gui ? U_DEBUG_GUI_OPEN_ALWAYS : U_DEBUG_GUI_OPEN_AUTO, +#else + .open = U_DEBUG_GUI_OPEN_NEVER, +#endif + }, + }; + try { - exit(ipc_server_main(0, 0 /*argc, argv*/)); + exit(ipc_server_main(0, 0, &server_info /*argc, argv, ismi*/)); } catch (std::exception & e) { @@ -472,7 +481,7 @@ gboolean headset_connected_success(void *) expose_known_keys_on_dbus(); - start_server(); + start_server(configuration::read_user_configuration()); start_app(); delay_next_try = default_delay_next_try;