@@ -1113,6 +1113,7 @@ void application::initialize()
|
||||
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_DEPTH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_USER_PRESENCE_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/htc_body_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include <openxr/openxr.h>
|
||||
#define GLM_FORCE_RADIANS
|
||||
|
||||
#include "stream.h"
|
||||
@@ -217,6 +218,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
|
||||
info.hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
info.eye_gaze = config.check_feature(feature::eye_gaze);
|
||||
info.presence = self->instance.has_extension(XR_EXT_USER_PRESENCE_EXTENSION_NAME) && self->system.user_presence_properties().supportsUserPresence;
|
||||
|
||||
if (config.check_feature(feature::face_tracking))
|
||||
{
|
||||
@@ -1287,6 +1289,11 @@ void scenes::stream::on_xr_event(const xr::event & event)
|
||||
.view_index = uint8_t(event.visibility_mask_changed.viewIndex),
|
||||
});
|
||||
break;
|
||||
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,
|
||||
});
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED:
|
||||
on_interaction_profile_changed(event.interaction_profile_changed);
|
||||
break;
|
||||
|
||||
@@ -43,6 +43,7 @@ union event
|
||||
XrEventDataDisplayRefreshRateChangedFB refresh_rate_changed;
|
||||
XrEventDataPassthroughStateChangedFB passthrough_state_changed;
|
||||
XrEventDataVisibilityMaskChangedKHR visibility_mask_changed;
|
||||
XrEventDataUserPresenceChangedEXT user_presence_changed;
|
||||
};
|
||||
class instance : public utils::handle<XrInstance, xrDestroyInstance>
|
||||
{
|
||||
|
||||
@@ -105,6 +105,24 @@ XrSystemEyeGazeInteractionPropertiesEXT xr::system::eye_gaze_interaction_propert
|
||||
return eye_gaze_prop;
|
||||
}
|
||||
|
||||
XrSystemUserPresencePropertiesEXT xr::system::user_presence_properties() const
|
||||
{
|
||||
if (!id)
|
||||
throw std::invalid_argument("this");
|
||||
|
||||
XrSystemUserPresencePropertiesEXT presence_prop{
|
||||
.type = XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT,
|
||||
};
|
||||
|
||||
XrSystemProperties prop{
|
||||
.type = XR_TYPE_SYSTEM_PROPERTIES,
|
||||
.next = &presence_prop,
|
||||
};
|
||||
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
|
||||
|
||||
return presence_prop;
|
||||
}
|
||||
|
||||
XrSystemFaceTrackingProperties2FB xr::system::fb_face_tracking2_properties() const
|
||||
{
|
||||
if (!id)
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
XrSystemProperties properties() const;
|
||||
XrSystemHandTrackingPropertiesEXT hand_tracking_properties() const;
|
||||
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_interaction_properties() const;
|
||||
XrSystemUserPresencePropertiesEXT user_presence_properties() const;
|
||||
XrSystemFaceTrackingProperties2FB fb_face_tracking2_properties() const;
|
||||
XrSystemFacialTrackingPropertiesHTC htc_face_tracking_properties() const;
|
||||
XrSystemBodyTrackingPropertiesFB fb_body_tracking_properties() const;
|
||||
|
||||
@@ -216,6 +216,7 @@ struct headset_info_packet
|
||||
std::array<XrFovf, 2> fov;
|
||||
bool hand_tracking;
|
||||
bool eye_gaze;
|
||||
bool presence;
|
||||
bool palm_pose;
|
||||
bool passthrough;
|
||||
face_type face_tracking;
|
||||
@@ -409,6 +410,11 @@ struct refresh_rate_changed
|
||||
float to;
|
||||
};
|
||||
|
||||
struct user_presence_changed
|
||||
{
|
||||
bool present;
|
||||
};
|
||||
|
||||
using packets = std::variant<
|
||||
crypto_handshake,
|
||||
pin_check_1,
|
||||
@@ -426,7 +432,8 @@ using packets = std::variant<
|
||||
timesync_response,
|
||||
battery,
|
||||
visibility_mask_changed,
|
||||
refresh_rate_changed>;
|
||||
refresh_rate_changed,
|
||||
user_presence_changed>;
|
||||
} // namespace from_headset
|
||||
|
||||
namespace to_headset
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
{
|
||||
|
||||
@@ -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 &&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user