st/oxr: Send XrEventDataInteractionProfileChanged events on interaction profile changes

This commit is contained in:
Jakob Bornecrantz 2020-07-20 19:34:02 +01:00
parent 56386aa1d7
commit b87fd91bc8
3 changed files with 51 additions and 6 deletions
src/xrt/state_trackers/oxr

View file

@ -122,6 +122,25 @@ oxr_event_alloc(struct oxr_logger *log,
return XR_SUCCESS;
}
static bool
is_session_link_to_event(struct oxr_event *event, XrSession session)
{
XrStructureType *type = oxr_event_extra(event);
switch (*type) {
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
XrEventDataSessionStateChanged *changed =
(XrEventDataSessionStateChanged *)type;
return changed->session == session;
}
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: {
XrEventDataInteractionProfileChanged *changed =
(XrEventDataInteractionProfileChanged *)type;
return changed->session == session;
}
default: return false;
}
}
/*
*
@ -157,6 +176,27 @@ oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
return XR_SUCCESS;
}
XrResult
oxr_event_push_XrEventDataInteractionProfileChanged(struct oxr_logger *log,
struct oxr_session *sess)
{
struct oxr_instance *inst = sess->sys->inst;
XrEventDataSessionStateChanged *changed;
struct oxr_event *event = NULL;
ALLOC(log, inst, &event, &changed);
changed->type = XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED;
changed->session = oxr_session_to_openxr(sess);
lock(inst);
push(inst, event);
unlock(inst);
return XR_SUCCESS;
}
XrResult
oxr_event_push_XrEventDataMainSessionVisibilityChangedEXTX(
struct oxr_logger *log, struct oxr_session *sess, bool visible)
@ -191,12 +231,7 @@ oxr_event_remove_session_events(struct oxr_logger *log,
struct oxr_event *cur = e;
e = e->next;
XrEventDataSessionStateChanged *changed = oxr_event_extra(cur);
if (changed->type != XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) {
continue;
}
if (changed->session != session) {
if (!is_session_link_to_event(cur, session)) {
continue;
}

View file

@ -1229,12 +1229,18 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
if (head != NULL) {
sess->head = head->path;
// Also push event
oxr_event_push_XrEventDataInteractionProfileChanged(log, sess);
}
if (left != NULL) {
sess->left = left->path;
// Also push event
oxr_event_push_XrEventDataInteractionProfileChanged(log, sess);
}
if (right != NULL) {
sess->right = right->path;
// Also push event
oxr_event_push_XrEventDataInteractionProfileChanged(log, sess);
}
return oxr_session_success_result(sess);

View file

@ -837,6 +837,10 @@ XrResult
oxr_event_push_XrEventDataMainSessionVisibilityChangedEXTX(
struct oxr_logger *log, struct oxr_session *sess, bool visible);
XrResult
oxr_event_push_XrEventDataInteractionProfileChanged(struct oxr_logger *log,
struct oxr_session *sess);
/*!
* This clears all pending events refers to the given session.
*/