diff --git a/client/constants.h b/client/constants.h index 7b58c775..9a29d1c4 100644 --- a/client/constants.h +++ b/client/constants.h @@ -27,7 +27,7 @@ namespace constants::gui { // 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) constexpr const char font_name[] = "Noto Sans"; @@ -43,9 +43,10 @@ constexpr float scroll_ratio = 10; 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) -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_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI +constexpr float fingertip_distance_hovering_thd = 0.15; // Max distance to have the cursor hovering +constexpr float fingertip_distance_touching_thd_hi = -0.01; // Distance to register a click +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 constexpr float scroll_value_thd = 0.01; diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index 35af95ce..ea193387 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -237,7 +237,10 @@ std::vector> imgui_context::ray_plane_intersection(cons // => ray_start.z + distance × ray_dir.z = 0 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; coord.x = ray_start.x + distance * ray_dir.x; @@ -625,7 +628,7 @@ std::vector imgui_context::read_controllers_sta if (state.hover_distance < constants::gui::fingertip_distance_hovering_thd) 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; } } diff --git a/dashboard/io.github.wivrn.wivrn.metainfo.xml b/dashboard/io.github.wivrn.wivrn.metainfo.xml index 7306e170..faba70fb 100644 --- a/dashboard/io.github.wivrn.wivrn.metainfo.xml +++ b/dashboard/io.github.wivrn.wivrn.metainfo.xml @@ -8,28 +8,26 @@

WiVRn allows you to run your VR games from your PC and play them from a standalone headset.

-

You will need to install the WiVRn client on your headset from the Meta Store or by following the wizard in the application.

+

Works with the WiVRn client app on standalone headsets, available as an APK and on the Meta Store.

+ +

Features:

+
    +
  • Supports OpenXR and OpenVR applications through xrizer or OpenComposite
  • +
  • Controller tracking, hand tracking, eye gaze tracking, body tracking as supported by the headset
  • +
  • Audio streaming and microphone
  • +
  • Low latency video streaming with H264 / HEVC / AV1 compression
  • +
  • Hardware accelerated compression with Vulkan video encode, VAAPI or NVENC
  • +
  • Software compression with x264
  • +

Supported headsets:

    -
  • Meta Quest 1
  • -
  • Meta Quest 2
  • -
  • Meta Quest 3
  • -
  • Meta Quest 3S
  • -
  • Meta Quest Pro
  • +
  • Meta Quest 1, 2, 3, 3S, pro
  • Pico Neo 4
  • -
  • HTC Vive Focus 3
  • -
  • HTC Vive XR Elite
  • -
-

Features:

-
    -
  • Supports OpenXR and OpenVR applications
  • -
  • Controller tracking, hand tracking, eye gaze tracking (if supported by the headset)
  • -
  • Audio streaming and microphone
  • -
  • Video streaming with H264 / HEVC / AV1 compression
  • -
  • Hardware accelerated compression with VAAPI or NVENC
  • -
  • Software compression with x264
  • +
  • HTC Vive Focus 3, XR Elite
+ +

For desktop streaming, check out wlx-overlay-s.

Guillaume Meunier, Patrick Nicolas et al @@ -69,6 +67,19 @@ + + https://github.com/WiVRn/WiVRn/releases/tag/v25.11 + +
    +
  • 10-bit encoding support for AV1 and h.265
  • +
  • H.265 encoding on Vulkan video backend
  • +
  • Firewall configuration for ufw and firewalld
  • +
  • Customizable lobby environment
  • +
  • Running application management during stream
  • +
  • Default to lower power states on headset
  • +
+
+
https://github.com/WiVRn/WiVRn/releases/tag/v25.9 diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index f82cf424..0c192c18 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -26,7 +26,6 @@ #include "main/comp_main_interface.h" #include "main/comp_target.h" #include "server/ipc_server.h" -#include "target_instance_wivrn.h" #include "util/u_builders.h" #include "util/u_logging.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; } -wivrn::wivrn_session::wivrn_session(std::unique_ptr connection, instance & inst, u_system & system) : +wivrn::wivrn_session::wivrn_session(std::unique_ptr connection, u_system & system) : xrt_system_devices{ .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); }, @@ -149,7 +148,6 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr connection .destroy = [](xrt_system_devices * self) { delete ((wivrn_session *)self); }, }, connection(std::move(connection)), - inst(inst), xrt_system(system), hmd(this, get_info()), left_controller(0, &hmd, this), @@ -308,7 +306,6 @@ wivrn_session::~wivrn_session() } xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr connection, - instance & inst, u_system & system, xrt_system_devices ** out_xsysd, xrt_space_overseer ** out_xspovrs, @@ -317,7 +314,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr self; try { - self.reset(new wivrn_session(std::move(connection), inst, system)); + self.reset(new wivrn_session(std::move(connection), system)); } catch (std::exception & e) { @@ -355,11 +352,22 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptrfeedback_csv.open(dump_file); } - self->thread = std::jthread([s = self.get()](auto stop_token) { return s->run(stop_token); }); *out_xsysd = self.release(); 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() { 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) { + assert(server); U_LOG_I("Session state changed: %s", xr::to_string(event.state)); bool visible, focused; switch (event.state) @@ -688,13 +697,13 @@ void wivrn_session::operator()(from_headset::session_state_changed && event) focused = false; break; } - scoped_lock lock(inst.server->global_state.lock); - 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.server_thread_index < 0 or t.ics.xc == nullptr) continue; 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); } } @@ -785,9 +794,10 @@ void wivrn_session::operator()(const from_headset::start_app & request) 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{}; - 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) continue; @@ -801,7 +811,7 @@ void wivrn_session::operator()(const from_headset::get_running_applications &) .name = std::string(tmp.data()), .id = t.ics.client_state.id, .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)); @@ -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) { - ipc_server_set_active_client(inst.server, req.id); - ipc_server_update_state(inst.server); + assert(server); + ipc_server_set_active_client(mnd_ipc_server, req.id); + ipc_server_update_state(mnd_ipc_server); // Send a refreshed application list (*this)(from_headset::get_running_applications{}); } void wivrn_session::operator()(const from_headset::stop_application & req) { - scoped_lock lock(inst.server->global_state.lock); - for (auto & t: inst.server->threads) + assert(server); + scoped_lock lock(mnd_ipc_server->global_state.lock); + for (auto & t: mnd_ipc_server->threads) { if (t.ics.client_state.id == req.id) { @@ -1021,15 +1033,16 @@ void wivrn_session::reconnect() void wivrn_session::poll_session_loss() { + assert(server); auto locked = session_loss.lock(); auto now = os_monotonic_get_ns(); if (locked->empty()) return; 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) { - for (auto & t: inst.server->threads) + for (auto & t: mnd_ipc_server->threads) { if (t.ics.client_state.id == it->second) { diff --git a/server/driver/wivrn_session.h b/server/driver/wivrn_session.h index 9df588d9..6d430e01 100644 --- a/server/driver/wivrn_session.h +++ b/server/driver/wivrn_session.h @@ -38,6 +38,7 @@ #include #include +struct ipc_server; struct u_system; struct xrt_space_overseer; struct xrt_system_compositor; @@ -45,7 +46,6 @@ union xrt_session_event; namespace wivrn { -class instance; class wivrn_eye_tracker; class wivrn_fb_face2_tracker; class wivrn_htc_face_tracker; @@ -95,10 +95,10 @@ class wivrn_session : public xrt_system_devices { friend wivrn_comp_target_factory; std::unique_ptr connection; - instance & inst; pacing_app_factory app_pacers; u_system & xrt_system; + ipc_server * mnd_ipc_server; xrt_space_overseer * space_overseer; xrt_system_compositor * system_compositor; @@ -141,18 +141,20 @@ class wivrn_session : public xrt_system_devices std::jthread thread; - wivrn_session(std::unique_ptr connection, instance &, u_system &); + wivrn_session(std::unique_ptr connection, u_system &); public: ~wivrn_session(); static xrt_result_t create_session(std::unique_ptr connection, - instance & instance, u_system & system, xrt_system_devices ** out_xsysd, xrt_space_overseer ** out_xspovrs, xrt_system_compositor ** out_xsysc); + void start(ipc_server *); + void stop(); + clock_offset get_offset(); bool connected(); const from_headset::headset_info_packet & get_info() diff --git a/server/ipc_server_cb.cpp b/server/ipc_server_cb.cpp index a5cb2138..b17e73d5 100644 --- a/server/ipc_server_cb.cpp +++ b/server/ipc_server_cb.cpp @@ -17,6 +17,7 @@ */ #include "ipc_server_cb.h" +#include "driver/wivrn_session.h" #include "target_instance_wivrn.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) { auto inst = static_cast(xrt_inst); - inst->server = server; + inst->set_ipc_server(server); } void ipc_server_cb::mainloop_leaving(ipc_server * server, xrt_instance * xrt_inst) { auto inst = static_cast(xrt_inst); - inst->server = nullptr; + inst->set_ipc_server(nullptr); } ipc_server_cb::ipc_server_cb() : diff --git a/server/target_instance_wivrn.cpp b/server/target_instance_wivrn.cpp index 4aede1ee..da2c4cd2 100644 --- a/server/target_instance_wivrn.cpp +++ b/server/target_instance_wivrn.cpp @@ -48,11 +48,13 @@ xrt_result_t instance::create_system( struct xrt_system_compositor * xsysc = NULL; auto res = wivrn::wivrn_session::create_session( std::move(connection), - *this, *u_sys, out_xsysd, out_xspovrs, out_xsysc); + if (res != XRT_SUCCESS) + return res; + session = (wivrn_session *)*out_xsysd; u_system_set_system_compositor(u_sys, *out_xsysc); 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 xrt_result_t xrt_instance_create(struct xrt_instance_info * ii, struct xrt_instance ** out_xinst) diff --git a/server/target_instance_wivrn.h b/server/target_instance_wivrn.h index 3ddd1883..9b05925b 100644 --- a/server/target_instance_wivrn.h +++ b/server/target_instance_wivrn.h @@ -23,6 +23,7 @@ namespace wivrn { +class wivrn_session; class instance : public xrt_instance { xrt_result_t create_system( @@ -33,9 +34,11 @@ class instance : public xrt_instance xrt_result_t get_prober(xrt_prober **); + wivrn_session * session = nullptr; + public: - ipc_server * server = nullptr; using base = xrt_instance; instance(); + void set_ipc_server(ipc_server *); }; } // namespace wivrn