-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the OpenXR Eye gaze interaction extension
- Loading branch information
1 parent
e188d61
commit 145c56d
Showing
8 changed files
with
216 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/**************************************************************************/ | ||
/* openxr_eye_gaze_interaction.cpp */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#include "openxr_eye_gaze_interaction.h" | ||
#include "../action_map/openxr_interaction_profile_meta_data.h" | ||
|
||
OpenXREyeGazeInteractionExtension *OpenXREyeGazeInteractionExtension::singleton = nullptr; | ||
|
||
OpenXREyeGazeInteractionExtension::OpenXREyeGazeInteractionExtension() { | ||
singleton = this; | ||
} | ||
|
||
OpenXREyeGazeInteractionExtension::~OpenXREyeGazeInteractionExtension() { | ||
singleton = nullptr; | ||
} | ||
|
||
HashMap<String, bool *> OpenXREyeGazeInteractionExtension::get_requested_extensions() { | ||
HashMap<String, bool *> request_extensions; | ||
|
||
request_extensions[XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME] = &available; | ||
|
||
return request_extensions; | ||
} | ||
|
||
void *OpenXREyeGazeInteractionExtension::set_system_properties_and_get_next_pointer(void *p_next_pointer) { | ||
if (!available) { | ||
return p_next_pointer; | ||
} | ||
|
||
properties.type = XR_TYPE_SYSTEM_EYE_GAZE_INTERACTION_PROPERTIES_EXT; | ||
properties.next = p_next_pointer; | ||
properties.supportsEyeGazeInteraction = false; | ||
|
||
return &properties; | ||
} | ||
|
||
bool OpenXREyeGazeInteractionExtension::is_available() { | ||
return available; | ||
} | ||
|
||
bool OpenXREyeGazeInteractionExtension::supports_eye_gaze() { | ||
// note, supportsEyeGazeInteraction is somewhat confusingly named, it does not denote that this | ||
// capability is not available even though the extension is, it denotes its limited. | ||
// | ||
// From the OpenXR Specification: | ||
// supportsEyeGazeInteraction the runtime must set this value to XR_TRUE when eye gaze sufficient | ||
// for use cases such as aiming or targeting is supported by the current device, | ||
// otherwise the runtime must set this to XR_FALSE | ||
return properties.supportsEyeGazeInteraction; | ||
} | ||
|
||
void OpenXREyeGazeInteractionExtension::on_register_metadata() { | ||
OpenXRInteractionProfileMetaData *metadata = OpenXRInteractionProfileMetaData::get_singleton(); | ||
ERR_FAIL_NULL(metadata); | ||
|
||
// Eyes top path | ||
metadata->register_top_level_path("Eye gaze tracker", "/user/eyes_ext", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME); | ||
|
||
// Eye gaze interaction | ||
metadata->register_interaction_profile("Eye gaze", "/interaction_profiles/ext/eye_gaze_interaction", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME); | ||
metadata->register_io_path("/interaction_profiles/ext/eye_gaze_interaction", "Gaze pose", "/user/eyes_ext", "/user/eyes_ext/input/gaze_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/**************************************************************************/ | ||
/* openxr_eye_gaze_interaction.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#ifndef OPENXR_EYE_GAZE_INTERACTION_H | ||
#define OPENXR_EYE_GAZE_INTERACTION_H | ||
|
||
#include "openxr_extension_wrapper.h" | ||
|
||
class OpenXREyeGazeInteractionExtension : public OpenXRExtensionWrapper { | ||
public: | ||
static OpenXREyeGazeInteractionExtension *get_singleton() { return singleton; } | ||
|
||
OpenXREyeGazeInteractionExtension(); | ||
~OpenXREyeGazeInteractionExtension(); | ||
|
||
virtual HashMap<String, bool *> get_requested_extensions() override; | ||
virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) override; | ||
|
||
bool is_available(); | ||
bool supports_eye_gaze(); | ||
|
||
virtual void on_register_metadata() override; | ||
|
||
private: | ||
static OpenXREyeGazeInteractionExtension *singleton; | ||
|
||
bool available = false; | ||
XrSystemEyeGazeInteractionPropertiesEXT properties; | ||
}; | ||
|
||
#endif // OPENXR_EYE_GAZE_INTERACTION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters