Merge branch 'sync' into sneed

This commit is contained in:
Vindicus999
2026-09-27 18:51:13 -04:00
172 changed files with 27992 additions and 15036 deletions
+27 -18
View File
@@ -26,6 +26,7 @@
#include "xrt/xrt_device.h"
#include "util/u_device.h"
#include "util/u_device_id.h"
#include "util/u_logging.h"
#include "utils/method.h"
@@ -70,28 +71,27 @@ xrt_result_t wivrn_hmd::get_visibility_mask(xrt_visibility_mask_type type, uint3
wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
const from_headset::headset_info_packet & info) :
xrt_device{
.id = u_device_id_generate(),
.name = XRT_DEVICE_GENERIC_HMD,
.device_type = XRT_DEVICE_TYPE_HMD,
.str = "WiVRn HMD",
.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)
{
xrt_device_init(static_cast<xrt_device *>(this));
@@ -103,6 +103,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;
@@ -129,6 +136,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)
@@ -156,13 +175,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,
@@ -240,13 +252,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