Update Monado

This commit is contained in:
Sapphire
2026-08-01 20:37:14 +02:00
committed by xytovl
parent a6da4e6dc9
commit 4749c15aa4
7 changed files with 47 additions and 49 deletions
+1
View File
@@ -1380,6 +1380,7 @@ void scenes::stream::on_xr_event(const xr::event & event)
case XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT:
network_session->send_control(from_headset::user_presence_changed{
.present = (bool)event.user_presence_changed.isUserPresent,
.change_time = instance.now(),
});
break;
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED:
+1
View File
@@ -650,6 +650,7 @@ struct session_state_changed
struct user_presence_changed
{
bool present;
XrTime change_time;
};
struct stream_tab_changed
+1 -1
View File
@@ -61,7 +61,7 @@
# Keep in sync with CMakeLists.txt monado rev
rev = lib.strings.trim (builtins.readFile ./monado-rev);
# Nix will output the correct hash when it doesn't match
hash = "sha256-3PtR4K73gKsgHce72W8EM+jWNJE0YRDKrqnu9RXX24g=";
hash = "sha256-kiYBTF65q95yBr2ol/1Gyhgr7Ml14jqavSOOvfXLsVo=";
};
};
+1 -1
View File
@@ -1 +1 @@
5b85faa0443c2259b4a1f1c65022982527815236
5dbe934da3395df7f543f653a43fc325219705fa
+25 -18
View File
@@ -76,22 +76,20 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
.serial = "WiVRn HMD",
.hmd = &hmd_parts,
.tracking_origin = &tracking_origin,
.input_count = 1,
.inputs = &pose_input,
.supported = {
.orientation_tracking = true,
.position_tracking = true,
.presence = info.user_presence,
.battery_status = true,
},
.update_inputs = [](xrt_device *) { return XRT_SUCCESS; },
.update_inputs = method_pointer<&wivrn_hmd::update_inputs>,
.get_tracked_pose = method_pointer<&wivrn_hmd::get_tracked_pose>,
.get_presence = method_pointer<&wivrn_hmd::get_presence>,
.get_view_poses = method_pointer<&wivrn_hmd::get_view_poses>,
.get_visibility_mask = method_pointer<&wivrn_hmd::get_visibility_mask>,
.get_battery_status = method_pointer<&wivrn_hmd::get_battery_status>,
.destroy = [](xrt_device *) {},
},
presence(true, os_monotonic_get_ns()),
cnx(cnx)
{
const auto config = configuration();
@@ -101,6 +99,13 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
auto eye_height = info.render_eye_height;
eye_height = ((eye_height + 3) / 4) * 4;
inputs_array.emplace_back(true, 0, XRT_INPUT_GENERIC_HEAD_POSE);
if (info.user_presence)
inputs_array.emplace_back(true, presence.get_unsafe().change_time, XRT_INPUT_GENERIC_HEAD_DETECT);
input_count = inputs_array.size();
inputs = inputs_array.data();
// Setup info.
hmd->view_count = 2;
hmd->blend_modes[hmd->blend_mode_count++] = XRT_BLEND_MODE_OPAQUE;
@@ -127,6 +132,18 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
hmd->distortion.fov[1] = xrt_cast(info.fov[1]);
}
xrt_result_t wivrn_hmd::update_inputs()
{
if (not supported.presence)
return XRT_SUCCESS;
auto p = presence.lock();
xrt_input & input = inputs_array.at(1);
input.value.boolean = p->value;
input.timestamp = p->change_time;
return XRT_SUCCESS;
}
xrt_result_t wivrn_hmd::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * res)
{
if (name != XRT_INPUT_GENERIC_HEAD_POSE)
@@ -154,13 +171,6 @@ void wivrn_hmd::update_battery(const from_headset::battery & new_battery)
*battery.lock() = new_battery;
}
xrt_result_t wivrn_hmd::get_presence(bool * out_presence)
{
*out_presence = presence;
return XRT_SUCCESS;
}
xrt_result_t wivrn_hmd::get_view_poses(const xrt_vec3 * default_eye_relation,
int64_t at_timestamp_ns,
xrt_view_type view_type,
@@ -238,13 +248,10 @@ void wivrn_hmd::update_visibility_mask(const from_headset::visibility_mask_chang
m->at(mask.view_index) = mask.data;
}
bool wivrn_hmd::update_presence(bool new_presence)
void wivrn_hmd::update_presence(bool new_presence, int64_t timestamp)
{
if (this->presence.exchange(new_presence) != new_presence)
{
U_LOG_I("user presence changed to %s", new_presence ? "true" : "false");
return true;
}
return false;
auto p = presence.lock();
p->value = new_presence;
p->change_time = timestamp;
}
} // namespace wivrn
+12 -7
View File
@@ -24,6 +24,8 @@
#include "xrt/xrt_device.h"
#include "xrt/xrt_tracking.h"
#include <inplace_vector.hpp>
#include "view_list.h"
#include <array>
@@ -33,12 +35,15 @@ namespace wivrn
{
class wivrn_session;
struct wivrn_hmd_presence_data
{
bool value;
int64_t change_time;
};
class wivrn_hmd : public xrt_device
{
xrt_input pose_input{
.active = true,
.name = XRT_INPUT_GENERIC_HEAD_POSE,
};
beman::inplace_vector::inplace_vector<xrt_input, 2> inputs_array;
xrt_hmd_parts hmd_parts{};
xrt_tracking_origin tracking_origin{
.name = "WiVRn origin",
@@ -51,7 +56,7 @@ class wivrn_hmd : public xrt_device
view_list views;
thread_safe<from_headset::battery> battery{};
std::atomic<bool> presence{true};
thread_safe<wivrn_hmd_presence_data> presence;
thread_safe<std::array<std::optional<from_headset::visibility_mask_changed::masks>, 2>> visibility_mask;
wivrn::wivrn_session * cnx;
@@ -65,8 +70,8 @@ public:
void set_foveated_size(uint32_t width, uint32_t height);
xrt_result_t update_inputs();
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation *);
xrt_result_t get_presence(bool * out_presence);
xrt_result_t get_view_poses(const xrt_vec3 * default_eye_relation,
int64_t at_timestamp_ns,
xrt_view_type view_type,
@@ -81,6 +86,6 @@ public:
void update_battery(const from_headset::battery &);
void update_tracking(const from_headset::tracking &, const clock_offset &);
void update_visibility_mask(const from_headset::visibility_mask_changed &);
bool update_presence(bool);
void update_presence(bool new_presence, int64_t timestamp);
};
} // namespace wivrn
+6 -22
View File
@@ -388,14 +388,9 @@ void wivrn_session::pause_session()
// notify clients about session pause
update_client_states(false, false);
if (get_info().user_presence)
{
(*this)(from_headset::user_presence_changed{
.present = false,
});
}
hmd.update_presence(false, os_monotonic_get_ns());
update_client_states(false, false);
// pause session components
@@ -444,13 +439,6 @@ void wivrn_session::resume_session()
compositor.resume();
if (get_info().user_presence)
{
(*this)(from_headset::user_presence_changed{
.present = true,
});
}
(*this)(from_headset::get_application_list{
.language = get_info().language,
.country = get_info().country,
@@ -461,6 +449,7 @@ void wivrn_session::resume_session()
worker_thread = std::jthread([this](std::stop_token stop) { return run_worker(stop); });
update_client_states(true, true);
hmd.update_presence(false, os_monotonic_get_ns());
}
clock_offset wivrn_session::get_offset()
@@ -847,14 +836,9 @@ void wivrn_session::operator()(from_headset::session_state_changed && event)
}
void wivrn_session::operator()(from_headset::user_presence_changed && event)
{
if (hmd.update_presence(event.present))
push_event(
{
.presence_change = {
.type = XRT_SESSION_EVENT_USER_PRESENCE_CHANGE,
.is_user_present = event.present,
},
});
clock_offset o = offset_est.get_offset();
U_LOG_I("user presence changed to %s", event.present ? "true" : "false");
hmd.update_presence(event.present, o ? o.from_headset(event.change_time) : os_monotonic_get_ns());
}
void wivrn_session::operator()(from_headset::refresh_rate_changed && event)