Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-11-09 01:52:46 +00:00
8 changed files with 94 additions and 49 deletions
+5 -4
View File
@@ -27,7 +27,7 @@
namespace constants::gui namespace constants::gui
{ {
// Minimum distance between a GUI layer and a fingertip/controller to register a click // Minimum distance between a GUI layer and a fingertip/controller to register a click
constexpr float min_pointer_distance = -0.02; constexpr float min_controller_distance = -0.02;
// Font to use (desktop only) // Font to use (desktop only)
constexpr const char font_name[] = "Noto Sans"; constexpr const char font_name[] = "Noto Sans";
@@ -43,9 +43,10 @@ constexpr float scroll_ratio = 10;
constexpr float trigger_click_thd = 0.8; constexpr float trigger_click_thd = 0.8;
// Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI) // Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI)
constexpr float fingertip_distance_hovering_thd = 0.15; // Max distance to have the cursor hovering constexpr float fingertip_distance_hovering_thd = 0.15; // Max distance to have the cursor hovering
constexpr float fingertip_distance_touching_thd = -0.01; // Max distance to register a click constexpr float fingertip_distance_touching_thd_hi = -0.01; // Distance to register a click
constexpr float fingertip_distance_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI constexpr float fingertip_distance_touching_thd_lo = -0.15; // Distance to register a click
constexpr float fingertip_distance_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI
// Minimum scroll value to enable a controller // Minimum scroll value to enable a controller
constexpr float scroll_value_thd = 0.01; constexpr float scroll_value_thd = 0.01;
+5 -2
View File
@@ -237,7 +237,10 @@ std::vector<std::pair<ImVec2, float>> imgui_context::ray_plane_intersection(cons
// => ray_start.z + distance × ray_dir.z = 0 // => ray_start.z + distance × ray_dir.z = 0
float distance = -ray_start.z / ray_dir.z; float distance = -ray_start.z / ray_dir.z;
if (distance < constants::gui::min_pointer_distance) if (distance < constants::gui::min_controller_distance and in.source == ImGuiMouseSource_VRController)
continue;
if (distance < constants::gui::fingertip_distance_touching_thd_lo and in.source == ImGuiMouseSource_VRHandTracking)
continue; continue;
coord.x = ray_start.x + distance * ray_dir.x; coord.x = ray_start.x + distance * ray_dir.x;
@@ -625,7 +628,7 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
if (state.hover_distance < constants::gui::fingertip_distance_hovering_thd) if (state.hover_distance < constants::gui::fingertip_distance_hovering_thd)
state.fingertip_hovering = true; state.fingertip_hovering = true;
if (state.hover_distance < constants::gui::fingertip_distance_touching_thd) if (state.hover_distance < constants::gui::fingertip_distance_touching_thd_hi and state.hover_distance > constants::gui::fingertip_distance_touching_thd_lo)
state.fingertip_touching = true; state.fingertip_touching = true;
} }
} }
+28 -17
View File
@@ -8,28 +8,26 @@
<description> <description>
<p>WiVRn allows you to run your VR games from your PC and play them from a standalone headset.</p> <p>WiVRn allows you to run your VR games from your PC and play them from a standalone headset.</p>
<p>You will need to install the WiVRn client on your headset from the Meta Store or by following the wizard in the application.</p> <p>Works with the WiVRn client app on standalone headsets, available as an APK and on the Meta Store.</p>
<p>Features:</p>
<ul>
<li>Supports OpenXR and OpenVR applications through xrizer or OpenComposite</li>
<li>Controller tracking, hand tracking, eye gaze tracking, body tracking as supported by the headset</li>
<li>Audio streaming and microphone</li>
<li>Low latency video streaming with H264 / HEVC / AV1 compression</li>
<li>Hardware accelerated compression with Vulkan video encode, VAAPI or NVENC</li>
<li>Software compression with x264</li>
</ul>
<p>Supported headsets:</p> <p>Supported headsets:</p>
<ul> <ul>
<li>Meta Quest 1</li> <li>Meta Quest 1, 2, 3, 3S, pro</li>
<li>Meta Quest 2</li>
<li>Meta Quest 3</li>
<li>Meta Quest 3S</li>
<li>Meta Quest Pro</li>
<li>Pico Neo 4</li> <li>Pico Neo 4</li>
<li>HTC Vive Focus 3</li> <li>HTC Vive Focus 3, XR Elite</li>
<li>HTC Vive XR Elite</li>
</ul>
<p>Features:</p>
<ul>
<li>Supports OpenXR and OpenVR applications</li>
<li>Controller tracking, hand tracking, eye gaze tracking (if supported by the headset)</li>
<li>Audio streaming and microphone</li>
<li>Video streaming with H264 / HEVC / AV1 compression</li>
<li>Hardware accelerated compression with VAAPI or NVENC</li>
<li>Software compression with x264</li>
</ul> </ul>
<p>For desktop streaming, check out wlx-overlay-s.</p>
</description> </description>
<developer id="io.github.wivrn.wivrn"> <developer id="io.github.wivrn.wivrn">
<name>Guillaume Meunier, Patrick Nicolas et al</name> <name>Guillaume Meunier, Patrick Nicolas et al</name>
@@ -69,6 +67,19 @@
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="25.11" date="2025-11-08">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v25.11</url>
<description>
<ul>
<li>10-bit encoding support for AV1 and h.265</li>
<li>H.265 encoding on Vulkan video backend</li>
<li>Firewall configuration for ufw and firewalld</li>
<li>Customizable lobby environment</li>
<li>Running application management during stream</li>
<li>Default to lower power states on headset</li>
</ul>
</description>
</release>
<release version="25.9" date="2025-09-17"> <release version="25.9" date="2025-09-17">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v25.9</url> <url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v25.9</url>
<description> <description>
+31 -18
View File
@@ -26,7 +26,6 @@
#include "main/comp_main_interface.h" #include "main/comp_main_interface.h"
#include "main/comp_target.h" #include "main/comp_target.h"
#include "server/ipc_server.h" #include "server/ipc_server.h"
#include "target_instance_wivrn.h"
#include "util/u_builders.h" #include "util/u_builders.h"
#include "util/u_logging.h" #include "util/u_logging.h"
#include "util/u_system.h" #include "util/u_system.h"
@@ -141,7 +140,7 @@ bool wivrn::tracking_control_t::set_enabled(to_headset::tracking_control::id id,
return changed; return changed;
} }
wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection, instance & inst, u_system & system) : wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection, u_system & system) :
xrt_system_devices{ xrt_system_devices{
.get_roles = [](xrt_system_devices * self, xrt_system_roles * out_roles) { return ((wivrn_session *)self)->get_roles(out_roles); }, .get_roles = [](xrt_system_devices * self, xrt_system_roles * out_roles) { return ((wivrn_session *)self)->get_roles(out_roles); },
.feature_inc = [](xrt_system_devices * self, xrt_device_feature_type f) { return ((wivrn_session *)self)->feature_inc(f); }, .feature_inc = [](xrt_system_devices * self, xrt_device_feature_type f) { return ((wivrn_session *)self)->feature_inc(f); },
@@ -149,7 +148,6 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
.destroy = [](xrt_system_devices * self) { delete ((wivrn_session *)self); }, .destroy = [](xrt_system_devices * self) { delete ((wivrn_session *)self); },
}, },
connection(std::move(connection)), connection(std::move(connection)),
inst(inst),
xrt_system(system), xrt_system(system),
hmd(this, get_info()), hmd(this, get_info()),
left_controller(0, &hmd, this), left_controller(0, &hmd, this),
@@ -308,7 +306,6 @@ wivrn_session::~wivrn_session()
} }
xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connection> connection, xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connection> connection,
instance & inst,
u_system & system, u_system & system,
xrt_system_devices ** out_xsysd, xrt_system_devices ** out_xsysd,
xrt_space_overseer ** out_xspovrs, xrt_space_overseer ** out_xspovrs,
@@ -317,7 +314,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
std::unique_ptr<wivrn_session> self; std::unique_ptr<wivrn_session> self;
try try
{ {
self.reset(new wivrn_session(std::move(connection), inst, system)); self.reset(new wivrn_session(std::move(connection), system));
} }
catch (std::exception & e) catch (std::exception & e)
{ {
@@ -355,11 +352,22 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
self->feedback_csv.open(dump_file); self->feedback_csv.open(dump_file);
} }
self->thread = std::jthread([s = self.get()](auto stop_token) { return s->run(stop_token); });
*out_xsysd = self.release(); *out_xsysd = self.release();
return XRT_SUCCESS; return XRT_SUCCESS;
} }
void wivrn_session::start(ipc_server * server)
{
assert(not thread);
mnd_ipc_server = server;
thread = std::jthread([this](auto stop_token) { return run(stop_token); });
}
void wivrn_session::stop()
{
thread = std::jthread();
}
clock_offset wivrn_session::get_offset() clock_offset wivrn_session::get_offset()
{ {
return offset_est.get_offset(); return offset_est.get_offset();
@@ -671,6 +679,7 @@ void wivrn_session::operator()(from_headset::visibility_mask_changed && mask)
void wivrn_session::operator()(from_headset::session_state_changed && event) void wivrn_session::operator()(from_headset::session_state_changed && event)
{ {
assert(server);
U_LOG_I("Session state changed: %s", xr::to_string(event.state)); U_LOG_I("Session state changed: %s", xr::to_string(event.state));
bool visible, focused; bool visible, focused;
switch (event.state) switch (event.state)
@@ -688,13 +697,13 @@ void wivrn_session::operator()(from_headset::session_state_changed && event)
focused = false; focused = false;
break; break;
} }
scoped_lock lock(inst.server->global_state.lock); scoped_lock lock(mnd_ipc_server->global_state.lock);
for (auto & t: inst.server->threads) for (auto & t: mnd_ipc_server->threads)
{ {
if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr) if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr)
continue; continue;
bool current = t.ics.client_state.session_overlay or bool current = t.ics.client_state.session_overlay or
inst.server->global_state.active_client_index == t.ics.server_thread_index; mnd_ipc_server->global_state.active_client_index == t.ics.server_thread_index;
xrt_syscomp_set_state(system_compositor, t.ics.xc, visible and current, focused and current); xrt_syscomp_set_state(system_compositor, t.ics.xc, visible and current, focused and current);
} }
} }
@@ -785,9 +794,10 @@ void wivrn_session::operator()(const from_headset::start_app & request)
void wivrn_session::operator()(const from_headset::get_running_applications &) void wivrn_session::operator()(const from_headset::get_running_applications &)
{ {
scoped_lock lock(inst.server->global_state.lock); assert(server);
scoped_lock lock(mnd_ipc_server->global_state.lock);
to_headset::running_applications msg{}; to_headset::running_applications msg{};
for (auto & t: inst.server->threads) for (auto & t: mnd_ipc_server->threads)
{ {
if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr) if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr)
continue; continue;
@@ -801,7 +811,7 @@ void wivrn_session::operator()(const from_headset::get_running_applications &)
.name = std::string(tmp.data()), .name = std::string(tmp.data()),
.id = t.ics.client_state.id, .id = t.ics.client_state.id,
.overlay = t.ics.client_state.session_overlay, .overlay = t.ics.client_state.session_overlay,
.active = t.ics.server_thread_index == inst.server->global_state.active_client_index, .active = t.ics.server_thread_index == mnd_ipc_server->global_state.active_client_index,
}); });
} }
connection->send_control(std::move(msg)); connection->send_control(std::move(msg));
@@ -809,16 +819,18 @@ void wivrn_session::operator()(const from_headset::get_running_applications &)
void wivrn_session::operator()(const from_headset::set_active_application & req) void wivrn_session::operator()(const from_headset::set_active_application & req)
{ {
ipc_server_set_active_client(inst.server, req.id); assert(server);
ipc_server_update_state(inst.server); ipc_server_set_active_client(mnd_ipc_server, req.id);
ipc_server_update_state(mnd_ipc_server);
// Send a refreshed application list // Send a refreshed application list
(*this)(from_headset::get_running_applications{}); (*this)(from_headset::get_running_applications{});
} }
void wivrn_session::operator()(const from_headset::stop_application & req) void wivrn_session::operator()(const from_headset::stop_application & req)
{ {
scoped_lock lock(inst.server->global_state.lock); assert(server);
for (auto & t: inst.server->threads) scoped_lock lock(mnd_ipc_server->global_state.lock);
for (auto & t: mnd_ipc_server->threads)
{ {
if (t.ics.client_state.id == req.id) if (t.ics.client_state.id == req.id)
{ {
@@ -1021,15 +1033,16 @@ void wivrn_session::reconnect()
void wivrn_session::poll_session_loss() void wivrn_session::poll_session_loss()
{ {
assert(server);
auto locked = session_loss.lock(); auto locked = session_loss.lock();
auto now = os_monotonic_get_ns(); auto now = os_monotonic_get_ns();
if (locked->empty()) if (locked->empty())
return; return;
auto it = locked->begin(); auto it = locked->begin();
scoped_lock lock(inst.server->global_state.lock); scoped_lock lock(mnd_ipc_server->global_state.lock);
while (it != locked->end() and it->first <= now) while (it != locked->end() and it->first <= now)
{ {
for (auto & t: inst.server->threads) for (auto & t: mnd_ipc_server->threads)
{ {
if (t.ics.client_state.id == it->second) if (t.ics.client_state.id == it->second)
{ {
+6 -4
View File
@@ -38,6 +38,7 @@
#include <shared_mutex> #include <shared_mutex>
#include <thread> #include <thread>
struct ipc_server;
struct u_system; struct u_system;
struct xrt_space_overseer; struct xrt_space_overseer;
struct xrt_system_compositor; struct xrt_system_compositor;
@@ -45,7 +46,6 @@ union xrt_session_event;
namespace wivrn namespace wivrn
{ {
class instance;
class wivrn_eye_tracker; class wivrn_eye_tracker;
class wivrn_fb_face2_tracker; class wivrn_fb_face2_tracker;
class wivrn_htc_face_tracker; class wivrn_htc_face_tracker;
@@ -95,10 +95,10 @@ class wivrn_session : public xrt_system_devices
{ {
friend wivrn_comp_target_factory; friend wivrn_comp_target_factory;
std::unique_ptr<wivrn_connection> connection; std::unique_ptr<wivrn_connection> connection;
instance & inst;
pacing_app_factory app_pacers; pacing_app_factory app_pacers;
u_system & xrt_system; u_system & xrt_system;
ipc_server * mnd_ipc_server;
xrt_space_overseer * space_overseer; xrt_space_overseer * space_overseer;
xrt_system_compositor * system_compositor; xrt_system_compositor * system_compositor;
@@ -141,18 +141,20 @@ class wivrn_session : public xrt_system_devices
std::jthread thread; std::jthread thread;
wivrn_session(std::unique_ptr<wivrn_connection> connection, instance &, u_system &); wivrn_session(std::unique_ptr<wivrn_connection> connection, u_system &);
public: public:
~wivrn_session(); ~wivrn_session();
static xrt_result_t create_session(std::unique_ptr<wivrn_connection> connection, static xrt_result_t create_session(std::unique_ptr<wivrn_connection> connection,
instance & instance,
u_system & system, u_system & system,
xrt_system_devices ** out_xsysd, xrt_system_devices ** out_xsysd,
xrt_space_overseer ** out_xspovrs, xrt_space_overseer ** out_xspovrs,
xrt_system_compositor ** out_xsysc); xrt_system_compositor ** out_xsysc);
void start(ipc_server *);
void stop();
clock_offset get_offset(); clock_offset get_offset();
bool connected(); bool connected();
const from_headset::headset_info_packet & get_info() const from_headset::headset_info_packet & get_info()
+3 -2
View File
@@ -17,6 +17,7 @@
*/ */
#include "ipc_server_cb.h" #include "ipc_server_cb.h"
#include "driver/wivrn_session.h"
#include "target_instance_wivrn.h" #include "target_instance_wivrn.h"
#include "utils/method.h" #include "utils/method.h"
@@ -29,13 +30,13 @@ void ipc_server_cb::init_failed(xrt_result res)
void ipc_server_cb::mainloop_entering(ipc_server * server, xrt_instance * xrt_inst) void ipc_server_cb::mainloop_entering(ipc_server * server, xrt_instance * xrt_inst)
{ {
auto inst = static_cast<wivrn::instance *>(xrt_inst); auto inst = static_cast<wivrn::instance *>(xrt_inst);
inst->server = server; inst->set_ipc_server(server);
} }
void ipc_server_cb::mainloop_leaving(ipc_server * server, xrt_instance * xrt_inst) void ipc_server_cb::mainloop_leaving(ipc_server * server, xrt_instance * xrt_inst)
{ {
auto inst = static_cast<wivrn::instance *>(xrt_inst); auto inst = static_cast<wivrn::instance *>(xrt_inst);
inst->server = nullptr; inst->set_ipc_server(nullptr);
} }
ipc_server_cb::ipc_server_cb() : ipc_server_cb::ipc_server_cb() :
+12 -1
View File
@@ -48,11 +48,13 @@ xrt_result_t instance::create_system(
struct xrt_system_compositor * xsysc = NULL; struct xrt_system_compositor * xsysc = NULL;
auto res = wivrn::wivrn_session::create_session( auto res = wivrn::wivrn_session::create_session(
std::move(connection), std::move(connection),
*this,
*u_sys, *u_sys,
out_xsysd, out_xsysd,
out_xspovrs, out_xspovrs,
out_xsysc); out_xsysc);
if (res != XRT_SUCCESS)
return res;
session = (wivrn_session *)*out_xsysd;
u_system_set_system_compositor(u_sys, *out_xsysc); u_system_set_system_compositor(u_sys, *out_xsysc);
return res; return res;
} }
@@ -73,6 +75,15 @@ instance::instance() :
{ {
} }
void instance::set_ipc_server(ipc_server * server)
{
assert(session);
if (server)
session->start(server);
else
session->stop();
}
} // namespace wivrn } // namespace wivrn
xrt_result_t xrt_result_t
xrt_instance_create(struct xrt_instance_info * ii, struct xrt_instance ** out_xinst) xrt_instance_create(struct xrt_instance_info * ii, struct xrt_instance ** out_xinst)
+4 -1
View File
@@ -23,6 +23,7 @@
namespace wivrn namespace wivrn
{ {
class wivrn_session;
class instance : public xrt_instance class instance : public xrt_instance
{ {
xrt_result_t create_system( xrt_result_t create_system(
@@ -33,9 +34,11 @@ class instance : public xrt_instance
xrt_result_t get_prober(xrt_prober **); xrt_result_t get_prober(xrt_prober **);
wivrn_session * session = nullptr;
public: public:
ipc_server * server = nullptr;
using base = xrt_instance; using base = xrt_instance;
instance(); instance();
void set_ipc_server(ipc_server *);
}; };
} // namespace wivrn } // namespace wivrn