Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-08-08 23:15:07 +00:00
27 changed files with 8987 additions and 333 deletions
+25 -3
View File
@@ -28,6 +28,7 @@
#include "util/u_builders.h"
#include "util/u_logging.h"
#include "util/u_system.h"
#include "utils/load_icon.h"
#include "utils/scoped_lock.h"
#include "audio/audio_setup.h"
@@ -171,6 +172,12 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
throw;
}
(*this)(from_headset::get_application_list{
.language = get_info().language,
.country = get_info().country,
.variant = get_info().variant,
});
static_roles.head = xdevs[xdev_count++] = &hmd;
if (hmd.supported.face_tracking)
@@ -736,15 +743,30 @@ void wivrn_session::operator()(from_headset::get_application_list && request)
.country = std::move(request.country),
.variant = std::move(request.variant),
};
for (auto && [id, app]: list_applications())
auto apps = list_applications();
for (const auto & [id, app]: apps)
{
response.applications.emplace_back(
std::move(id),
// FIXME: use locale
app.name.at(""),
app.image);
app.name.at(""));
}
send_control(std::move(response));
for (const auto & [id, app]: apps)
{
if (app.icon_path)
{
auto icon = load_icon(*app.icon_path, 256);
send_control(to_headset::application_icon{
.id = id,
.image = std::move(icon),
});
}
}
}
void wivrn_session::operator()(const from_headset::start_app & request)
+26 -31
View File
@@ -18,7 +18,6 @@
#include "hostname.h"
#include "protocol_version.h"
#include "start_application.h"
#include "utils/flatpak.h"
#include "utils/overloaded.h"
#include "version.h"
#include "wivrn_config.h"
@@ -128,46 +127,37 @@ int create_listen_socket()
return fd;
}
static std::filesystem::path flatpak_app_path()
static bool pressure_vessel_openxr_support()
{
if (auto value = flatpak_key(flatpak::section::instance, "app-path"))
{
std::filesystem::path path = *value;
while (path != "" and path != path.parent_path() and path.filename() != "io.github.wivrn.wivrn")
path = path.parent_path();
auto pv_var = std::getenv("PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES");
return pv_var and pv_var == std::string_view("1");
}
return path;
}
return "/";
static void append_delim(std::string & to, std::string_view what, char delim)
{
if (not to.empty())
to += delim;
to += what;
}
static std::string steam_command()
{
std::string pressure_vessel_filesystems_rw = "$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME;
std::string vr_override;
std::string command;
// 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("/var"))
pressure_vessel_filesystems_rw += ":" + app_path;
}
else if (auto p = active_runtime::openvr_compat_path().string(); not p.empty())
if (not pressure_vessel_openxr_support())
command = "PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES=1";
if (auto p = active_runtime::openvr_compat_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;
append_delim(command, " VR_OVERRIDE=/run/host" + p, ' ');
else if (p.starts_with("/var"))
pressure_vessel_filesystems_rw += ":" + p;
append_delim(command, "PRESSURE_VESSEL_FILESYSTEMS_RW=" + p, ' ');
}
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;
if (not command.empty())
command += " %command%";
return command;
}
@@ -688,14 +678,18 @@ void on_json_configuration(WivrnServer * server, const GParamSpec * pspec, gpoin
std::filesystem::path config_new = config;
config_new += ".new";
std::ofstream file(config_new);
file.write(json, strlen(json));
{
std::ofstream file(config_new);
file.write(json, strlen(json));
}
std::error_code ec;
std::filesystem::rename(config_new, config, ec);
if (ec)
std::cerr << "Failed to save configuration: " << ec.message() << std::endl;
wivrn_server_set_steam_command(dbus_server, steam_command().c_str());
}
void expose_known_keys_on_dbus()
@@ -884,7 +878,8 @@ int inner_main(int argc, char * argv[], bool show_instructions)
std::cerr << "WiVRn " << wivrn::git_version << " starting" << std::endl;
if (show_instructions)
{
std::cerr << "For Steam games, set command to " << steam_command() << std::endl;
if (auto command = steam_command(); not command.empty())
std::cerr << "For Steam games, set command to " << command << std::endl;
}
std::filesystem::create_directories(socket_path().parent_path());