Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-07-06 11:13:13 +00:00
16 changed files with 130 additions and 56 deletions
+3 -1
View File
@@ -153,11 +153,13 @@ jobs:
nix-test:
name: Test Nix package and devshell
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v31
- run: nix flake check
- run: nix build
+2
View File
@@ -88,6 +88,8 @@
<!-- https://developer.oculus.com/documentation/native/android/mobile-splash/ -->
<meta-data android:name="com.oculus.ossplash" android:value="true"/>
<!-- https://developers.meta.com/horizon/documentation/native/android/mobile-passthrough-loading-screens -->
<meta-data android:name="com.oculus.ossplash.background" android:value="passthrough-contextual"/>
<!-- The activity is the built-in NativeActivity framework class. -->
<!-- launchMode is set to singleTask because there should never be multiple copies of the app running. -->
+18
View File
@@ -348,6 +348,24 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
default:
break;
}
else if (profile == "meta-quest-touch-plus")
{
switch (space)
{
case xr::spaces::grip_left:
case xr::spaces::grip_right:
return {{0, -0.010, -0.025}, glm::angleAxis(glm::radians(-12.f), glm::vec3{1, 0, 0})};
case xr::spaces::aim_left:
return {{0, 0, 0.03}, {1, 0, 0, 0}};
case xr::spaces::aim_right:
return {{0, 0, 0.03}, {1, 0, 0, 0}};
default:
break;
}
}
else if (profile == "htc-vive-focus-3")
switch (space)
{
+7 -1
View File
@@ -966,6 +966,12 @@ void scenes::lobby::render(const XrFrameState & frame_state)
.depthMask = true,
.compareOp = application::get_config().passthrough_enabled ? XR_COMPARE_OP_LESS_FB : XR_COMPARE_OP_LESS_OR_EQUAL_FB,
};
XrCompositionLayerDepthTestFB layer_depth_test_bg{
.type = XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB,
.next = nullptr,
.depthMask = true,
.compareOp = XR_COMPARE_OP_ALWAYS_FB,
};
// if (composition_layer_depth_test_supported or not application::get_config().passthrough_enabled)
layers_with_z_index.emplace_back(constants::lobby::zindex_lobby, reinterpret_cast<XrCompositionLayerBaseHeader *>(&lobby_layer));
@@ -977,7 +983,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
if (composition_layer_depth_test_supported)
{
lobby_layer.next = &layer_depth_test;
lobby_layer.next = &layer_depth_test_bg;
for (auto & [z_index, layer]: imgui_layers)
{
+1 -1
View File
@@ -51,6 +51,7 @@ xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, con
static XrPassthroughFB create_passthrough_fb(xr::instance & inst, xr::session & s)
{
PFN_xrCreatePassthroughFB xrCreatePassthroughFB = inst.get_proc<PFN_xrCreatePassthroughFB>("xrCreatePassthroughFB");
xrDestroyPassthroughFB = inst.get_proc<PFN_xrDestroyPassthroughFB>("xrDestroyPassthroughFB");
XrPassthroughFB id;
XrPassthroughCreateInfoFB info{
@@ -71,7 +72,6 @@ xr::passthrough_fb::passthrough_fb(instance & inst, session & s) :
.purpose = XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB,
})
{
xrDestroyPassthroughFB = inst.get_proc<PFN_xrDestroyPassthroughFB>("xrDestroyPassthroughFB");
xrPassthroughStartFB = inst.get_proc<PFN_xrPassthroughStartFB>("xrPassthroughStartFB");
xrPassthroughPauseFB = inst.get_proc<PFN_xrPassthroughPauseFB>("xrPassthroughPauseFB");
xrPassthroughLayerPauseFB = inst.get_proc<PFN_xrPassthroughLayerPauseFB>("xrPassthroughLayerPauseFB");
+7 -1
View File
@@ -1,6 +1,12 @@
# Configurable items
Configuration is done on server side, in `$XDG_CONFIG_HOME/wivrn/config.json` or if `$XDG_CONFIG_HOME` is not set, `$HOME/.config/wivrn/config.json`.
Configuration is done on server side.
Files are read from
- `/usr/share/wivrn/config.json` (where `/usr` is selected at configure time with `CMAKE_INSTALL_PREFIX`)
- `/etc/wivrn/config.json`
- `$XDG_CONFIG_HOME/wivrn/config.json` or if `$XDG_CONFIG_HOME` is not set, `$HOME/.config/wivrn/config.json`.
Files later in the list replace top-level values from previous ones.
All elements are optional and have default values.
+1 -1
View File
@@ -76,7 +76,7 @@ std::filesystem::path active_runtime::openvr_compat_path()
return std::filesystem::path();
},
},
configuration::read_user_configuration().openvr_compat_path);
configuration().openvr_compat_path);
}
static std::filesystem::path backup_name(std::filesystem::path file)
+69 -30
View File
@@ -19,6 +19,8 @@
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include "configuration.h"
#include <algorithm>
#include <chrono>
#include <ctime>
@@ -31,10 +33,10 @@
#include "util/u_logging.h"
#include "configuration.h"
#include "utils/xdg_base_directory.h"
#include "wivrn_config.h"
static std::filesystem::path config_file = xdg_config_home() / "wivrn" / "config.json";
static std::filesystem::path config_file;
static std::filesystem::path known_keys_file = xdg_config_home() / "wivrn" / "known_keys.json";
static std::filesystem::path cookie_file = xdg_config_home() / "wivrn" / "cookie";
@@ -65,12 +67,56 @@ void configuration::set_config_file(const std::filesystem::path & path)
{
config_file = path;
}
const std::filesystem::path & configuration::get_config_file()
std::filesystem::path configuration::get_config_file()
{
if (config_file.empty())
return xdg_config_home() / "wivrn" / "config.json";
return config_file;
}
nlohmann::json configuration::read_configuration()
{
if (config_file.empty())
{
nlohmann::json merged;
for (std::filesystem::path prefix: {
std::filesystem::path(WIVRN_INSTALL_PREFIX "/share"),
std::filesystem::path("/etc"),
xdg_config_home(),
})
{
auto path = prefix / "wivrn" / "config.json";
if (std::filesystem::exists(path))
{
try
{
for (const auto & [key, value]: nlohmann::json::parse(std::ifstream(path)).get<nlohmann::json::object_t>())
{
merged[key] = value;
}
}
catch (std::exception & e)
{
U_LOG_E("Invalid configuration file %s: %s", path.c_str(), e.what());
}
}
}
return merged;
}
else
{
try
{
return nlohmann::json::parse(std::ifstream(config_file));
}
catch (std::exception & e)
{
U_LOG_E("Invalid configuration file %s: %s", config_file.c_str(), e.what());
return nlohmann::json();
}
}
}
configuration::encoder parse_encoder(const nlohmann::json & item)
{
configuration::encoder e;
@@ -94,85 +140,78 @@ configuration::encoder parse_encoder(const nlohmann::json & item)
return e;
}
configuration configuration::read_user_configuration()
configuration::configuration()
{
configuration result;
if (not std::filesystem::exists(config_file))
return result;
std::ifstream file(config_file);
try
{
auto json = nlohmann::json::parse(file);
auto json = read_configuration();
if (auto it = json.find("scale"); it != json.end())
{
if (it->is_number())
result.scale = std::array<double, 2>{*it, *it};
scale = std::array<double, 2>{*it, *it};
else
result.scale = *it;
scale = *it;
}
if (auto it = json.find("grip-surface"); it != json.end())
{
result.grip_surface = *it;
grip_surface = *it;
}
if (auto it = json.find("bitrate"); it != json.end())
result.bitrate = *it;
bitrate = *it;
if (auto it = json.find("encoders"); it != json.end())
{
for (const auto & encoder: *it)
result.encoders.push_back(parse_encoder(encoder));
encoders.push_back(parse_encoder(encoder));
}
if (auto it = json.find("encoder-passthrough"); it != json.end())
result.encoder_passthrough = parse_encoder(*it);
encoder_passthrough = parse_encoder(*it);
if (auto it = json.find("application"); it != json.end())
{
if (it->is_string())
result.application.push_back(*it);
application.push_back(*it);
else
{
for (const auto & i: *it)
result.application.push_back(i);
application.push_back(i);
}
}
if (auto it = json.find("debug-gui"); it != json.end())
result.debug_gui = *it;
debug_gui = *it;
if (auto it = json.find("use-steamvr-lh"); it != json.end())
result.use_steamvr_lh = *it;
use_steamvr_lh = *it;
if (auto it = json.find("tcp-only"); it != json.end())
result.tcp_only = *it;
tcp_only = *it;
else if (auto it = json.find("tcp_only"); it != json.end())
result.tcp_only = *it;
tcp_only = *it;
if (auto it = json.find("publish-service"); it != json.end())
{
result.publication = *it;
if (result.publication == service_publication(-1))
publication = *it;
if (publication == service_publication(-1))
throw std::runtime_error("invalid service publication " + it->get<std::string>());
}
if (auto it = json.find("openvr-compat-path"); it != json.end())
{
if (it->is_null())
result.openvr_compat_path = nullptr;
openvr_compat_path = nullptr;
else
result.openvr_compat_path = *it;
openvr_compat_path = *it;
}
}
catch (const std::exception & e)
{
U_LOG_E("Invalid configuration file: %s", e.what());
return {};
U_LOG_E("Configuration file error: %s", e.what());
}
return result;
}
std::string server_cookie()
+5 -2
View File
@@ -23,6 +23,7 @@
#include <chrono>
#include <filesystem>
#include <map>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <variant>
@@ -68,8 +69,10 @@ struct configuration
std::variant<std::monostate, std::string, std::nullptr_t> openvr_compat_path;
static void set_config_file(const std::filesystem::path &);
static const std::filesystem::path & get_config_file();
static configuration read_user_configuration();
static std::filesystem::path get_config_file();
static nlohmann::json read_configuration();
configuration();
};
std::string server_cookie();
+1 -1
View File
@@ -88,7 +88,7 @@ void wivrn::wivrn_connection::init(std::stop_token stop_token, std::function<voi
throw std::system_error(errno, std::system_category(), "Cannot get client address");
}
if (configuration::read_user_configuration().tcp_only)
if (configuration().tcp_only)
{
port = -1;
}
+1 -1
View File
@@ -572,7 +572,7 @@ wivrn_controller::wivrn_controller(int hand_id,
SET_INPUT(TOUCH, GRIP_POSE);
SET_INPUT(GENERIC, PALM_POSE);
if (auto grip_surface = configuration::read_user_configuration().grip_surface)
if (auto grip_surface = configuration().grip_surface)
{
std::array<float, 3> angles = grip_surface.value();
float deg_2_rad = std::numbers::pi / 180.0;
+1 -1
View File
@@ -89,7 +89,7 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
},
cnx(cnx)
{
const auto config = configuration::read_user_configuration();
const auto config = configuration();
auto eye_width = info.recommended_eye_width;
eye_width = ((eye_width + 3) / 4) * 4;
+1 -1
View File
@@ -179,7 +179,7 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
static_roles.hand_tracking.right = xdevs[xdev_count++] = &right_hand;
#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
auto use_steamvr_lh = configuration::read_user_configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH");
auto use_steamvr_lh = 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)
-8
View File
@@ -330,14 +330,6 @@ static uint16_t align(uint16_t value, uint16_t alignment)
std::vector<encoder_settings> get_encoder_settings(wivrn_vk_bundle & bundle, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info)
{
configuration config;
try
{
config = configuration::read_user_configuration();
}
catch (const std::exception & e)
{
U_LOG_E("Failed to read encoder configuration: %s", e.what());
}
if (config.encoders.empty())
config.encoders = get_encoder_default_settings(bundle, info.supported_codecs);
if (not config.encoder_passthrough)
+12 -6
View File
@@ -479,7 +479,7 @@ gboolean headset_connected_success(void *)
expose_known_keys_on_dbus();
start_server(configuration::read_user_configuration());
start_server(configuration());
try
{
start_app();
@@ -855,9 +855,15 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
on_headset_info_packet({});
std::ifstream file(configuration::get_config_file());
std::string config{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
std::string config;
try
{
config = configuration::read_configuration().dump();
}
catch (std::exception & e)
{
std::cerr << "Invalid configuration: " << e.what() << std::endl;
}
wivrn_server_set_json_configuration(dbus_server, config.c_str());
expose_known_keys_on_dbus();
@@ -1035,11 +1041,11 @@ int main(int argc, char * argv[])
if (*no_publish)
publication = wivrn::service_publication::none;
else
publication = configuration::read_user_configuration().publication;
publication = configuration().publication;
#if WIVRN_USE_SYSTEMD
if (*app_flag)
return exec_application(configuration::read_user_configuration());
return exec_application(configuration());
#endif
try
{
+1 -1
View File
@@ -219,7 +219,7 @@ pid_t wivrn::start_unit_file()
pid_t wivrn::fork_application()
{
auto config = configuration::read_user_configuration();
configuration config;
if (config.application.empty())
return 0;