Forward XR_EXT_user_presence

Closes #258
This commit is contained in:
Sapphire
2025-07-04 23:43:06 +02:00
committed by xytovl
parent f43ee229f1
commit 3ac31fe5cc
10 changed files with 67 additions and 1 deletions
+15
View File
@@ -76,10 +76,12 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
.supported = {
.orientation_tracking = true,
.position_tracking = true,
.presence = info.presence,
.battery_status = true,
},
.update_inputs = [](xrt_device *) { return XRT_SUCCESS; },
.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>,
@@ -147,6 +149,13 @@ void wivrn_hmd::update_battery(const from_headset::battery & new_battery)
battery = 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,
uint32_t view_count,
@@ -222,4 +231,10 @@ void wivrn_hmd::update_visibility_mask(const from_headset::visibility_mask_chang
auto m = visibility_mask.lock();
m->at(mask.view_index) = mask.data;
}
void wivrn_hmd::update_presence(bool presence)
{
U_LOG_I("Updating user presence to %s", presence ? "true" : "false");
this->presence = presence;
}
} // namespace wivrn
+3
View File
@@ -53,6 +53,7 @@ class wivrn_hmd : public xrt_device
view_list views;
from_headset::battery battery{};
std::atomic<bool> presence{true};
thread_safe<std::array<std::optional<from_headset::visibility_mask_changed::masks>, 2>> visibility_mask;
wivrn::wivrn_session * cnx;
@@ -67,6 +68,7 @@ public:
void set_foveated_size(uint32_t width, uint32_t height);
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,
uint32_t view_count,
@@ -80,5 +82,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 &);
void update_presence(bool presence);
};
} // namespace wivrn
+12
View File
@@ -576,6 +576,18 @@ void wivrn_session::operator()(from_headset::visibility_mask_changed && mask)
auto result = xrt_session_event_sink_push(&xrt_system.broadcast, &event);
}
void wivrn_session::operator()(from_headset::user_presence_changed && event)
{
hmd.update_presence(event.present);
push_event(
{
.presence_change = {
.type = XRT_SESSION_EVENT_USER_PRESENCE_CHANGE,
.is_user_present = event.present,
},
});
}
void wivrn_session::operator()(from_headset::refresh_rate_changed && event)
{
{
+1
View File
@@ -179,6 +179,7 @@ public:
void operator()(from_headset::feedback &&);
void operator()(from_headset::battery &&);
void operator()(from_headset::visibility_mask_changed &&);
void operator()(from_headset::user_presence_changed &&);
void operator()(from_headset::refresh_rate_changed &&);
void operator()(audio_data &&);