Search for OpenComposite and write manifest on connect

This commit is contained in:
Patrick Nicolas
2024-11-23 13:37:44 +01:00
parent 597390ab9f
commit 64d36a7927
5 changed files with 29 additions and 10 deletions
+2
View File
@@ -38,6 +38,8 @@ auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO)
auto_option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" AUTO)
auto_option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" AUTO)
set(OPENCOMPOSITE_SEARCH_PATH "/usr/local/lib:/usr/lib:/opt" CACHE STRING "List of places to search for OpenComposite, separated by :")
option(WIVRN_FEATURE_RENDERDOC "Support renderdoc" OFF)
option(WIVRN_FEATURE_SOLARXR "Enable SolarXR driver" OFF)
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF)
+1
View File
@@ -36,3 +36,4 @@
#cmakedefine01 WIVRN_CLIENT_DEBUG_MENU
#define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define OPENCOMPOSITE_SEARCH_PATH "@OPENCOMPOSITE_SEARCH_PATH@"
+14 -8
View File
@@ -46,19 +46,25 @@ std::filesystem::path active_runtime::manifest_path()
return std::filesystem::path(WIVRN_INSTALL_PREFIX) / install_location;
}
std::filesystem::path active_runtime::opencomposite_path()
{
std::filesystem::path OpenComposite = "OpenComposite";
if (auto path = flatpak_key(flatpak::section::instance, "app-path"))
return *path / OpenComposite;
for (auto path: std::ranges::split_view(std::string_view(OPENCOMPOSITE_SEARCH_PATH), std::string_view(":")))
{
if (auto res = std::string_view(path) / OpenComposite; std::filesystem::exists(res))
return res;
}
return {};
}
static std::filesystem::path backup_name(std::filesystem::path file)
{
file += ".wivrn-backup";
return file;
}
static std::filesystem::path find_opencomposite()
{
if (auto path = flatpak_key(flatpak::section::instance, "app-path"))
return *path + "/OpenComposite";
return {};
}
static void move_file(const std::filesystem::path & from, const std::filesystem::path & to)
{
if (not std::filesystem::exists(from))
@@ -85,7 +91,7 @@ active_runtime::active_runtime() :
try
{
auto opencomposite = find_opencomposite();
auto opencomposite = opencomposite_path();
if (not opencomposite.empty())
{
std::filesystem::path openvr_manifest = xdg_config_home() / "openvr/openvrpaths.vrpath";
+1
View File
@@ -38,5 +38,6 @@ public:
~active_runtime();
static std::filesystem::path manifest_path();
static std::filesystem::path opencomposite_path();
};
} // namespace wivrn
+11 -2
View File
@@ -148,17 +148,26 @@ static std::filesystem::path flatpak_app_path()
static std::string steam_command()
{
std::string pressure_vessel_filesystems_rw = "$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME;
std::string vr_override;
// Check if in a flatpak
if (is_flatpak())
{
std::string app_path = flatpak_app_path().string();
// /usr and /var are remapped by steam
if (app_path.starts_with("/usr") or app_path.starts_with("/var"))
if (app_path.starts_with("/var"))
pressure_vessel_filesystems_rw += ":" + app_path;
}
else if (auto p = active_runtime::opencomposite_path().string(); not p.empty())
{
// /usr cannot be shared in pressure vessel container
if (p.starts_with("/usr"))
vr_override = " VR_OVERRIDE=/run/host" + p;
else if (p.starts_with("/var"))
pressure_vessel_filesystems_rw += ":" + p;
}
std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + " %command%";
std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + vr_override + " %command%";
if (auto p = active_runtime::manifest_path().string(); p.starts_with("/usr"))
command = "XR_RUNTIME_JSON=/run/host" + p + " " + command;