xrt,st/oxr: Implement face tracking device feature for FB and HTC extensions
Co-authored-by: Korcan Hussein <korcan.hussein@collabora.com> Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2649>
49 unmodified lines50515253545556575889 unmodified lines14814915015115215315415515615727 unmodified lines185186187188189190191192193194145 unmodified linesExpand all49 unmodified lines switch (type) { case XRT_DEVICE_FEATURE_HAND_TRACKING_LEFT: return "hand_tracking_left"; case XRT_DEVICE_FEATURE_HAND_TRACKING_RIGHT: return "hand_tracking_right"; case XRT_DEVICE_FEATURE_EYE_TRACKING: return "eye_tracking"; case XRT_DEVICE_FEATURE_FACE_TRACKING: return "face_tracking"; default: return "invalid"; }}
89 unmodified lines } else if (type == XRT_DEVICE_FEATURE_HAND_TRACKING_RIGHT) { xret = set_hand_tracking_enabled(xsysd, XRT_HAND_RIGHT, true); } else if (type == XRT_DEVICE_FEATURE_EYE_TRACKING) { xret = xrt_device_begin_feature(xsysd->static_roles.eyes, type); } else if (type == XRT_DEVICE_FEATURE_FACE_TRACKING) { xret = xrt_device_begin_feature(xsysd->static_roles.face, type); } else { xret = XRT_ERROR_FEATURE_NOT_SUPPORTED; } if (xret != XRT_SUCCESS) {27 unmodified lines } else if (type == XRT_DEVICE_FEATURE_EYE_TRACKING) { // @todo When eyes are moved from the static roles, we need to end features on the old device when // swapping which device is in the eyes role xret = xrt_device_end_feature(xsysd->static_roles.eyes, type); } else if (type == XRT_DEVICE_FEATURE_FACE_TRACKING) { xret = xrt_device_end_feature(xsysd->static_roles.face, type); } else { xret = XRT_ERROR_FEATURE_NOT_SUPPORTED; } if (xret != XRT_SUCCESS) {145 unmodified linesExpand all253 unmodified linesExpand all254255256257258259260261262901 unmodified linesExpand all253 unmodified linesExpand all{ XRT_DEVICE_FEATURE_HAND_TRACKING_LEFT = 0, XRT_DEVICE_FEATURE_HAND_TRACKING_RIGHT, XRT_DEVICE_FEATURE_EYE_TRACKING, XRT_DEVICE_FEATURE_FACE_TRACKING, XRT_DEVICE_FEATURE_MAX_ENUM,};
/*!901 unmodified linesExpand all19 unmodified lines202122232425262728293031322 unmodified lines3536373839404142434452 unmodified lines97989910010110210310410510610710810911011156 unmodified lines19 unmodified linesstatic XrResultoxr_face_tracker2_fb_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb){ struct oxr_face_tracker2_fb *face_tracker2_fb = (struct oxr_face_tracker2_fb *)hb;
if (face_tracker2_fb->feature_incremented) { xrt_system_devices_feature_dec(face_tracker2_fb->sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); }
free(face_tracker2_fb); return XR_SUCCESS;}
2 unmodified lines struct oxr_session *sess, const XrFaceTrackerCreateInfo2FB *createInfo, struct oxr_face_tracker2_fb **out_face_tracker2_fb){ xrt_result_t xret;
if (createInfo->faceExpressionSet != XR_FACE_EXPRESSION_SET2_DEFAULT_FB) { return oxr_error(log, XR_ERROR_FEATURE_UNSUPPORTED, "Unsupported expression set"); }
52 unmodified lines struct oxr_face_tracker2_fb *face_tracker2_fb = NULL; OXR_ALLOCATE_HANDLE_OR_RETURN(log, face_tracker2_fb, OXR_XR_DEBUG_FTRACKER, oxr_face_tracker2_fb_destroy_cb, &sess->handle);
xret = xrt_system_devices_feature_inc(sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); if (xret != XRT_SUCCESS) { oxr_handle_destroy(log, &face_tracker2_fb->handle); return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "Failed to start face tracking feature"); } face_tracker2_fb->feature_incremented = true;
face_tracker2_fb->sess = sess; face_tracker2_fb->xdev = xdev; face_tracker2_fb->audio_enabled = want_audio; face_tracker2_fb->visual_enabled = want_visual;56 unmodified lines19 unmodified lines202122232425262728293031323321 unmodified lines55565758596061626364656667686979 unmodified lines19 unmodified linesstatic XrResultoxr_face_tracker_android_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb){ struct oxr_face_tracker_android *face_tracker_android = (struct oxr_face_tracker_android *)hb;
if (face_tracker_android->feature_incremented) { xrt_system_devices_feature_dec(face_tracker_android->sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); }
free(face_tracker_android); return XR_SUCCESS;}
21 unmodified lines struct oxr_face_tracker_android *face_tracker_android = NULL; OXR_ALLOCATE_HANDLE_OR_RETURN(log, face_tracker_android, OXR_XR_DEBUG_FTRACKER, oxr_face_tracker_android_destroy_cb, &sess->handle);
xrt_result_t xret = xrt_system_devices_feature_inc(sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); if (xret != XRT_SUCCESS) { oxr_handle_destroy(log, &face_tracker_android->handle); return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "Failed to start face tracking feature"); }
face_tracker_android->feature_incremented = true; face_tracker_android->sess = sess; face_tracker_android->xdev = xdev;
*faceTracker = oxr_face_tracker_android_to_openxr(face_tracker_android);79 unmodified lines33 unmodified lines343536373839404142434445462 unmodified lines4950515253545556575819 unmodified lines78798081828384858687888990919241 unmodified lines33 unmodified linesstatic XrResultoxr_facial_tracker_htc_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb){ struct oxr_facial_tracker_htc *face_tracker_htc = (struct oxr_facial_tracker_htc *)hb;
if (face_tracker_htc->feature_incremented) { xrt_system_devices_feature_dec(face_tracker_htc->sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); }
free(face_tracker_htc); return XR_SUCCESS;}
2 unmodified lines struct oxr_session *sess, const XrFacialTrackerCreateInfoHTC *createInfo, struct oxr_facial_tracker_htc **out_face_tracker_htc){ xrt_result_t xret;
bool supports_eye = false; bool supports_lip = false; oxr_system_get_face_tracking_htc_support(log, sess->sys->inst, &supports_eye, &supports_lip);
19 unmodified lines struct oxr_facial_tracker_htc *face_tracker_htc = NULL; OXR_ALLOCATE_HANDLE_OR_RETURN(log, face_tracker_htc, OXR_XR_DEBUG_FTRACKER, oxr_facial_tracker_htc_destroy_cb, &sess->handle);
xret = xrt_system_devices_feature_inc(sess->sys->xsysd, XRT_DEVICE_FEATURE_FACE_TRACKING); if (xret != XRT_SUCCESS) { oxr_handle_destroy(log, &face_tracker_htc->handle); return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "Failed to start face tracking feature"); } face_tracker_htc->feature_incremented = true;
face_tracker_htc->sess = sess; face_tracker_htc->xdev = xdev; face_tracker_htc->facial_tracking_type = facial_tracking_type;
41 unmodified lines2884 unmodified linesExpand all2885288628872888288928902891289228932894289571 unmodified lines29672968296929702971297229732974297529762977161 unmodified linesExpand all3139314031413142314331443145314631473148314924 unmodified lines2884 unmodified linesExpand all struct xrt_device *xdev;
//! Type of facial tracking, eyes or lips enum xrt_facial_tracking_type_htc facial_tracking_type;
//! To track if the feature set has been incremented since creation. bool feature_incremented;};
XrResultoxr_facial_tracker_htc_create(struct oxr_logger *log,71 unmodified lines struct xrt_device *xdev;
bool audio_enabled; bool visual_enabled;
//! To track if the feature set has been incremented since creation. bool feature_incremented;};
XrResultoxr_face_tracker2_fb_create(struct oxr_logger *log,161 unmodified linesExpand all struct oxr_session *sess;
//! xrt_device backing this face tracker struct xrt_device *xdev;
//! To track if the feature set has been incremented since creation. bool feature_incremented;};
XrResultoxr_face_tracker_android_create(struct oxr_logger *log,24 unmodified lines