Add support for the OpenXR Eye gaze interaction extension

Co-authored-by: Bastiaan Olij <mux213@gmail.com>
This commit is contained in:
Bastiaan Olij 2023-06-08 12:05:20 +10:00 committed by Fredia Huya-Kouadio
parent a2f90d565a
commit 9e56e7a3ce
18 changed files with 266 additions and 6 deletions

View file

@ -36,6 +36,8 @@
#include "extensions/openxr_hand_tracking_extension.h"
#include "extensions/openxr_eye_gaze_interaction.h"
void OpenXRInterface::_bind_methods() {
// lifecycle signals
ADD_SIGNAL(MethodInfo("session_begun"));
@ -119,6 +121,8 @@ void OpenXRInterface::_bind_methods() {
BIND_ENUM_CONSTANT(HAND_JOINT_LITTLE_DISTAL);
BIND_ENUM_CONSTANT(HAND_JOINT_LITTLE_TIP);
BIND_ENUM_CONSTANT(HAND_JOINT_MAX);
ClassDB::bind_method(D_METHOD("is_eye_gaze_interaction_supported"), &OpenXRInterface::is_eye_gaze_interaction_supported);
}
StringName OpenXRInterface::get_name() const {
@ -152,7 +156,9 @@ PackedStringArray OpenXRInterface::get_suggested_tracker_names() const {
"/user/vive_tracker_htcx/role/waist",
"/user/vive_tracker_htcx/role/chest",
"/user/vive_tracker_htcx/role/camera",
"/user/vive_tracker_htcx/role/keyboard"
"/user/vive_tracker_htcx/role/keyboard",
"/user/eyes_ext",
};
return arr;
@ -705,6 +711,21 @@ Array OpenXRInterface::get_available_display_refresh_rates() const {
}
}
bool OpenXRInterface::is_eye_gaze_interaction_supported() {
if (openxr_api == nullptr) {
return false;
} else if (!openxr_api->is_initialized()) {
return false;
} else {
OpenXREyeGazeInteractionExtension *eye_gaze_ext = OpenXREyeGazeInteractionExtension::get_singleton();
if (eye_gaze_ext == nullptr) {
return false;
} else {
return eye_gaze_ext->supports_eye_gaze_interaction();
}
}
}
bool OpenXRInterface::is_action_set_active(const String &p_action_set) const {
for (ActionSet *action_set : action_sets) {
if (action_set->action_set_name == p_action_set) {