feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
Import("env_openxr")
|
||||
|
|
@ -12,6 +13,8 @@ if env["platform"] == "android":
|
|||
env_openxr.add_source_files(module_obj, "platform/openxr_android_extension.cpp")
|
||||
if env["vulkan"]:
|
||||
env_openxr.add_source_files(module_obj, "platform/openxr_vulkan_extension.cpp")
|
||||
if env["metal"]:
|
||||
env_openxr.add_source_files(module_obj, "platform/openxr_metal_extension.mm")
|
||||
if env["opengl3"] and env["platform"] != "macos":
|
||||
env_openxr.add_source_files(module_obj, "platform/openxr_opengl_extension.cpp")
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@
|
|||
|
||||
#include "openxr_composition_layer_extension.h"
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
#endif
|
||||
|
||||
#include "platform/android/api/java_class_wrapper.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -55,18 +61,37 @@ HashMap<String, bool *> OpenXRCompositionLayerExtension::get_requested_extension
|
|||
request_extensions[XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME] = &cylinder_ext_available;
|
||||
request_extensions[XR_KHR_COMPOSITION_LAYER_EQUIRECT2_EXTENSION_NAME] = &equirect_ext_available;
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
request_extensions[XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME] = &android_surface_ext_available;
|
||||
#endif
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::on_session_created(const XrSession p_instance) {
|
||||
void OpenXRCompositionLayerExtension::on_instance_created(const XrInstance p_instance) {
|
||||
#ifdef ANDROID_ENABLED
|
||||
EXT_INIT_XR_FUNC(xrDestroySwapchain);
|
||||
EXT_INIT_XR_FUNC(xrCreateSwapchainAndroidSurfaceKHR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::on_session_created(const XrSession p_session) {
|
||||
OpenXRAPI::get_singleton()->register_composition_layer_provider(this);
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::on_session_destroyed() {
|
||||
OpenXRAPI::get_singleton()->unregister_composition_layer_provider(this);
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
free_queued_android_surface_swapchains();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::on_pre_render() {
|
||||
#ifdef ANDROID_ENABLED
|
||||
free_queued_android_surface_swapchains();
|
||||
#endif
|
||||
|
||||
for (OpenXRViewportCompositionLayerProvider *composition_layer : composition_layers) {
|
||||
composition_layer->on_pre_render();
|
||||
}
|
||||
|
|
@ -113,6 +138,36 @@ bool OpenXRCompositionLayerExtension::is_available(XrStructureType p_which) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
bool OpenXRCompositionLayerExtension::create_android_surface_swapchain(XrSwapchainCreateInfo *p_info, XrSwapchain *r_swapchain, jobject *r_surface) {
|
||||
if (android_surface_ext_available) {
|
||||
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL_V(openxr_api, false);
|
||||
|
||||
XrResult result = xrCreateSwapchainAndroidSurfaceKHR(openxr_api->get_session(), p_info, r_swapchain, r_surface);
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Failed to create Android surface swapchain [", openxr_api->get_error_string(result), "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::free_android_surface_swapchain(XrSwapchain p_swapchain) {
|
||||
android_surface_swapchain_free_queue.push_back(p_swapchain);
|
||||
}
|
||||
|
||||
void OpenXRCompositionLayerExtension::free_queued_android_surface_swapchains() {
|
||||
for (XrSwapchain swapchain : android_surface_swapchain_free_queue) {
|
||||
xrDestroySwapchain(swapchain);
|
||||
}
|
||||
android_surface_swapchain_free_queue.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// OpenXRViewportCompositionLayerProvider
|
||||
|
||||
|
|
@ -127,8 +182,12 @@ OpenXRViewportCompositionLayerProvider::~OpenXRViewportCompositionLayerProvider(
|
|||
extension->on_viewport_composition_layer_destroyed(composition_layer);
|
||||
}
|
||||
|
||||
// This will reset the viewport and free the swapchain too.
|
||||
set_viewport(RID(), Size2i());
|
||||
if (use_android_surface) {
|
||||
free_swapchain();
|
||||
} else {
|
||||
// This will reset the viewport and free the swapchain too.
|
||||
set_viewport(RID(), Size2i());
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::set_alpha_blend(bool p_alpha_blend) {
|
||||
|
|
@ -143,43 +202,128 @@ void OpenXRViewportCompositionLayerProvider::set_alpha_blend(bool p_alpha_blend)
|
|||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::set_viewport(RID p_viewport, Size2i p_size) {
|
||||
ERR_FAIL_COND(use_android_surface);
|
||||
|
||||
RenderingServer *rs = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL(rs);
|
||||
|
||||
if (viewport != p_viewport) {
|
||||
if (viewport.is_valid()) {
|
||||
RID rt = rs->viewport_get_render_target(viewport);
|
||||
RSG::texture_storage->render_target_set_override(rt, RID(), RID(), RID());
|
||||
if (subviewport.viewport != p_viewport) {
|
||||
if (subviewport.viewport.is_valid()) {
|
||||
RID rt = rs->viewport_get_render_target(subviewport.viewport);
|
||||
RSG::texture_storage->render_target_set_override(rt, RID(), RID(), RID(), RID());
|
||||
}
|
||||
|
||||
viewport = p_viewport;
|
||||
subviewport.viewport = p_viewport;
|
||||
|
||||
if (viewport.is_valid()) {
|
||||
viewport_size = p_size;
|
||||
if (subviewport.viewport.is_valid()) {
|
||||
subviewport.viewport_size = p_size;
|
||||
} else {
|
||||
free_swapchain();
|
||||
viewport_size = Size2i();
|
||||
subviewport.viewport_size = Size2i();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::set_use_android_surface(bool p_use_android_surface, Size2i p_size) {
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (p_use_android_surface == use_android_surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
use_android_surface = p_use_android_surface;
|
||||
|
||||
if (use_android_surface) {
|
||||
if (!composition_layer_extension->is_android_surface_swapchain_available()) {
|
||||
ERR_PRINT_ONCE("OpenXR: Cannot use Android surface for composition layer because the extension isn't available");
|
||||
}
|
||||
|
||||
if (subviewport.viewport.is_valid()) {
|
||||
set_viewport(RID(), Size2i());
|
||||
}
|
||||
|
||||
swapchain_size = p_size;
|
||||
} else {
|
||||
free_swapchain();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
void OpenXRViewportCompositionLayerProvider::create_android_surface() {
|
||||
ERR_FAIL_COND(android_surface.swapchain != XR_NULL_HANDLE || android_surface.surface.is_valid());
|
||||
ERR_FAIL_COND(!openxr_api || !openxr_api->is_running());
|
||||
|
||||
void *next_pointer = nullptr;
|
||||
for (OpenXRExtensionWrapper *wrapper : openxr_api->get_registered_extension_wrappers()) {
|
||||
void *np = wrapper->set_android_surface_swapchain_create_info_and_get_next_pointer(extension_property_values, next_pointer);
|
||||
if (np != nullptr) {
|
||||
next_pointer = np;
|
||||
}
|
||||
}
|
||||
|
||||
// The XR_FB_android_surface_swapchain_create extension mandates that format, sampleCount,
|
||||
// faceCount, arraySize, and mipCount must be zero.
|
||||
XrSwapchainCreateInfo info = {
|
||||
XR_TYPE_SWAPCHAIN_CREATE_INFO, // type
|
||||
next_pointer, // next
|
||||
0, // createFlags
|
||||
XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, // usageFlags
|
||||
0, // format
|
||||
0, // sampleCount
|
||||
(uint32_t)swapchain_size.x, // width
|
||||
(uint32_t)swapchain_size.y, // height
|
||||
0, // faceCount
|
||||
0, // arraySize
|
||||
0, // mipCount
|
||||
};
|
||||
|
||||
jobject surface;
|
||||
composition_layer_extension->create_android_surface_swapchain(&info, &android_surface.swapchain, &surface);
|
||||
|
||||
if (surface) {
|
||||
android_surface.surface.instantiate(JavaClassWrapper::get_singleton()->wrap("android.view.Surface"), surface);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Ref<JavaObject> OpenXRViewportCompositionLayerProvider::get_android_surface() {
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (use_android_surface) {
|
||||
if (android_surface.surface.is_null()) {
|
||||
create_android_surface();
|
||||
}
|
||||
return android_surface.surface;
|
||||
}
|
||||
#endif
|
||||
return Ref<JavaObject>();
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::set_extension_property_values(const Dictionary &p_extension_property_values) {
|
||||
extension_property_values = p_extension_property_values;
|
||||
extension_property_values_changed = true;
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::on_pre_render() {
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (use_android_surface) {
|
||||
if (android_surface.surface.is_null()) {
|
||||
create_android_surface();
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderingServer *rs = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL(rs);
|
||||
|
||||
if (viewport.is_valid() && openxr_api && openxr_api->is_running()) {
|
||||
RS::ViewportUpdateMode update_mode = rs->viewport_get_update_mode(viewport);
|
||||
if (subviewport.viewport.is_valid() && openxr_api && openxr_api->is_running()) {
|
||||
RS::ViewportUpdateMode update_mode = rs->viewport_get_update_mode(subviewport.viewport);
|
||||
if (update_mode == RS::VIEWPORT_UPDATE_ONCE || update_mode == RS::VIEWPORT_UPDATE_ALWAYS) {
|
||||
// Update our XR swapchain
|
||||
if (update_and_acquire_swapchain(update_mode == RS::VIEWPORT_UPDATE_ONCE)) {
|
||||
// Render to our XR swapchain image.
|
||||
RID rt = rs->viewport_get_render_target(viewport);
|
||||
RSG::texture_storage->render_target_set_override(rt, get_current_swapchain_texture(), RID(), RID());
|
||||
RID rt = rs->viewport_get_render_target(subviewport.viewport);
|
||||
RSG::texture_storage->render_target_set_override(rt, get_current_swapchain_texture(), RID(), RID(), RID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -196,48 +340,36 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (swapchain_info.get_swapchain() == XR_NULL_HANDLE) {
|
||||
XrSwapchainSubImage subimage = {
|
||||
0, // swapchain // NOLINT(modernize-use-nullptr) - 32-bit uses non-pointer uint64
|
||||
{ { 0, 0 }, { 0, 0 } }, // imageRect
|
||||
0, // imageArrayIndex
|
||||
};
|
||||
update_swapchain_sub_image(subimage);
|
||||
|
||||
if (subimage.swapchain == XR_NULL_HANDLE) {
|
||||
// Don't have a swapchain to display? Ignore our layer.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (swapchain_info.is_image_acquired()) {
|
||||
swapchain_info.release();
|
||||
}
|
||||
|
||||
// Update the layer struct for the swapchain.
|
||||
switch (composition_layer->type) {
|
||||
case XR_TYPE_COMPOSITION_LAYER_QUAD: {
|
||||
XrCompositionLayerQuad *quad_layer = (XrCompositionLayerQuad *)composition_layer;
|
||||
quad_layer->space = openxr_api->get_play_space();
|
||||
quad_layer->subImage.swapchain = swapchain_info.get_swapchain();
|
||||
quad_layer->subImage.imageArrayIndex = 0;
|
||||
quad_layer->subImage.imageRect.offset.x = 0;
|
||||
quad_layer->subImage.imageRect.offset.y = 0;
|
||||
quad_layer->subImage.imageRect.extent.width = swapchain_size.width;
|
||||
quad_layer->subImage.imageRect.extent.height = swapchain_size.height;
|
||||
quad_layer->subImage = subimage;
|
||||
} break;
|
||||
|
||||
case XR_TYPE_COMPOSITION_LAYER_CYLINDER_KHR: {
|
||||
XrCompositionLayerCylinderKHR *cylinder_layer = (XrCompositionLayerCylinderKHR *)composition_layer;
|
||||
cylinder_layer->space = openxr_api->get_play_space();
|
||||
cylinder_layer->subImage.swapchain = swapchain_info.get_swapchain();
|
||||
cylinder_layer->subImage.imageArrayIndex = 0;
|
||||
cylinder_layer->subImage.imageRect.offset.x = 0;
|
||||
cylinder_layer->subImage.imageRect.offset.y = 0;
|
||||
cylinder_layer->subImage.imageRect.extent.width = swapchain_size.width;
|
||||
cylinder_layer->subImage.imageRect.extent.height = swapchain_size.height;
|
||||
cylinder_layer->subImage = subimage;
|
||||
} break;
|
||||
|
||||
case XR_TYPE_COMPOSITION_LAYER_EQUIRECT2_KHR: {
|
||||
XrCompositionLayerEquirect2KHR *equirect_layer = (XrCompositionLayerEquirect2KHR *)composition_layer;
|
||||
equirect_layer->space = openxr_api->get_play_space();
|
||||
equirect_layer->subImage.swapchain = swapchain_info.get_swapchain();
|
||||
equirect_layer->subImage.imageArrayIndex = 0;
|
||||
equirect_layer->subImage.imageRect.offset.x = 0;
|
||||
equirect_layer->subImage.imageRect.offset.y = 0;
|
||||
equirect_layer->subImage.imageRect.extent.width = swapchain_size.width;
|
||||
equirect_layer->subImage.imageRect.extent.height = swapchain_size.height;
|
||||
equirect_layer->subImage = subimage;
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
|
@ -261,27 +393,49 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
|
|||
return composition_layer;
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::update_swapchain_sub_image(XrSwapchainSubImage &r_subimage) {
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (use_android_surface) {
|
||||
r_subimage.swapchain = android_surface.swapchain;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
XrSwapchain swapchain = subviewport.swapchain_info.get_swapchain();
|
||||
|
||||
if (swapchain && subviewport.swapchain_info.is_image_acquired()) {
|
||||
subviewport.swapchain_info.release();
|
||||
}
|
||||
|
||||
r_subimage.swapchain = swapchain;
|
||||
}
|
||||
|
||||
r_subimage.imageRect.extent.width = swapchain_size.width;
|
||||
r_subimage.imageRect.extent.height = swapchain_size.height;
|
||||
}
|
||||
|
||||
bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p_static_image) {
|
||||
ERR_FAIL_COND_V(use_android_surface, false);
|
||||
|
||||
if (openxr_api == nullptr || composition_layer_extension == nullptr) {
|
||||
// OpenXR not initialized or we're in the editor?
|
||||
return false;
|
||||
}
|
||||
if (!composition_layer_extension->is_available(composition_layer->type)) {
|
||||
if (!composition_layer_extension->is_available(get_openxr_type())) {
|
||||
// Selected type is not supported?
|
||||
return false;
|
||||
}
|
||||
|
||||
// See if our current swapchain is outdated.
|
||||
if (swapchain_info.get_swapchain() != XR_NULL_HANDLE) {
|
||||
if (subviewport.swapchain_info.get_swapchain() != XR_NULL_HANDLE) {
|
||||
// If this swap chain, or the previous one, were static, then we can't reuse it.
|
||||
if (swapchain_size == viewport_size && !p_static_image && !static_image) {
|
||||
if (swapchain_size == subviewport.viewport_size && !p_static_image && !subviewport.static_image) {
|
||||
// We're all good! Just acquire it.
|
||||
// We can ignore should_render here, return will be false.
|
||||
bool should_render = true;
|
||||
return swapchain_info.acquire(should_render);
|
||||
return subviewport.swapchain_info.acquire(should_render);
|
||||
}
|
||||
|
||||
swapchain_info.queue_free();
|
||||
subviewport.swapchain_info.queue_free();
|
||||
}
|
||||
|
||||
// Create our new swap chain
|
||||
|
|
@ -292,7 +446,7 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
|
|||
if (p_static_image) {
|
||||
create_flags |= XR_SWAPCHAIN_CREATE_STATIC_IMAGE_BIT;
|
||||
}
|
||||
if (!swapchain_info.create(create_flags, XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, swapchain_format, viewport_size.width, viewport_size.height, sample_count, array_size)) {
|
||||
if (!subviewport.swapchain_info.create(create_flags, XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, swapchain_format, subviewport.viewport_size.width, subviewport.viewport_size.height, sample_count, array_size)) {
|
||||
swapchain_size = Size2i();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -300,26 +454,40 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
|
|||
// Acquire our image so we can start rendering into it,
|
||||
// we can ignore should_render here, ret will be false.
|
||||
bool should_render = true;
|
||||
bool ret = swapchain_info.acquire(should_render);
|
||||
bool ret = subviewport.swapchain_info.acquire(should_render);
|
||||
|
||||
swapchain_size = viewport_size;
|
||||
static_image = p_static_image;
|
||||
swapchain_size = subviewport.viewport_size;
|
||||
subviewport.static_image = p_static_image;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OpenXRViewportCompositionLayerProvider::free_swapchain() {
|
||||
if (swapchain_info.get_swapchain() != XR_NULL_HANDLE) {
|
||||
swapchain_info.queue_free();
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (use_android_surface) {
|
||||
if (android_surface.swapchain != XR_NULL_HANDLE) {
|
||||
composition_layer_extension->free_android_surface_swapchain(android_surface.swapchain);
|
||||
|
||||
android_surface.swapchain = XR_NULL_HANDLE;
|
||||
android_surface.surface.unref();
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (subviewport.swapchain_info.get_swapchain() != XR_NULL_HANDLE) {
|
||||
subviewport.swapchain_info.queue_free();
|
||||
}
|
||||
subviewport.static_image = false;
|
||||
}
|
||||
|
||||
swapchain_size = Size2i();
|
||||
static_image = false;
|
||||
}
|
||||
|
||||
RID OpenXRViewportCompositionLayerProvider::get_current_swapchain_texture() {
|
||||
ERR_FAIL_COND_V(use_android_surface, RID());
|
||||
|
||||
if (openxr_api == nullptr) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
return swapchain_info.get_image();
|
||||
return subviewport.swapchain_info.get_image();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,15 @@
|
|||
|
||||
#include "../openxr_api.h"
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <jni.h>
|
||||
|
||||
// Copied here from openxr_platform.h, in order to avoid including that whole header,
|
||||
// which can cause compilation issues on some platforms.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrCreateSwapchainAndroidSurfaceKHR)(XrSession session, const XrSwapchainCreateInfo *info, XrSwapchain *swapchain, jobject *surface);
|
||||
#endif
|
||||
|
||||
class JavaObject;
|
||||
class OpenXRViewportCompositionLayerProvider;
|
||||
|
||||
// This extension provides access to composition layers for displaying 2D content through the XR compositor.
|
||||
|
|
@ -49,7 +58,8 @@ public:
|
|||
virtual ~OpenXRCompositionLayerExtension() override;
|
||||
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
virtual void on_session_created(const XrSession p_instance) override;
|
||||
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||
virtual void on_session_created(const XrSession p_session) override;
|
||||
virtual void on_session_destroyed() override;
|
||||
virtual void on_pre_render() override;
|
||||
|
||||
|
|
@ -61,6 +71,12 @@ public:
|
|||
void unregister_viewport_composition_layer_provider(OpenXRViewportCompositionLayerProvider *p_composition_layer);
|
||||
|
||||
bool is_available(XrStructureType p_which);
|
||||
bool is_android_surface_swapchain_available() { return android_surface_ext_available; }
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
bool create_android_surface_swapchain(XrSwapchainCreateInfo *p_info, XrSwapchain *r_swapchain, jobject *r_surface);
|
||||
void free_android_surface_swapchain(XrSwapchain p_swapchain);
|
||||
#endif
|
||||
|
||||
private:
|
||||
static OpenXRCompositionLayerExtension *singleton;
|
||||
|
|
@ -69,6 +85,15 @@ private:
|
|||
|
||||
bool cylinder_ext_available = false;
|
||||
bool equirect_ext_available = false;
|
||||
bool android_surface_ext_available = false;
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
Vector<XrSwapchain> android_surface_swapchain_free_queue;
|
||||
void free_queued_android_surface_swapchains();
|
||||
|
||||
EXT_PROTO_XRRESULT_FUNC1(xrDestroySwapchain, (XrSwapchain), swapchain)
|
||||
EXT_PROTO_XRRESULT_FUNC4(xrCreateSwapchainAndroidSurfaceKHR, (XrSession), session, (const XrSwapchainCreateInfo *), info, (XrSwapchain *), swapchain, (jobject *), surface)
|
||||
#endif
|
||||
};
|
||||
|
||||
class OpenXRViewportCompositionLayerProvider {
|
||||
|
|
@ -78,20 +103,37 @@ class OpenXRViewportCompositionLayerProvider {
|
|||
Dictionary extension_property_values;
|
||||
bool extension_property_values_changed = true;
|
||||
|
||||
RID viewport;
|
||||
Size2i viewport_size;
|
||||
struct {
|
||||
RID viewport;
|
||||
Size2i viewport_size;
|
||||
OpenXRAPI::OpenXRSwapChainInfo swapchain_info;
|
||||
bool static_image = false;
|
||||
} subviewport;
|
||||
|
||||
OpenXRAPI::OpenXRSwapChainInfo swapchain_info;
|
||||
#ifdef ANDROID_ENABLED
|
||||
struct {
|
||||
XrSwapchain swapchain = XR_NULL_HANDLE;
|
||||
Ref<JavaObject> surface;
|
||||
} android_surface;
|
||||
#endif
|
||||
|
||||
bool use_android_surface = false;
|
||||
Size2i swapchain_size;
|
||||
bool static_image = false;
|
||||
|
||||
OpenXRAPI *openxr_api = nullptr;
|
||||
OpenXRCompositionLayerExtension *composition_layer_extension = nullptr;
|
||||
|
||||
// Only for SubViewports.
|
||||
bool update_and_acquire_swapchain(bool p_static_image);
|
||||
void free_swapchain();
|
||||
RID get_current_swapchain_texture();
|
||||
|
||||
void update_swapchain_sub_image(XrSwapchainSubImage &r_swapchain_sub_image);
|
||||
void free_swapchain();
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
void create_android_surface();
|
||||
#endif
|
||||
|
||||
public:
|
||||
XrStructureType get_openxr_type() { return composition_layer->type; }
|
||||
|
||||
|
|
@ -102,7 +144,12 @@ public:
|
|||
bool get_alpha_blend() const { return alpha_blend; }
|
||||
|
||||
void set_viewport(RID p_viewport, Size2i p_size);
|
||||
RID get_viewport() const { return viewport; }
|
||||
RID get_viewport() const { return subviewport.viewport; }
|
||||
|
||||
void set_use_android_surface(bool p_enable, Size2i p_size);
|
||||
bool get_use_android_surface() const { return use_android_surface; }
|
||||
|
||||
Ref<JavaObject> get_android_surface();
|
||||
|
||||
void set_extension_property_values(const Dictionary &p_property_values);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,287 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_debug_utils_extension.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_debug_utils_extension.h"
|
||||
|
||||
#include "../openxr_api.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
OpenXRDebugUtilsExtension *OpenXRDebugUtilsExtension::singleton = nullptr;
|
||||
|
||||
OpenXRDebugUtilsExtension *OpenXRDebugUtilsExtension::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
OpenXRDebugUtilsExtension::OpenXRDebugUtilsExtension() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
OpenXRDebugUtilsExtension::~OpenXRDebugUtilsExtension() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
HashMap<String, bool *> OpenXRDebugUtilsExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
request_extensions[XR_EXT_DEBUG_UTILS_EXTENSION_NAME] = &debug_utils_ext;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::on_instance_created(const XrInstance p_instance) {
|
||||
if (debug_utils_ext) {
|
||||
EXT_INIT_XR_FUNC(xrCreateDebugUtilsMessengerEXT);
|
||||
EXT_INIT_XR_FUNC(xrDestroyDebugUtilsMessengerEXT);
|
||||
EXT_INIT_XR_FUNC(xrSetDebugUtilsObjectNameEXT);
|
||||
EXT_INIT_XR_FUNC(xrSessionBeginDebugUtilsLabelRegionEXT);
|
||||
EXT_INIT_XR_FUNC(xrSessionEndDebugUtilsLabelRegionEXT);
|
||||
EXT_INIT_XR_FUNC(xrSessionInsertDebugUtilsLabelEXT);
|
||||
|
||||
debug_utils_ext = xrCreateDebugUtilsMessengerEXT_ptr && xrDestroyDebugUtilsMessengerEXT_ptr && xrSetDebugUtilsObjectNameEXT_ptr && xrSessionBeginDebugUtilsLabelRegionEXT_ptr && xrSessionEndDebugUtilsLabelRegionEXT_ptr && xrSessionInsertDebugUtilsLabelEXT_ptr;
|
||||
} else {
|
||||
WARN_PRINT("OpenXR: The debug utils extension is not available on this runtime. Debug logging is not enabled!");
|
||||
}
|
||||
|
||||
// On successful init, setup our default messenger.
|
||||
if (debug_utils_ext) {
|
||||
int max_severity = GLOBAL_GET("xr/openxr/extensions/debug_utils");
|
||||
int types = GLOBAL_GET("xr/openxr/extensions/debug_message_types");
|
||||
|
||||
XrDebugUtilsMessageSeverityFlagsEXT message_severities = 0;
|
||||
|
||||
if (max_severity >= 1) {
|
||||
message_severities |= XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||
}
|
||||
if (max_severity >= 2) {
|
||||
message_severities |= XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
|
||||
}
|
||||
if (max_severity >= 3) {
|
||||
message_severities |= XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
|
||||
}
|
||||
if (max_severity >= 4) {
|
||||
message_severities |= XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
||||
}
|
||||
|
||||
XrDebugUtilsMessageTypeFlagsEXT message_types = 0;
|
||||
|
||||
// These should match up but just to be safe and future proof...
|
||||
if (types & 1) {
|
||||
message_types |= XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
|
||||
}
|
||||
if (types & 2) {
|
||||
message_types |= XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
|
||||
}
|
||||
if (types & 4) {
|
||||
message_types |= XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||
}
|
||||
if (types & 8) {
|
||||
message_types |= XR_DEBUG_UTILS_MESSAGE_TYPE_CONFORMANCE_BIT_EXT;
|
||||
}
|
||||
|
||||
XrDebugUtilsMessengerCreateInfoEXT callback_info = {
|
||||
XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, // type
|
||||
nullptr, // next
|
||||
message_severities, // messageSeverities
|
||||
message_types, // messageTypes
|
||||
&OpenXRDebugUtilsExtension::_debug_callback, // userCallback
|
||||
nullptr, // userData
|
||||
};
|
||||
|
||||
XrResult result = xrCreateDebugUtilsMessengerEXT(p_instance, &callback_info, &default_messenger);
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to create debug callback [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
|
||||
set_object_name(XR_OBJECT_TYPE_INSTANCE, uint64_t(p_instance), "Main Godot OpenXR Instance");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::on_instance_destroyed() {
|
||||
if (default_messenger != XR_NULL_HANDLE) {
|
||||
XrResult result = xrDestroyDebugUtilsMessengerEXT(default_messenger);
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to destroy debug callback [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
|
||||
default_messenger = XR_NULL_HANDLE;
|
||||
}
|
||||
|
||||
xrCreateDebugUtilsMessengerEXT_ptr = nullptr;
|
||||
xrDestroyDebugUtilsMessengerEXT_ptr = nullptr;
|
||||
xrSetDebugUtilsObjectNameEXT_ptr = nullptr;
|
||||
xrSessionBeginDebugUtilsLabelRegionEXT_ptr = nullptr;
|
||||
xrSessionEndDebugUtilsLabelRegionEXT_ptr = nullptr;
|
||||
xrSessionInsertDebugUtilsLabelEXT_ptr = nullptr;
|
||||
debug_utils_ext = false;
|
||||
}
|
||||
|
||||
bool OpenXRDebugUtilsExtension::get_active() {
|
||||
return debug_utils_ext;
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::set_object_name(XrObjectType p_object_type, uint64_t p_object_handle, const char *p_object_name) {
|
||||
ERR_FAIL_COND(!debug_utils_ext);
|
||||
ERR_FAIL_NULL(xrSetDebugUtilsObjectNameEXT_ptr);
|
||||
|
||||
const XrDebugUtilsObjectNameInfoEXT space_name_info = {
|
||||
XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, // type
|
||||
nullptr, // next
|
||||
p_object_type, // objectType
|
||||
p_object_handle, // objectHandle
|
||||
p_object_name, // objectName
|
||||
};
|
||||
|
||||
XrResult result = xrSetDebugUtilsObjectNameEXT_ptr(OpenXRAPI::get_singleton()->get_instance(), &space_name_info);
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to set object name [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::begin_debug_label_region(const char *p_label_name) {
|
||||
ERR_FAIL_COND(!debug_utils_ext);
|
||||
ERR_FAIL_NULL(xrSessionBeginDebugUtilsLabelRegionEXT_ptr);
|
||||
|
||||
const XrDebugUtilsLabelEXT session_active_region_label = {
|
||||
XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type
|
||||
nullptr, // next
|
||||
p_label_name, // labelName
|
||||
};
|
||||
|
||||
XrResult result = xrSessionBeginDebugUtilsLabelRegionEXT_ptr(OpenXRAPI::get_singleton()->get_session(), &session_active_region_label);
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to begin label region [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::end_debug_label_region() {
|
||||
ERR_FAIL_COND(!debug_utils_ext);
|
||||
ERR_FAIL_NULL(xrSessionEndDebugUtilsLabelRegionEXT_ptr);
|
||||
|
||||
XrResult result = xrSessionEndDebugUtilsLabelRegionEXT_ptr(OpenXRAPI::get_singleton()->get_session());
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to end label region [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRDebugUtilsExtension::insert_debug_label(const char *p_label_name) {
|
||||
ERR_FAIL_COND(!debug_utils_ext);
|
||||
ERR_FAIL_NULL(xrSessionInsertDebugUtilsLabelEXT_ptr);
|
||||
|
||||
const XrDebugUtilsLabelEXT session_active_region_label = {
|
||||
XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type
|
||||
nullptr, // next
|
||||
p_label_name, // labelName
|
||||
};
|
||||
|
||||
XrResult result = xrSessionInsertDebugUtilsLabelEXT_ptr(OpenXRAPI::get_singleton()->get_session(), &session_active_region_label);
|
||||
if (XR_FAILED(result)) {
|
||||
ERR_PRINT("OpenXR: Failed to insert label [" + OpenXRAPI::get_singleton()->get_error_string(result) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
XrBool32 XRAPI_PTR OpenXRDebugUtilsExtension::_debug_callback(XrDebugUtilsMessageSeverityFlagsEXT p_message_severity, XrDebugUtilsMessageTypeFlagsEXT p_message_types, const XrDebugUtilsMessengerCallbackDataEXT *p_callback_data, void *p_user_data) {
|
||||
OpenXRDebugUtilsExtension *debug_utils = OpenXRDebugUtilsExtension::get_singleton();
|
||||
|
||||
if (debug_utils) {
|
||||
return debug_utils->debug_callback(p_message_severity, p_message_types, p_callback_data, p_user_data);
|
||||
}
|
||||
|
||||
return XR_FALSE;
|
||||
}
|
||||
|
||||
XrBool32 OpenXRDebugUtilsExtension::debug_callback(XrDebugUtilsMessageSeverityFlagsEXT p_message_severity, XrDebugUtilsMessageTypeFlagsEXT p_message_types, const XrDebugUtilsMessengerCallbackDataEXT *p_callback_data, void *p_user_data) {
|
||||
String msg;
|
||||
|
||||
ERR_FAIL_NULL_V(p_callback_data, XR_FALSE);
|
||||
|
||||
if (p_message_types == XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) {
|
||||
msg = ", type: General";
|
||||
} else if (p_message_types == XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) {
|
||||
msg = ", type: Validation";
|
||||
} else if (p_message_types == XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) {
|
||||
msg = ", type: Performance";
|
||||
} else if (p_message_types == XR_DEBUG_UTILS_MESSAGE_TYPE_CONFORMANCE_BIT_EXT) {
|
||||
msg = ", type: Conformance";
|
||||
} else {
|
||||
msg = ", type: Unknown (" + String::num_uint64(p_message_types) + ")";
|
||||
}
|
||||
|
||||
if (p_callback_data->functionName) {
|
||||
msg += ", function Name: " + String(p_callback_data->functionName);
|
||||
}
|
||||
if (p_callback_data->messageId) {
|
||||
msg += "\nMessage ID: " + String(p_callback_data->messageId);
|
||||
}
|
||||
if (p_callback_data->message) {
|
||||
msg += "\nMessage: " + String(p_callback_data->message);
|
||||
}
|
||||
|
||||
if (p_callback_data->objectCount > 0) {
|
||||
String objects;
|
||||
|
||||
for (uint32_t i = 0; i < p_callback_data->objectCount; i++) {
|
||||
if (!objects.is_empty()) {
|
||||
objects += ", ";
|
||||
}
|
||||
objects += p_callback_data->objects[i].objectName;
|
||||
}
|
||||
|
||||
msg += "\nObjects: " + objects;
|
||||
}
|
||||
|
||||
if (p_callback_data->sessionLabelCount > 0) {
|
||||
String labels;
|
||||
|
||||
for (uint32_t i = 0; i < p_callback_data->sessionLabelCount; i++) {
|
||||
if (!labels.is_empty()) {
|
||||
labels += ", ";
|
||||
}
|
||||
labels += p_callback_data->sessionLabels[i].labelName;
|
||||
}
|
||||
|
||||
msg += "\nLabels: " + labels;
|
||||
}
|
||||
|
||||
if (p_message_severity == XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
||||
ERR_PRINT("OpenXR: Severity: Error" + msg);
|
||||
} else if (p_message_severity == XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
||||
WARN_PRINT("OpenXR: Severity: Warning" + msg);
|
||||
} else if (p_message_severity == XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
|
||||
print_line("OpenXR: Severity: Info" + msg);
|
||||
} else if (p_message_severity == XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
|
||||
// This is a bit double because we won't output this unless verbose messaging in Godot is on.
|
||||
print_verbose("OpenXR: Severity: Verbose" + msg);
|
||||
}
|
||||
|
||||
return XR_FALSE;
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_debug_utils_extension.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_DEBUG_UTILS_EXTENSION_H
|
||||
#define OPENXR_DEBUG_UTILS_EXTENSION_H
|
||||
|
||||
#include "../util.h"
|
||||
#include "openxr_extension_wrapper.h"
|
||||
|
||||
class OpenXRDebugUtilsExtension : public OpenXRExtensionWrapper {
|
||||
public:
|
||||
static OpenXRDebugUtilsExtension *get_singleton();
|
||||
|
||||
OpenXRDebugUtilsExtension();
|
||||
virtual ~OpenXRDebugUtilsExtension() override;
|
||||
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||
virtual void on_instance_destroyed() override;
|
||||
|
||||
bool get_active();
|
||||
|
||||
void set_object_name(XrObjectType p_object_type, uint64_t p_object_handle, const char *p_object_name);
|
||||
void begin_debug_label_region(const char *p_label_name);
|
||||
void end_debug_label_region();
|
||||
void insert_debug_label(const char *p_label_name);
|
||||
|
||||
private:
|
||||
static OpenXRDebugUtilsExtension *singleton;
|
||||
|
||||
// related extensions
|
||||
bool debug_utils_ext = false;
|
||||
|
||||
// debug handlers
|
||||
XrDebugUtilsMessengerEXT default_messenger = XR_NULL_HANDLE;
|
||||
|
||||
static XrBool32 XRAPI_PTR _debug_callback(XrDebugUtilsMessageSeverityFlagsEXT p_message_severity, XrDebugUtilsMessageTypeFlagsEXT p_message_types, const XrDebugUtilsMessengerCallbackDataEXT *p_callback_data, void *p_user_data);
|
||||
XrBool32 debug_callback(XrDebugUtilsMessageSeverityFlagsEXT p_message_severity, XrDebugUtilsMessageTypeFlagsEXT p_message_types, const XrDebugUtilsMessengerCallbackDataEXT *p_callback_data, void *p_user_data);
|
||||
|
||||
// OpenXR API call wrappers
|
||||
EXT_PROTO_XRRESULT_FUNC3(xrCreateDebugUtilsMessengerEXT, (XrInstance), p_instance, (const XrDebugUtilsMessengerCreateInfoEXT *), p_create_info, (XrDebugUtilsMessengerEXT *), p_messenger)
|
||||
EXT_PROTO_XRRESULT_FUNC1(xrDestroyDebugUtilsMessengerEXT, (XrDebugUtilsMessengerEXT), p_messenger)
|
||||
EXT_PROTO_XRRESULT_FUNC2(xrSetDebugUtilsObjectNameEXT, (XrInstance), p_instance, (const XrDebugUtilsObjectNameInfoEXT *), p_name_info)
|
||||
EXT_PROTO_XRRESULT_FUNC2(xrSessionBeginDebugUtilsLabelRegionEXT, (XrSession), p_session, (const XrDebugUtilsLabelEXT *), p_label_info)
|
||||
EXT_PROTO_XRRESULT_FUNC1(xrSessionEndDebugUtilsLabelRegionEXT, (XrSession), p_session)
|
||||
EXT_PROTO_XRRESULT_FUNC2(xrSessionInsertDebugUtilsLabelEXT, (XrSession), p_session, (const XrDebugUtilsLabelEXT *), p_label_info)
|
||||
};
|
||||
|
||||
#endif // OPENXR_DEBUG_UTILS_EXTENSION_H
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_dpad_binding_extension.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_dpad_binding_extension.h"
|
||||
#include "../openxr_api.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
|
||||
// Implementation for:
|
||||
// https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#XR_EXT_dpad_binding
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenXRDPadBindingExtension
|
||||
|
||||
OpenXRDPadBindingExtension *OpenXRDPadBindingExtension::singleton = nullptr;
|
||||
|
||||
OpenXRDPadBindingExtension *OpenXRDPadBindingExtension::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
OpenXRDPadBindingExtension::OpenXRDPadBindingExtension() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
OpenXRDPadBindingExtension::~OpenXRDPadBindingExtension() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
HashMap<String, bool *> OpenXRDPadBindingExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
// Note, we're dependent on the binding modifier extension, this may be requested by multiple extension wrappers.
|
||||
request_extensions[XR_KHR_BINDING_MODIFICATION_EXTENSION_NAME] = &binding_modifier_ext;
|
||||
request_extensions[XR_EXT_DPAD_BINDING_EXTENSION_NAME] = &dpad_binding_ext;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
bool OpenXRDPadBindingExtension::is_available() {
|
||||
return binding_modifier_ext && dpad_binding_ext;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenXRDpadBindingModifier
|
||||
|
||||
void OpenXRDpadBindingModifier::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_action_set", "action_set"), &OpenXRDpadBindingModifier::set_action_set);
|
||||
ClassDB::bind_method(D_METHOD("get_action_set"), &OpenXRDpadBindingModifier::get_action_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "action_set", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRActionSet"), "set_action_set", "get_action_set");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_input_path", "input_path"), &OpenXRDpadBindingModifier::set_input_path);
|
||||
ClassDB::bind_method(D_METHOD("get_input_path"), &OpenXRDpadBindingModifier::get_input_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "input_path", PROPERTY_HINT_TYPE_STRING, "binding_path"), "set_input_path", "get_input_path");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_threshold", "threshold"), &OpenXRDpadBindingModifier::set_threshold);
|
||||
ClassDB::bind_method(D_METHOD("get_threshold"), &OpenXRDpadBindingModifier::get_threshold);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_threshold", "get_threshold");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_threshold_released", "threshold_released"), &OpenXRDpadBindingModifier::set_threshold_released);
|
||||
ClassDB::bind_method(D_METHOD("get_threshold_released"), &OpenXRDpadBindingModifier::get_threshold_released);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "threshold_released", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_threshold_released", "get_threshold_released");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_center_region", "center_region"), &OpenXRDpadBindingModifier::set_center_region);
|
||||
ClassDB::bind_method(D_METHOD("get_center_region"), &OpenXRDpadBindingModifier::get_center_region);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "center_region", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_center_region", "get_center_region");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_wedge_angle", "wedge_angle"), &OpenXRDpadBindingModifier::set_wedge_angle);
|
||||
ClassDB::bind_method(D_METHOD("get_wedge_angle"), &OpenXRDpadBindingModifier::get_wedge_angle);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wedge_angle", PROPERTY_HINT_RANGE, "1.0,180.0,0.1,radians_as_degrees"), "set_wedge_angle", "get_wedge_angle");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_is_sticky", "is_sticky"), &OpenXRDpadBindingModifier::set_is_sticky);
|
||||
ClassDB::bind_method(D_METHOD("get_is_sticky"), &OpenXRDpadBindingModifier::get_is_sticky);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_sticky"), "set_is_sticky", "get_is_sticky");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_on_haptic", "haptic"), &OpenXRDpadBindingModifier::set_on_haptic);
|
||||
ClassDB::bind_method(D_METHOD("get_on_haptic"), &OpenXRDpadBindingModifier::get_on_haptic);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "on_haptic", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRHapticBase"), "set_on_haptic", "get_on_haptic");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_off_haptic", "haptic"), &OpenXRDpadBindingModifier::set_off_haptic);
|
||||
ClassDB::bind_method(D_METHOD("get_off_haptic"), &OpenXRDpadBindingModifier::get_off_haptic);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "off_haptic", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRHapticBase"), "set_off_haptic", "get_off_haptic");
|
||||
}
|
||||
|
||||
OpenXRDpadBindingModifier::OpenXRDpadBindingModifier() {
|
||||
ERR_FAIL_COND(dpad_bindings_data.resize_zeroed(sizeof(XrInteractionProfileDpadBindingEXT)) != OK);
|
||||
dpad_bindings = (XrInteractionProfileDpadBindingEXT *)dpad_bindings_data.ptrw();
|
||||
|
||||
dpad_bindings->type = XR_TYPE_INTERACTION_PROFILE_DPAD_BINDING_EXT;
|
||||
dpad_bindings->next = nullptr;
|
||||
|
||||
dpad_bindings->forceThreshold = 0.6;
|
||||
dpad_bindings->forceThresholdReleased = 0.4;
|
||||
dpad_bindings->centerRegion = 0.1;
|
||||
dpad_bindings->wedgeAngle = Math::deg_to_rad(90.0);
|
||||
dpad_bindings->isSticky = false;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_action_set(const Ref<OpenXRActionSet> p_action_set) {
|
||||
action_set = p_action_set;
|
||||
}
|
||||
|
||||
Ref<OpenXRActionSet> OpenXRDpadBindingModifier::get_action_set() const {
|
||||
return action_set;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_input_path(const String &p_input_path) {
|
||||
input_path = p_input_path;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
String OpenXRDpadBindingModifier::get_input_path() const {
|
||||
return input_path;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_threshold(float p_threshold) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
ERR_FAIL_COND(p_threshold < 0.0 || p_threshold > 1.0);
|
||||
|
||||
dpad_bindings->forceThreshold = p_threshold;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRDpadBindingModifier::get_threshold() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, 0.0);
|
||||
return dpad_bindings->forceThreshold;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_threshold_released(float p_threshold) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
ERR_FAIL_COND(p_threshold < 0.0 || p_threshold > 1.0);
|
||||
|
||||
dpad_bindings->forceThresholdReleased = p_threshold;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRDpadBindingModifier::get_threshold_released() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, 0.0);
|
||||
return dpad_bindings->forceThresholdReleased;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_center_region(float p_center_region) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
ERR_FAIL_COND(p_center_region < 0.0 || p_center_region > 1.0);
|
||||
|
||||
dpad_bindings->centerRegion = p_center_region;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRDpadBindingModifier::get_center_region() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, 0.0);
|
||||
return dpad_bindings->centerRegion;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_wedge_angle(float p_wedge_angle) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
dpad_bindings->wedgeAngle = p_wedge_angle;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRDpadBindingModifier::get_wedge_angle() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, 0.0);
|
||||
return dpad_bindings->wedgeAngle;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_wedge_angle_deg(float p_wedge_angle) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
dpad_bindings->wedgeAngle = Math::deg_to_rad(p_wedge_angle);
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRDpadBindingModifier::get_wedge_angle_deg() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, 0.0);
|
||||
return Math::rad_to_deg(dpad_bindings->wedgeAngle);
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_is_sticky(bool p_sticky) {
|
||||
ERR_FAIL_NULL(dpad_bindings);
|
||||
dpad_bindings->isSticky = p_sticky;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
bool OpenXRDpadBindingModifier::get_is_sticky() const {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, false);
|
||||
return dpad_bindings->isSticky;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_on_haptic(const Ref<OpenXRHapticBase> &p_haptic) {
|
||||
on_haptic = p_haptic;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<OpenXRHapticBase> OpenXRDpadBindingModifier::get_on_haptic() const {
|
||||
return on_haptic;
|
||||
}
|
||||
|
||||
void OpenXRDpadBindingModifier::set_off_haptic(const Ref<OpenXRHapticBase> &p_haptic) {
|
||||
off_haptic = p_haptic;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<OpenXRHapticBase> OpenXRDpadBindingModifier::get_off_haptic() const {
|
||||
return off_haptic;
|
||||
}
|
||||
|
||||
PackedByteArray OpenXRDpadBindingModifier::get_ip_modification() {
|
||||
ERR_FAIL_NULL_V(dpad_bindings, PackedByteArray());
|
||||
|
||||
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL_V(openxr_api, PackedByteArray());
|
||||
|
||||
OpenXRDPadBindingExtension *dpad_binding_ext = OpenXRDPadBindingExtension::get_singleton();
|
||||
if (!dpad_binding_ext || !dpad_binding_ext->is_available()) {
|
||||
// Extension not enabled!
|
||||
WARN_PRINT("DPad binding extension is not enabled or available.");
|
||||
return PackedByteArray();
|
||||
}
|
||||
|
||||
dpad_bindings->binding = openxr_api->get_xr_path(input_path);
|
||||
ERR_FAIL_COND_V(dpad_bindings->binding == XR_NULL_PATH, PackedByteArray());
|
||||
|
||||
// Get our action set
|
||||
ERR_FAIL_COND_V(action_set.is_null(), PackedByteArray());
|
||||
RID action_set_rid = openxr_api->find_action_set(action_set->get_name());
|
||||
ERR_FAIL_COND_V(!action_set_rid.is_valid(), PackedByteArray());
|
||||
dpad_bindings->actionSet = openxr_api->action_set_get_handle(action_set_rid);
|
||||
|
||||
// These are set already:
|
||||
// - forceThreshold
|
||||
// - forceThresholdReleased
|
||||
// - centerRegion
|
||||
// - wedgeAngle
|
||||
// - isSticky
|
||||
|
||||
if (on_haptic.is_valid()) {
|
||||
dpad_bindings->onHaptic = on_haptic->get_xr_structure();
|
||||
} else {
|
||||
dpad_bindings->onHaptic = nullptr;
|
||||
}
|
||||
|
||||
if (off_haptic.is_valid()) {
|
||||
dpad_bindings->offHaptic = off_haptic->get_xr_structure();
|
||||
} else {
|
||||
dpad_bindings->offHaptic = nullptr;
|
||||
}
|
||||
|
||||
return dpad_bindings_data;
|
||||
}
|
||||
109
engine/modules/openxr/extensions/openxr_dpad_binding_extension.h
Normal file
109
engine/modules/openxr/extensions/openxr_dpad_binding_extension.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_dpad_binding_extension.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_DPAD_BINDING_EXTENSION_H
|
||||
#define OPENXR_DPAD_BINDING_EXTENSION_H
|
||||
|
||||
#include "../action_map/openxr_action_set.h"
|
||||
#include "../action_map/openxr_binding_modifier.h"
|
||||
#include "../action_map/openxr_haptic_feedback.h"
|
||||
#include "../util.h"
|
||||
#include "openxr_extension_wrapper.h"
|
||||
|
||||
class OpenXRDPadBindingExtension : public OpenXRExtensionWrapper {
|
||||
public:
|
||||
static OpenXRDPadBindingExtension *get_singleton();
|
||||
|
||||
OpenXRDPadBindingExtension();
|
||||
virtual ~OpenXRDPadBindingExtension() override;
|
||||
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
|
||||
bool is_available();
|
||||
|
||||
private:
|
||||
static OpenXRDPadBindingExtension *singleton;
|
||||
|
||||
bool binding_modifier_ext = false;
|
||||
bool dpad_binding_ext = false;
|
||||
};
|
||||
|
||||
class OpenXRDpadBindingModifier : public OpenXRIPBindingModifier {
|
||||
GDCLASS(OpenXRDpadBindingModifier, OpenXRIPBindingModifier);
|
||||
|
||||
private:
|
||||
PackedByteArray dpad_bindings_data;
|
||||
XrInteractionProfileDpadBindingEXT *dpad_bindings = nullptr;
|
||||
String input_path;
|
||||
Ref<OpenXRActionSet> action_set;
|
||||
Ref<OpenXRHapticBase> on_haptic;
|
||||
Ref<OpenXRHapticBase> off_haptic;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
OpenXRDpadBindingModifier();
|
||||
|
||||
void set_action_set(const Ref<OpenXRActionSet> p_action_set);
|
||||
Ref<OpenXRActionSet> get_action_set() const;
|
||||
|
||||
void set_input_path(const String &p_input_path);
|
||||
String get_input_path() const;
|
||||
|
||||
void set_threshold(float p_threshold);
|
||||
float get_threshold() const;
|
||||
|
||||
void set_threshold_released(float p_threshold);
|
||||
float get_threshold_released() const;
|
||||
|
||||
void set_center_region(float p_center_region);
|
||||
float get_center_region() const;
|
||||
|
||||
void set_wedge_angle(float p_wedge_angle);
|
||||
float get_wedge_angle() const;
|
||||
|
||||
void set_wedge_angle_deg(float p_wedge_angle);
|
||||
float get_wedge_angle_deg() const;
|
||||
|
||||
void set_is_sticky(bool p_sticky);
|
||||
bool get_is_sticky() const;
|
||||
|
||||
void set_on_haptic(const Ref<OpenXRHapticBase> &p_haptic);
|
||||
Ref<OpenXRHapticBase> get_on_haptic() const;
|
||||
|
||||
void set_off_haptic(const Ref<OpenXRHapticBase> &p_haptic);
|
||||
Ref<OpenXRHapticBase> get_off_haptic() const;
|
||||
|
||||
virtual String get_description() const override { return "DPad modifier"; }
|
||||
virtual PackedByteArray get_ip_modification() override;
|
||||
};
|
||||
|
||||
#endif // OPENXR_DPAD_BINDING_EXTENSION_H
|
||||
|
|
@ -57,11 +57,12 @@ public:
|
|||
// You should return the pointer to the last struct you define as your result.
|
||||
// If you are not adding any structs, just return `p_next_pointer`.
|
||||
// See existing extensions for examples of this implementation.
|
||||
virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) { return p_next_pointer; } // Add additional data structures when we interogate OpenXRS system abilities.
|
||||
virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) { return p_next_pointer; } // Add additional data structures when we interrogate OpenXRS system abilities.
|
||||
virtual void *set_instance_create_info_and_get_next_pointer(void *p_next_pointer) { return p_next_pointer; } // Add additional data structures when we create our OpenXR instance.
|
||||
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) { return p_next_pointer; } // Add additional data structures when we create our OpenXR session.
|
||||
virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) { return p_next_pointer; } // Add additional data structures when creating OpenXR swap chains.
|
||||
virtual void *set_hand_joint_locations_and_get_next_pointer(int p_hand_index, void *p_next_pointer) { return p_next_pointer; }
|
||||
virtual void *set_projection_views_and_get_next_pointer(int p_view_index, void *p_next_pointer) { return p_next_pointer; }
|
||||
|
||||
virtual PackedStringArray get_suggested_tracker_names() { return PackedStringArray(); }
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ public:
|
|||
virtual void on_before_instance_created() {} // `on_before_instance_created` is called before we create our OpenXR instance.
|
||||
virtual void on_instance_created(const XrInstance p_instance) {} // `on_instance_created` is called right after we've successfully created our OpenXR instance.
|
||||
virtual void on_instance_destroyed() {} // `on_instance_destroyed` is called right before we destroy our OpenXR instance.
|
||||
virtual void on_session_created(const XrSession p_instance) {} // `on_session_created` is called right after we've successfully created our OpenXR session.
|
||||
virtual void on_session_created(const XrSession p_session) {} // `on_session_created` is called right after we've successfully created our OpenXR session.
|
||||
virtual void on_session_destroyed() {} // `on_session_destroyed` is called right before we destroy our OpenXR session.
|
||||
|
||||
// `on_process` is called as part of our OpenXR process handling,
|
||||
|
|
@ -97,10 +98,11 @@ public:
|
|||
virtual void on_state_loss_pending() {} // `on_state_loss_pending` is called when the OpenXR session state is changed to loss pending.
|
||||
virtual void on_state_exiting() {} // `on_state_exiting` is called when the OpenXR session state is changed to exiting.
|
||||
|
||||
virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, Dictionary p_property_values, void *p_next_pointer) { return p_next_pointer; } // Add additional data structures to composition layers created via OpenXRCompositionLayer.
|
||||
virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, const Dictionary &p_property_values, void *p_next_pointer) { return p_next_pointer; } // Add additional data structures to composition layers created via OpenXRCompositionLayer.
|
||||
virtual void on_viewport_composition_layer_destroyed(const XrCompositionLayerBaseHeader *p_layer) {} // `on_viewport_composition_layer_destroyed` is called when a composition layer created via OpenXRCompositionLayer is destroyed.
|
||||
virtual void get_viewport_composition_layer_extension_properties(List<PropertyInfo> *p_property_list) {} // Get additional property definitions for OpenXRCompositionLayer.
|
||||
virtual Dictionary get_viewport_composition_layer_extension_property_defaults() { return Dictionary(); } // Get the default values for the additional property definitions for OpenXRCompositionLayer.
|
||||
virtual void *set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) { return p_next_pointer; }
|
||||
|
||||
// `on_event_polled` is called when there is an OpenXR event to process.
|
||||
// Should return true if the event was handled, false otherwise.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ void OpenXRExtensionWrapperExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_set_session_create_and_get_next_pointer, "next_pointer");
|
||||
GDVIRTUAL_BIND(_set_swapchain_create_info_and_get_next_pointer, "next_pointer");
|
||||
GDVIRTUAL_BIND(_set_hand_joint_locations_and_get_next_pointer, "hand_index", "next_pointer");
|
||||
GDVIRTUAL_BIND(_set_projection_views_and_get_next_pointer, "view_index", "next_pointer");
|
||||
GDVIRTUAL_BIND(_get_composition_layer_count);
|
||||
GDVIRTUAL_BIND(_get_composition_layer, "index");
|
||||
GDVIRTUAL_BIND(_get_composition_layer_order, "index");
|
||||
|
|
@ -51,6 +52,8 @@ void OpenXRExtensionWrapperExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_on_process);
|
||||
GDVIRTUAL_BIND(_on_pre_render);
|
||||
GDVIRTUAL_BIND(_on_main_swapchains_created);
|
||||
GDVIRTUAL_BIND(_on_pre_draw_viewport, "viewport");
|
||||
GDVIRTUAL_BIND(_on_post_draw_viewport, "viewport");
|
||||
GDVIRTUAL_BIND(_on_session_destroyed);
|
||||
GDVIRTUAL_BIND(_on_state_idle);
|
||||
GDVIRTUAL_BIND(_on_state_ready);
|
||||
|
|
@ -65,6 +68,7 @@ void OpenXRExtensionWrapperExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_get_viewport_composition_layer_extension_properties);
|
||||
GDVIRTUAL_BIND(_get_viewport_composition_layer_extension_property_defaults);
|
||||
GDVIRTUAL_BIND(_on_viewport_composition_layer_destroyed, "layer");
|
||||
GDVIRTUAL_BIND(_set_android_surface_swapchain_create_info_and_get_next_pointer, "property_values", "next_pointer");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_openxr_api"), &OpenXRExtensionWrapperExtension::get_openxr_api);
|
||||
ClassDB::bind_method(D_METHOD("register_extension_wrapper"), &OpenXRExtensionWrapperExtension::register_extension_wrapper);
|
||||
|
|
@ -137,6 +141,16 @@ void *OpenXRExtensionWrapperExtension::set_hand_joint_locations_and_get_next_poi
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void *OpenXRExtensionWrapperExtension::set_projection_views_and_get_next_pointer(int p_view_index, void *p_next_pointer) {
|
||||
uint64_t pointer = 0;
|
||||
|
||||
if (GDVIRTUAL_CALL(_set_projection_views_and_get_next_pointer, p_view_index, GDExtensionPtr<void>(p_next_pointer), pointer)) {
|
||||
return reinterpret_cast<void *>(pointer);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PackedStringArray OpenXRExtensionWrapperExtension::get_suggested_tracker_names() {
|
||||
PackedStringArray ret;
|
||||
|
||||
|
|
@ -207,6 +221,14 @@ void OpenXRExtensionWrapperExtension::on_session_destroyed() {
|
|||
GDVIRTUAL_CALL(_on_session_destroyed);
|
||||
}
|
||||
|
||||
void OpenXRExtensionWrapperExtension::on_pre_draw_viewport(RID p_render_target) {
|
||||
GDVIRTUAL_CALL(_on_pre_draw_viewport, p_render_target);
|
||||
}
|
||||
|
||||
void OpenXRExtensionWrapperExtension::on_post_draw_viewport(RID p_render_target) {
|
||||
GDVIRTUAL_CALL(_on_post_draw_viewport, p_render_target);
|
||||
}
|
||||
|
||||
void OpenXRExtensionWrapperExtension::on_state_idle() {
|
||||
GDVIRTUAL_CALL(_on_state_idle);
|
||||
}
|
||||
|
|
@ -249,7 +271,7 @@ bool OpenXRExtensionWrapperExtension::on_event_polled(const XrEventDataBuffer &p
|
|||
return false;
|
||||
}
|
||||
|
||||
void *OpenXRExtensionWrapperExtension::set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, Dictionary p_property_values, void *p_next_pointer) {
|
||||
void *OpenXRExtensionWrapperExtension::set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, const Dictionary &p_property_values, void *p_next_pointer) {
|
||||
uint64_t pointer = 0;
|
||||
|
||||
if (GDVIRTUAL_CALL(_set_viewport_composition_layer_and_get_next_pointer, GDExtensionConstPtr<void>(p_layer), p_property_values, GDExtensionPtr<void>(p_next_pointer), pointer)) {
|
||||
|
|
@ -279,6 +301,16 @@ Dictionary OpenXRExtensionWrapperExtension::get_viewport_composition_layer_exten
|
|||
return property_defaults;
|
||||
}
|
||||
|
||||
void *OpenXRExtensionWrapperExtension::set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) {
|
||||
uint64_t pointer = 0;
|
||||
|
||||
if (GDVIRTUAL_CALL(_set_android_surface_swapchain_create_info_and_get_next_pointer, p_property_values, GDExtensionPtr<void>(p_next_pointer), pointer)) {
|
||||
return reinterpret_cast<void *>(pointer);
|
||||
}
|
||||
|
||||
return p_next_pointer;
|
||||
}
|
||||
|
||||
Ref<OpenXRAPIExtension> OpenXRExtensionWrapperExtension::get_openxr_api() {
|
||||
return openxr_api;
|
||||
}
|
||||
|
|
@ -287,8 +319,7 @@ void OpenXRExtensionWrapperExtension::register_extension_wrapper() {
|
|||
OpenXRAPI::register_extension_wrapper(this);
|
||||
}
|
||||
|
||||
OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() :
|
||||
Object(), OpenXRExtensionWrapper() {
|
||||
OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() {
|
||||
openxr_api.instantiate();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "openxr_extension_wrapper.h"
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "core/variant/native_ptr.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
|
@ -60,6 +59,7 @@ public:
|
|||
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
|
||||
virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override;
|
||||
virtual void *set_hand_joint_locations_and_get_next_pointer(int p_hand_index, void *p_next_pointer) override;
|
||||
virtual void *set_projection_views_and_get_next_pointer(int p_view_index, void *p_next_pointer) override;
|
||||
|
||||
virtual int get_composition_layer_count() override;
|
||||
virtual XrCompositionLayerBaseHeader *get_composition_layer(int p_index) override;
|
||||
|
|
@ -71,6 +71,7 @@ public:
|
|||
GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>);
|
||||
GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>);
|
||||
GDVIRTUAL2R(uint64_t, _set_hand_joint_locations_and_get_next_pointer, int, GDExtensionPtr<void>);
|
||||
GDVIRTUAL2R(uint64_t, _set_projection_views_and_get_next_pointer, int, GDExtensionPtr<void>);
|
||||
GDVIRTUAL0R(int, _get_composition_layer_count);
|
||||
GDVIRTUAL1R(uint64_t, _get_composition_layer, int);
|
||||
GDVIRTUAL1R(int, _get_composition_layer_order, int);
|
||||
|
|
@ -88,6 +89,8 @@ public:
|
|||
virtual void on_pre_render() override;
|
||||
virtual void on_main_swapchains_created() override;
|
||||
virtual void on_session_destroyed() override;
|
||||
virtual void on_pre_draw_viewport(RID p_render_target) override;
|
||||
virtual void on_post_draw_viewport(RID p_render_target) override;
|
||||
|
||||
GDVIRTUAL0(_on_register_metadata);
|
||||
GDVIRTUAL0(_on_before_instance_created);
|
||||
|
|
@ -98,6 +101,8 @@ public:
|
|||
GDVIRTUAL0(_on_pre_render);
|
||||
GDVIRTUAL0(_on_main_swapchains_created);
|
||||
GDVIRTUAL0(_on_session_destroyed);
|
||||
GDVIRTUAL1(_on_pre_draw_viewport, RID);
|
||||
GDVIRTUAL1(_on_post_draw_viewport, RID);
|
||||
|
||||
virtual void on_state_idle() override;
|
||||
virtual void on_state_ready() override;
|
||||
|
|
@ -121,15 +126,17 @@ public:
|
|||
|
||||
GDVIRTUAL1R(bool, _on_event_polled, GDExtensionConstPtr<void>);
|
||||
|
||||
virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, Dictionary p_property_values, void *p_next_pointer) override;
|
||||
virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, const Dictionary &p_property_values, void *p_next_pointer) override;
|
||||
virtual void on_viewport_composition_layer_destroyed(const XrCompositionLayerBaseHeader *p_layer) override;
|
||||
virtual void get_viewport_composition_layer_extension_properties(List<PropertyInfo> *p_property_list) override;
|
||||
virtual Dictionary get_viewport_composition_layer_extension_property_defaults() override;
|
||||
virtual void *set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) override;
|
||||
|
||||
GDVIRTUAL3R(uint64_t, _set_viewport_composition_layer_and_get_next_pointer, GDExtensionConstPtr<void>, Dictionary, GDExtensionPtr<void>);
|
||||
GDVIRTUAL1(_on_viewport_composition_layer_destroyed, GDExtensionConstPtr<void>);
|
||||
GDVIRTUAL0R(TypedArray<Dictionary>, _get_viewport_composition_layer_extension_properties);
|
||||
GDVIRTUAL0R(Dictionary, _get_viewport_composition_layer_extension_property_defaults);
|
||||
GDVIRTUAL2R(uint64_t, _set_android_surface_swapchain_create_info_and_get_next_pointer, Dictionary, GDExtensionPtr<void>);
|
||||
|
||||
Ref<OpenXRAPIExtension> get_openxr_api();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,14 @@ OpenXRHandTrackingExtension::~OpenXRHandTrackingExtension() {
|
|||
HashMap<String, bool *> OpenXRHandTrackingExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
unobstructed_data_source = GLOBAL_GET("xr/openxr/extensions/hand_tracking_unobstructed_data_source");
|
||||
controller_data_source = GLOBAL_GET("xr/openxr/extensions/hand_tracking_controller_data_source");
|
||||
|
||||
request_extensions[XR_EXT_HAND_TRACKING_EXTENSION_NAME] = &hand_tracking_ext;
|
||||
request_extensions[XR_EXT_HAND_JOINTS_MOTION_RANGE_EXTENSION_NAME] = &hand_motion_range_ext;
|
||||
request_extensions[XR_EXT_HAND_TRACKING_DATA_SOURCE_EXTENSION_NAME] = &hand_tracking_source_ext;
|
||||
if (unobstructed_data_source || controller_data_source) {
|
||||
request_extensions[XR_EXT_HAND_TRACKING_DATA_SOURCE_EXTENSION_NAME] = &hand_tracking_source_ext;
|
||||
}
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
|
@ -141,10 +146,18 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
void *next_pointer = nullptr;
|
||||
|
||||
// Originally not all XR runtimes supported hand tracking data sourced both from controllers and normal hand tracking.
|
||||
// With this extension we can indicate we accept input from both sources so hand tracking data is consistently provided
|
||||
// on runtimes that support this.
|
||||
XrHandTrackingDataSourceEXT data_sources[2] = { XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT, XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT };
|
||||
XrHandTrackingDataSourceInfoEXT data_source_info = { XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT, next_pointer, 2, data_sources };
|
||||
// With this extension we can indicate we wish to accept input from either or both sources.
|
||||
// This functionality is subject to the abilities of the XR runtime and requires the data source extension.
|
||||
// Note: If the data source extension is not available, no guarantees can be made on what the XR runtime supports.
|
||||
uint32_t data_source_count = 0;
|
||||
XrHandTrackingDataSourceEXT data_sources[2];
|
||||
if (unobstructed_data_source) {
|
||||
data_sources[data_source_count++] = XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT;
|
||||
}
|
||||
if (controller_data_source) {
|
||||
data_sources[data_source_count++] = XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT;
|
||||
}
|
||||
XrHandTrackingDataSourceInfoEXT data_source_info = { XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT, next_pointer, data_source_count, data_sources };
|
||||
if (hand_tracking_source_ext) {
|
||||
// If supported include this info
|
||||
next_pointer = &data_source_info;
|
||||
|
|
@ -224,7 +237,9 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
if (XR_FAILED(result)) {
|
||||
// not successful? then we do nothing.
|
||||
print_line("OpenXR: Failed to get tracking for hand", i, "[", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
||||
godot_tracker->set_hand_tracking_source(XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN);
|
||||
godot_tracker->set_has_tracking_data(false);
|
||||
godot_tracker->invalidate_pose("default");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -235,8 +250,6 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
}
|
||||
|
||||
if (hand_trackers[i].locations.isActive) {
|
||||
godot_tracker->set_has_tracking_data(true);
|
||||
|
||||
// SKELETON_RIG_HUMANOID bone adjustment. This rotation performs:
|
||||
// OpenXR Z+ -> Godot Humanoid Y- (Back along the bone)
|
||||
// OpenXR Y+ -> Godot Humanoid Z- (Out the back of the hand)
|
||||
|
|
@ -245,7 +258,6 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
for (int joint = 0; joint < XR_HAND_JOINT_COUNT_EXT; joint++) {
|
||||
const XrHandJointLocationEXT &location = hand_trackers[i].joint_locations[joint];
|
||||
const XrHandJointVelocityEXT &velocity = hand_trackers[i].joint_velocities[joint];
|
||||
const XrHandTrackingDataSourceStateEXT &data_source = hand_trackers[i].data_source;
|
||||
const XrPosef &pose = location.pose;
|
||||
|
||||
Transform3D transform;
|
||||
|
|
@ -285,23 +297,35 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
godot_tracker->set_hand_joint_radius((XRHandTracker::HandJoint)joint, location.radius);
|
||||
|
||||
if (joint == XR_HAND_JOINT_PALM_EXT) {
|
||||
XRHandTracker::HandTrackingSource source = XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN;
|
||||
if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT) {
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_UNOBSTRUCTED;
|
||||
} else if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT) {
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_CONTROLLER;
|
||||
}
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
|
||||
XrHandTrackingDataSourceStateEXT &data_source = hand_trackers[i].data_source;
|
||||
|
||||
godot_tracker->set_hand_tracking_source(source);
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT) {
|
||||
XRHandTracker::HandTrackingSource source = XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN;
|
||||
if (hand_tracking_source_ext) {
|
||||
if (!data_source.isActive) {
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_NOT_TRACKED;
|
||||
} else if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT) {
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_UNOBSTRUCTED;
|
||||
} else if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT) {
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_CONTROLLER;
|
||||
} else {
|
||||
// Data source shouldn't be active, if new data sources are added to OpenXR we need to enable them.
|
||||
WARN_PRINT_ONCE("Unknown active data source found!");
|
||||
source = XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
godot_tracker->set_hand_tracking_source(source);
|
||||
godot_tracker->set_has_tracking_data(true);
|
||||
godot_tracker->set_pose("default", transform, linear_velocity, angular_velocity);
|
||||
} else {
|
||||
godot_tracker->set_hand_tracking_source(hand_tracking_source_ext ? XRHandTracker::HAND_TRACKING_SOURCE_NOT_TRACKED : XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN);
|
||||
godot_tracker->set_has_tracking_data(false);
|
||||
godot_tracker->invalidate_pose("default");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
godot_tracker->set_hand_tracking_source(hand_tracking_source_ext ? XRHandTracker::HAND_TRACKING_SOURCE_NOT_TRACKED : XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN);
|
||||
godot_tracker->set_has_tracking_data(false);
|
||||
godot_tracker->invalidate_pose("default");
|
||||
}
|
||||
|
|
@ -349,16 +373,17 @@ XrHandJointsMotionRangeEXT OpenXRHandTrackingExtension::get_motion_range(HandTra
|
|||
OpenXRHandTrackingExtension::HandTrackedSource OpenXRHandTrackingExtension::get_hand_tracking_source(HandTrackedHands p_hand) const {
|
||||
ERR_FAIL_UNSIGNED_INDEX_V(p_hand, OPENXR_MAX_TRACKED_HANDS, OPENXR_SOURCE_UNKNOWN);
|
||||
|
||||
if (hand_tracking_source_ext && hand_trackers[p_hand].data_source.isActive) {
|
||||
switch (hand_trackers[p_hand].data_source.dataSource) {
|
||||
case XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT:
|
||||
return OPENXR_SOURCE_UNOBSTRUCTED;
|
||||
|
||||
case XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT:
|
||||
return OPENXR_SOURCE_CONTROLLER;
|
||||
|
||||
default:
|
||||
return OPENXR_SOURCE_UNKNOWN;
|
||||
if (hand_tracking_source_ext) {
|
||||
if (!hand_trackers[p_hand].data_source.isActive) {
|
||||
return OPENXR_SOURCE_NOT_TRACKED;
|
||||
} else if (hand_trackers[p_hand].data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT) {
|
||||
return OPENXR_SOURCE_UNOBSTRUCTED;
|
||||
} else if (hand_trackers[p_hand].data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT) {
|
||||
return OPENXR_SOURCE_CONTROLLER;
|
||||
} else {
|
||||
// Data source shouldn't be active, if new data sources are added to OpenXR we need to enable them.
|
||||
WARN_PRINT_ONCE("Unknown active data source found!");
|
||||
return OPENXR_SOURCE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public:
|
|||
OPENXR_SOURCE_UNKNOWN,
|
||||
OPENXR_SOURCE_UNOBSTRUCTED,
|
||||
OPENXR_SOURCE_CONTROLLER,
|
||||
OPENXR_SOURCE_NOT_TRACKED,
|
||||
OPENXR_SOURCE_MAX
|
||||
};
|
||||
|
||||
|
|
@ -110,6 +111,8 @@ private:
|
|||
bool hand_tracking_ext = false;
|
||||
bool hand_motion_range_ext = false;
|
||||
bool hand_tracking_source_ext = false;
|
||||
bool unobstructed_data_source = false;
|
||||
bool controller_data_source = false;
|
||||
|
||||
// functions
|
||||
void cleanup_hand_tracking();
|
||||
|
|
|
|||
|
|
@ -61,96 +61,88 @@ void OpenXRHTCControllerExtension::on_register_metadata() {
|
|||
metadata->register_top_level_path("HTC left hand tracker", "/user/hand_htc/left", XR_HTC_HAND_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_top_level_path("HTC right hand tracker", "/user/hand_htc/right", XR_HTC_HAND_INTERACTION_EXTENSION_NAME);
|
||||
|
||||
// HTC Vive Cosmos controller
|
||||
metadata->register_interaction_profile("Vive Cosmos controller", "/interaction_profiles/htc/vive_cosmos_controller", XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // HTC Vive Cosmos controller
|
||||
const String profile_path = "/interaction_profiles/htc/vive_cosmos_controller";
|
||||
metadata->register_interaction_profile("Vive Cosmos controller", profile_path, XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Shoulder click", user_path, user_path + "/input/shoulder/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Shoulder click", "/user/hand/left", "/user/hand/left/input/shoulder/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Shoulder click", "/user/hand/right", "/user/hand/right/input/shoulder/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze click", user_path, user_path + "/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Trigger click", "/user/hand/left", "/user/hand/left/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Squeeze click", "/user/hand/left", "/user/hand/left/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Squeeze click", "/user/hand/right", "/user/hand/right/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_cosmos_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
|
||||
// HTC Vive Focus 3 controller
|
||||
metadata->register_interaction_profile("Vive Focus 3 controller", "/interaction_profiles/htc/vive_focus3_controller", XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // HTC Vive Focus 3 controller
|
||||
const String profile_path = "/interaction_profiles/htc/vive_focus3_controller";
|
||||
metadata->register_interaction_profile("Vive Focus 3 controller", profile_path, XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger touch", user_path, user_path + "/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze click", user_path, user_path + "/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze touch", user_path, user_path + "/input/squeeze/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger click", "/user/hand/left", "/user/hand/left/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze click", "/user/hand/left", "/user/hand/left/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze touch", "/user/hand/left", "/user/hand/left/input/squeeze/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze click", "/user/hand/right", "/user/hand/right/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze touch", "/user/hand/right", "/user/hand/right/input/squeeze/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbrest touch", user_path, user_path + "/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbrest touch", "/user/hand/left", "/user/hand/left/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbrest touch", "/user/hand/right", "/user/hand/right/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
|
||||
// HTC Hand interaction profile
|
||||
metadata->register_interaction_profile("HTC Hand interaction", "/interaction_profiles/htc/hand_interaction", XR_HTC_HAND_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Grip pose", "/user/hand_htc/left", "/user/hand_htc/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Grip pose", "/user/hand_htc/right", "/user/hand_htc/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Aim pose", "/user/hand_htc/left", "/user/hand_htc/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Aim pose", "/user/hand_htc/right", "/user/hand_htc/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // HTC Hand interaction profile
|
||||
const String profile_path = "/interaction_profiles/htc/hand_interaction";
|
||||
metadata->register_interaction_profile("HTC Hand interaction", profile_path, XR_HTC_HAND_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand_htc/left", "/user/hand_htc/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Select (pinch)", "/user/hand_htc/left", "/user/hand_htc/left/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Select (pinch)", "/user/hand_htc/right", "/user/hand_htc/right/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Select (pinch)", user_path, user_path + "/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Squeeze (grab)", "/user/hand_htc/left", "/user/hand_htc/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/hand_interaction", "Squeeze (grab)", "/user/hand_htc/right", "/user/hand_htc/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Squeeze (grab)", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,134 +83,45 @@ void OpenXRHTCViveTrackerExtension::on_register_metadata() {
|
|||
metadata->register_top_level_path("Camera tracker", "/user/vive_tracker_htcx/role/camera", XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_top_level_path("Keyboard tracker", "/user/vive_tracker_htcx/role/keyboard", XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME);
|
||||
|
||||
// HTC Vive tracker
|
||||
// Interestingly enough trackers don't have buttons or inputs, yet these are defined in the spec.
|
||||
// I think this can be supported through attachments on the trackers.
|
||||
metadata->register_interaction_profile("HTC Vive tracker", "/interaction_profiles/htc/vive_tracker_htcx", XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Menu click", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
{ // HTC Vive tracker
|
||||
// Interestingly enough trackers don't have buttons or inputs, yet these are defined in the spec.
|
||||
// I think this can be supported through attachments on the trackers.
|
||||
const String profile_path = "/interaction_profiles/htc/vive_tracker_htcx";
|
||||
metadata->register_interaction_profile("HTC Vive tracker", profile_path, XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : {
|
||||
/* "/user/vive_tracker_htcx/role/handheld_object", */
|
||||
"/user/vive_tracker_htcx/role/left_foot",
|
||||
"/user/vive_tracker_htcx/role/right_foot",
|
||||
"/user/vive_tracker_htcx/role/left_shoulder",
|
||||
"/user/vive_tracker_htcx/role/right_shoulder",
|
||||
"/user/vive_tracker_htcx/role/left_elbow",
|
||||
"/user/vive_tracker_htcx/role/right_elbow",
|
||||
"/user/vive_tracker_htcx/role/left_knee",
|
||||
"/user/vive_tracker_htcx/role/right_knee",
|
||||
"/user/vive_tracker_htcx/role/waist",
|
||||
"/user/vive_tracker_htcx/role/chest",
|
||||
"/user/vive_tracker_htcx/role/camera",
|
||||
"/user/vive_tracker_htcx/role/keyboard",
|
||||
}) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Menu click", user_path, user_path + "/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze click", user_path, user_path + "/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trigger click", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad", user_path, user_path + "/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Trackpad click", user_path, user_path + "/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad touch", user_path, user_path + "/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Up", user_path, user_path + "/input/trackpad/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Down", user_path, user_path + "/input/trackpad/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Left", user_path, user_path + "/input/trackpad/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Right", user_path, user_path + "/input/trackpad/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Center", user_path, user_path + "/input/trackpad/dpad_center", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Squeeze click", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad click", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Trackpad touch", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
// register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Grip pose", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
// metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/handheld_object", "/user/vive_tracker_htcx/role/handheld_object/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/left_foot/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/right_foot/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/left_shoulder/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/right_shoulder/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/left_elbow/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/right_elbow/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/left_knee/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/right_knee/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/waist/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/chest/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/camera/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/htc/vive_tracker_htcx", "Haptic output", "/user/vive_tracker_htcx/role/keyboard", "/user/vive_tracker_htcx/role/keyboard/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenXRHTCViveTrackerExtension::on_event_polled(const XrEventDataBuffer &event) {
|
||||
|
|
|
|||
|
|
@ -48,37 +48,33 @@ void OpenXRHuaweiControllerExtension::on_register_metadata() {
|
|||
OpenXRInteractionProfileMetadata *metadata = OpenXRInteractionProfileMetadata::get_singleton();
|
||||
ERR_FAIL_NULL(metadata);
|
||||
|
||||
// Huawei controller
|
||||
metadata->register_interaction_profile("Huawei controller", "/interaction_profiles/huawei/controller", XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // Huawei controller
|
||||
const String profile_path = "/interaction_profiles/huawei/controller";
|
||||
metadata->register_interaction_profile("Huawei controller", profile_path, XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Home click", "/user/hand/left", "/user/hand/left/input/home/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Home click", "/user/hand/right", "/user/hand/right/input/home/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Back click", "/user/hand/left", "/user/hand/left/input/back/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Back click", "/user/hand/right", "/user/hand/right/input/back/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Home click", user_path, user_path + "/input/home/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Back click", user_path, user_path + "/input/back/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Volume up click", "/user/hand/left", "/user/hand/left/input/volume_up/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Volume up click", "/user/hand/right", "/user/hand/right/input/volume_up/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Volume down click", "/user/hand/left", "/user/hand/left/input/volume_down/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Volume down click", "/user/hand/right", "/user/hand/right/input/volume_down/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Volume up click", user_path, user_path + "/input/volume_up/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Volume down click", user_path, user_path + "/input/volume_down/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trigger click", "/user/hand/left", "/user/hand/left/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad", "/user/hand/left", "/user/hand/left/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad click", "/user/hand/left", "/user/hand/left/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad touch", "/user/hand/left", "/user/hand/left/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad", "/user/hand/right", "/user/hand/right/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad click", "/user/hand/right", "/user/hand/right/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Trackpad touch", "/user/hand/right", "/user/hand/right/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad", user_path, user_path + "/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Trackpad click", user_path, user_path + "/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad touch", user_path, user_path + "/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Up", user_path, user_path + "/input/trackpad/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Down", user_path, user_path + "/input/trackpad/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Left", user_path, user_path + "/input/trackpad/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Right", user_path, user_path + "/input/trackpad/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Center", user_path, user_path + "/input/trackpad/dpad_center", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/huawei/controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "openxr_local_floor_extension.h"
|
||||
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
OpenXRLocalFloorExtension *OpenXRLocalFloorExtension::singleton = nullptr;
|
||||
|
||||
OpenXRLocalFloorExtension *OpenXRLocalFloorExtension::get_singleton() {
|
||||
|
|
|
|||
|
|
@ -52,133 +52,110 @@ void OpenXRMetaControllerExtension::on_register_metadata() {
|
|||
|
||||
// Note, we register controllers regardless if they are supported on the current hardware.
|
||||
|
||||
// Normal touch controller is part of the core spec, but we do have some extensions.
|
||||
metadata->register_io_path("/interaction_profiles/oculus/touch_controller", "Trigger proximity", "/user/hand/left", "/user/hand/left/input/trigger/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/oculus/touch_controller", "Trigger proximity", "/user/hand/right", "/user/hand/right/input/trigger/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
{ // Normal touch controller is part of the core spec, but we do have some extensions.
|
||||
const String profile_path = "/interaction_profiles/oculus/touch_controller";
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Trigger proximity", user_path, user_path + "/input/trigger/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumb proximity", user_path, user_path + "/input/thumb_fb/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/oculus/touch_controller", "Thumb proximity", "/user/hand/left", "/user/hand/left/input/thumb_fb/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/oculus/touch_controller", "Thumb proximity", "/user/hand/right", "/user/hand/right/input/thumb_fb/proximity_fb ", "XR_FB_touch_controller_proximity", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
{ // Touch controller pro (Quest Pro)
|
||||
const String profile_path = "/interaction_profiles/facebook/touch_controller_pro";
|
||||
metadata->register_interaction_profile("Touch controller pro", profile_path, "XR_FB_touch_controller_pro");
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
// Touch controller pro (Quest Pro)
|
||||
metadata->register_interaction_profile("Touch controller pro", "/interaction_profiles/facebook/touch_controller_pro", "XR_FB_touch_controller_pro");
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger touch", user_path, user_path + "/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger proximity", user_path, user_path + "/input/trigger/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger curl", user_path, user_path + "/input/trigger/curl_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger slide", user_path, user_path + "/input/trigger/slide_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger force", user_path, user_path + "/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumb proximity", user_path, user_path + "/input/thumb_fb/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger proximity", "/user/hand/left", "/user/hand/left/input/trigger/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger curl", "/user/hand/left", "/user/hand/left/input/trigger/curl_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger slide", "/user/hand/left", "/user/hand/left/input/trigger/slide_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger force", "/user/hand/left", "/user/hand/left/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger proximity", "/user/hand/right", "/user/hand/right/input/trigger/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger curl", "/user/hand/right", "/user/hand/right/input/trigger/curl_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger slide", "/user/hand/right", "/user/hand/right/input/trigger/slide_fb", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Trigger force", "/user/hand/right", "/user/hand/right/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick X", user_path, user_path + "/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Y", user_path, user_path + "/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbrest touch", user_path, user_path + "/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbrest force", user_path, user_path + "/input/thumbrest/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumb proximity", "/user/hand/left", "/user/hand/left/input/thumb_fb/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumb proximity", "/user/hand/right", "/user/hand/right/input/thumb_fb/proximity_fb", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Stylus force", user_path, user_path + "/input/stylus_fb/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick X", "/user/hand/left", "/user/hand/left/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick Y", "/user/hand/left", "/user/hand/left/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick X", "/user/hand/right", "/user/hand/right/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick Y", "/user/hand/right", "/user/hand/right/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Haptic trigger output", user_path, user_path + "/output/haptic_trigger_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Haptic thumb output", user_path, user_path + "/output/haptic_thumb_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbrest touch", "/user/hand/left", "/user/hand/left/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbrest force", "/user/hand/left", "/user/hand/left/input/thumbrest/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbrest touch", "/user/hand/right", "/user/hand/right/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Thumbrest force", "/user/hand/right", "/user/hand/right/input/thumbrest/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Stylus force", "/user/hand/left", "/user/hand/left/input/stylus_fb/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Stylus force", "/user/hand/right", "/user/hand/right/input/stylus_fb/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic trigger output", "/user/hand/left", "/user/hand/left/output/haptic_trigger_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic thumb output", "/user/hand/left", "/user/hand/left/output/haptic_thumb_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic trigger output", "/user/hand/right", "/user/hand/right/output/haptic_trigger_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/facebook/touch_controller_pro", "Haptic thumb output", "/user/hand/right", "/user/hand/right/output/haptic_thumb_fb", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
{ // Touch controller plus (Quest 3)
|
||||
const String profile_path = "/interaction_profiles/meta/touch_controller_plus";
|
||||
metadata->register_interaction_profile("Touch controller plus", profile_path, "XR_META_touch_controller_plus");
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
// Touch controller plus (Quest 3)
|
||||
metadata->register_interaction_profile("Touch controller plus", "/interaction_profiles/meta/touch_controller_plus", "XR_META_touch_controller_plus");
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger touch", user_path, user_path + "/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger proximity", user_path, user_path + "/input/trigger/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger curl", user_path, user_path + "/input/trigger/curl_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger slide", user_path, user_path + "/input/trigger/slide_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger force", user_path, user_path + "/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumb proximity", user_path, user_path + "/input/thumb_meta/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger proximity", "/user/hand/left", "/user/hand/left/input/trigger/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger curl", "/user/hand/left", "/user/hand/left/input/trigger/curl_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger slide", "/user/hand/left", "/user/hand/left/input/trigger/slide_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger force", "/user/hand/left", "/user/hand/left/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger proximity", "/user/hand/right", "/user/hand/right/input/trigger/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger curl", "/user/hand/right", "/user/hand/right/input/trigger/curl_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger slide", "/user/hand/right", "/user/hand/right/input/trigger/slide_meta", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Trigger force", "/user/hand/right", "/user/hand/right/input/trigger/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick X", user_path, user_path + "/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Y", user_path, user_path + "/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbrest touch", user_path, user_path + "/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumb proximity", "/user/hand/left", "/user/hand/left/input/thumb_meta/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumb proximity", "/user/hand/right", "/user/hand/right/input/thumb_meta/proximity_meta", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick X", "/user/hand/left", "/user/hand/left/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick Y", "/user/hand/left", "/user/hand/left/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick X", "/user/hand/right", "/user/hand/right/input/thumbstick/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick Y", "/user/hand/right", "/user/hand/right/input/thumbstick/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbrest touch", "/user/hand/left", "/user/hand/left/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Thumbrest touch", "/user/hand/right", "/user/hand/right/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/meta/touch_controller_plus", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void OpenXRML2ControllerExtension::on_register_metadata() {
|
|||
|
||||
// Magic Leap 2 Controller
|
||||
const String profile_path = "/interaction_profiles/ml/ml2_controller";
|
||||
metadata->register_interaction_profile("Magic Leap 2 controller", "/interaction_profiles/ml/ml2_controller", XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_interaction_profile("Magic Leap 2 controller", profile_path, XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
|
@ -66,6 +66,11 @@ void OpenXRML2ControllerExtension::on_register_metadata() {
|
|||
metadata->register_io_path(profile_path, "Trackpad X", user_path, user_path + "/input/trackpad/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trackpad Y", user_path, user_path + "/input/trackpad/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trackpad touch", user_path, user_path + "/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Up", user_path, user_path + "/input/trackpad/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Down", user_path, user_path + "/input/trackpad/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Left", user_path, user_path + "/input/trackpad/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Right", user_path, user_path + "/input/trackpad/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Center", user_path, user_path + "/input/trackpad/dpad_center", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
|
|
|||
83
engine/modules/openxr/extensions/openxr_mxink_extension.cpp
Normal file
83
engine/modules/openxr/extensions/openxr_mxink_extension.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_mxink_extension.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_mxink_extension.h"
|
||||
|
||||
#include "../action_map/openxr_interaction_profile_metadata.h"
|
||||
|
||||
// Not in base XR libs needs def
|
||||
#define XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME "XR_LOGITECH_mx_ink_stylus_interaction"
|
||||
|
||||
HashMap<String, bool *> OpenXRMxInkExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
request_extensions[XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME] = &available;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
bool OpenXRMxInkExtension::is_available() {
|
||||
return available;
|
||||
}
|
||||
|
||||
void OpenXRMxInkExtension::on_register_metadata() {
|
||||
OpenXRInteractionProfileMetadata *metadata = OpenXRInteractionProfileMetadata::get_singleton();
|
||||
ERR_FAIL_NULL(metadata);
|
||||
|
||||
// Logitech MX Ink Stylus
|
||||
metadata->register_interaction_profile("Logitech MX Ink Stylus", "/interaction_profiles/logitech/mx_ink_stylus_logitech", XR_LOGITECH_MX_INK_STYLUS_INTERACTION_EXTENSION_NAME);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip Force", "/user/hand/left", "/user/hand/left/input/tip_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Middle force", "/user/hand/left", "/user/hand/left/input/cluster_middle_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front click", "/user/hand/left", "/user/hand/left/input/cluster_front_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front double", "/user/hand/left", "/user/hand/left/input/cluster_front_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back click", "/user/hand/left", "/user/hand/left/input/cluster_back_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back double", "/user/hand/left", "/user/hand/left/input/cluster_back_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "System click", "/user/hand/left", "/user/hand/left/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Docked", "/user/hand/left", "/user/hand/left/input/dock_logitech/docked_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip pose", "/user/hand/left", "/user/hand/left/input/tip_logitech/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip Force", "/user/hand/right", "/user/hand/right/input/tip_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Middle force", "/user/hand/right", "/user/hand/right/input/cluster_middle_logitech/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front click", "/user/hand/right", "/user/hand/right/input/cluster_front_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Front double", "/user/hand/right", "/user/hand/right/input/cluster_front_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back click", "/user/hand/right", "/user/hand/right/input/cluster_back_logitech/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Back double", "/user/hand/right", "/user/hand/right/input/cluster_back_logitech/double_tap_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Docked", "/user/hand/right", "/user/hand/right/input/dock_logitech/docked_logitech", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Tip pose", "/user/hand/right", "/user/hand/right/input/tip_logitech/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/logitech/mx_ink_stylus_logitech", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
48
engine/modules/openxr/extensions/openxr_mxink_extension.h
Normal file
48
engine/modules/openxr/extensions/openxr_mxink_extension.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_mxink_extension.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_MXINK_EXTENSION_H
|
||||
#define OPENXR_MXINK_EXTENSION_H
|
||||
|
||||
#include "openxr_extension_wrapper.h"
|
||||
|
||||
class OpenXRMxInkExtension : public OpenXRExtensionWrapper {
|
||||
public:
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
|
||||
bool is_available();
|
||||
|
||||
virtual void on_register_metadata() override;
|
||||
|
||||
private:
|
||||
bool available = false;
|
||||
};
|
||||
|
||||
#endif // OPENXR_MXINK_EXTENSION_H
|
||||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "openxr_palm_pose_extension.h"
|
||||
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
OpenXRPalmPoseExtension *OpenXRPalmPoseExtension::singleton = nullptr;
|
||||
|
||||
OpenXRPalmPoseExtension *OpenXRPalmPoseExtension::get_singleton() {
|
||||
|
|
|
|||
|
|
@ -55,85 +55,79 @@ void OpenXRPicoControllerExtension::on_register_metadata() {
|
|||
// Make sure we switch to our new name.
|
||||
metadata->register_profile_rename("/interaction_profiles/pico/neo3_controller", "/interaction_profiles/bytedance/pico_neo3_controller");
|
||||
|
||||
// Pico neo 3 controller.
|
||||
metadata->register_interaction_profile("Pico Neo3 controller", "/interaction_profiles/bytedance/pico_neo3_controller", XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // Pico neo 3 controller.
|
||||
const String profile_path = "/interaction_profiles/bytedance/pico_neo3_controller";
|
||||
metadata->register_interaction_profile("Pico Neo3 controller", profile_path, XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Menu click", "/user/hand/right", "/user/hand/right/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "System click", "/user/hand/left", "/user/hand/left/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", user_path, user_path + "/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", user_path, user_path + "/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger touch", user_path, user_path + "/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico_neo3_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
|
||||
// Pico 4 controller.
|
||||
metadata->register_interaction_profile("Pico 4 controller", "/interaction_profiles/bytedance/pico4_controller", XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // Pico 4 controller.
|
||||
const String profile_path = "/interaction_profiles/bytedance/pico4_controller";
|
||||
metadata->register_interaction_profile("Pico 4 controller", profile_path, XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
// Note, no menu on right controller!
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "System click", "/user/hand/left", "/user/hand/left/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "System click", user_path, user_path + "/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger touch", user_path, user_path + "/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick touch", user_path, user_path + "/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/bytedance/pico4_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
// Note, no menu on right controller!
|
||||
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,193 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_valve_analog_threshold_extension.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_valve_analog_threshold_extension.h"
|
||||
#include "../action_map/openxr_action_set.h"
|
||||
#include "../action_map/openxr_interaction_profile.h"
|
||||
#include "../openxr_api.h"
|
||||
|
||||
// Implementation for:
|
||||
// https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#XR_VALVE_analog_threshold
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenXRValveAnalogThresholdExtension
|
||||
|
||||
OpenXRValveAnalogThresholdExtension *OpenXRValveAnalogThresholdExtension::singleton = nullptr;
|
||||
|
||||
OpenXRValveAnalogThresholdExtension *OpenXRValveAnalogThresholdExtension::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
OpenXRValveAnalogThresholdExtension::OpenXRValveAnalogThresholdExtension() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
OpenXRValveAnalogThresholdExtension::~OpenXRValveAnalogThresholdExtension() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
HashMap<String, bool *> OpenXRValveAnalogThresholdExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
// Note, we're dependent on the binding modifier extension, this may be requested by multiple extension wrappers.
|
||||
request_extensions[XR_KHR_BINDING_MODIFICATION_EXTENSION_NAME] = &binding_modifier_ext;
|
||||
request_extensions[XR_VALVE_ANALOG_THRESHOLD_EXTENSION_NAME] = &threshold_ext;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
bool OpenXRValveAnalogThresholdExtension::is_available() {
|
||||
return binding_modifier_ext && threshold_ext;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenXRAnalogThresholdModifier
|
||||
|
||||
void OpenXRAnalogThresholdModifier::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_on_threshold", "on_threshold"), &OpenXRAnalogThresholdModifier::set_on_threshold);
|
||||
ClassDB::bind_method(D_METHOD("get_on_threshold"), &OpenXRAnalogThresholdModifier::get_on_threshold);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "on_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_on_threshold", "get_on_threshold");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_off_threshold", "off_threshold"), &OpenXRAnalogThresholdModifier::set_off_threshold);
|
||||
ClassDB::bind_method(D_METHOD("get_off_threshold"), &OpenXRAnalogThresholdModifier::get_off_threshold);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "off_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_off_threshold", "get_off_threshold");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_on_haptic", "haptic"), &OpenXRAnalogThresholdModifier::set_on_haptic);
|
||||
ClassDB::bind_method(D_METHOD("get_on_haptic"), &OpenXRAnalogThresholdModifier::get_on_haptic);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "on_haptic", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRHapticBase"), "set_on_haptic", "get_on_haptic");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_off_haptic", "haptic"), &OpenXRAnalogThresholdModifier::set_off_haptic);
|
||||
ClassDB::bind_method(D_METHOD("get_off_haptic"), &OpenXRAnalogThresholdModifier::get_off_haptic);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "off_haptic", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRHapticBase"), "set_off_haptic", "get_off_haptic");
|
||||
}
|
||||
|
||||
OpenXRAnalogThresholdModifier::OpenXRAnalogThresholdModifier() {
|
||||
analog_threshold.type = XR_TYPE_INTERACTION_PROFILE_ANALOG_THRESHOLD_VALVE;
|
||||
analog_threshold.next = nullptr;
|
||||
|
||||
analog_threshold.onThreshold = 0.6;
|
||||
analog_threshold.offThreshold = 0.4;
|
||||
}
|
||||
|
||||
void OpenXRAnalogThresholdModifier::set_on_threshold(float p_threshold) {
|
||||
ERR_FAIL_COND(p_threshold < 0.0 || p_threshold > 1.0);
|
||||
|
||||
analog_threshold.onThreshold = p_threshold;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRAnalogThresholdModifier::get_on_threshold() const {
|
||||
return analog_threshold.onThreshold;
|
||||
}
|
||||
|
||||
void OpenXRAnalogThresholdModifier::set_off_threshold(float p_threshold) {
|
||||
ERR_FAIL_COND(p_threshold < 0.0 || p_threshold > 1.0);
|
||||
|
||||
analog_threshold.offThreshold = p_threshold;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
float OpenXRAnalogThresholdModifier::get_off_threshold() const {
|
||||
return analog_threshold.offThreshold;
|
||||
}
|
||||
|
||||
void OpenXRAnalogThresholdModifier::set_on_haptic(const Ref<OpenXRHapticBase> &p_haptic) {
|
||||
on_haptic = p_haptic;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<OpenXRHapticBase> OpenXRAnalogThresholdModifier::get_on_haptic() const {
|
||||
return on_haptic;
|
||||
}
|
||||
|
||||
void OpenXRAnalogThresholdModifier::set_off_haptic(const Ref<OpenXRHapticBase> &p_haptic) {
|
||||
off_haptic = p_haptic;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<OpenXRHapticBase> OpenXRAnalogThresholdModifier::get_off_haptic() const {
|
||||
return off_haptic;
|
||||
}
|
||||
|
||||
PackedByteArray OpenXRAnalogThresholdModifier::get_ip_modification() {
|
||||
PackedByteArray ret;
|
||||
|
||||
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL_V(openxr_api, ret);
|
||||
|
||||
OpenXRValveAnalogThresholdExtension *analog_threshold_ext = OpenXRValveAnalogThresholdExtension::get_singleton();
|
||||
if (!analog_threshold_ext || !analog_threshold_ext->is_available()) {
|
||||
// Extension not enabled!
|
||||
WARN_PRINT("Analog threshold extension is not enabled or available.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ERR_FAIL_NULL_V(ip_binding, ret);
|
||||
|
||||
Ref<OpenXRAction> action = ip_binding->get_action();
|
||||
ERR_FAIL_COND_V(action.is_null(), ret);
|
||||
|
||||
// Get our action set
|
||||
Ref<OpenXRActionSet> action_set = action->get_action_set();
|
||||
ERR_FAIL_COND_V(action_set.is_null(), ret);
|
||||
RID action_set_rid = openxr_api->find_action_set(action_set->get_name());
|
||||
ERR_FAIL_COND_V(!action_set_rid.is_valid(), ret);
|
||||
|
||||
// Get our action
|
||||
RID action_rid = openxr_api->find_action(action->get_name(), action_set_rid);
|
||||
ERR_FAIL_COND_V(!action_rid.is_valid(), ret);
|
||||
|
||||
analog_threshold.action = openxr_api->action_get_handle(action_rid);
|
||||
|
||||
analog_threshold.binding = openxr_api->get_xr_path(ip_binding->get_binding_path());
|
||||
ERR_FAIL_COND_V(analog_threshold.binding == XR_NULL_PATH, ret);
|
||||
|
||||
// These are set already:
|
||||
// - analog_threshold.onThreshold
|
||||
// - analog_threshold.offThreshold
|
||||
|
||||
if (on_haptic.is_valid()) {
|
||||
analog_threshold.onHaptic = on_haptic->get_xr_structure();
|
||||
} else {
|
||||
analog_threshold.onHaptic = nullptr;
|
||||
}
|
||||
|
||||
if (off_haptic.is_valid()) {
|
||||
analog_threshold.offHaptic = off_haptic->get_xr_structure();
|
||||
} else {
|
||||
analog_threshold.offHaptic = nullptr;
|
||||
}
|
||||
|
||||
// Copy into byte array so we can return it.
|
||||
ERR_FAIL_COND_V(ret.resize(sizeof(XrInteractionProfileAnalogThresholdVALVE)) != OK, ret);
|
||||
memcpy(ret.ptrw(), &analog_threshold, sizeof(XrInteractionProfileAnalogThresholdVALVE));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_valve_analog_threshold_extension.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_VALVE_ANALOG_THRESHOLD_EXTENSION_H
|
||||
#define OPENXR_VALVE_ANALOG_THRESHOLD_EXTENSION_H
|
||||
|
||||
#include "../action_map/openxr_binding_modifier.h"
|
||||
#include "../action_map/openxr_haptic_feedback.h"
|
||||
#include "../util.h"
|
||||
#include "core/io/resource.h"
|
||||
#include "openxr_extension_wrapper.h"
|
||||
|
||||
class OpenXRValveAnalogThresholdExtension : public OpenXRExtensionWrapper {
|
||||
public:
|
||||
static OpenXRValveAnalogThresholdExtension *get_singleton();
|
||||
|
||||
OpenXRValveAnalogThresholdExtension();
|
||||
virtual ~OpenXRValveAnalogThresholdExtension() override;
|
||||
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
|
||||
bool is_available();
|
||||
|
||||
private:
|
||||
static OpenXRValveAnalogThresholdExtension *singleton;
|
||||
|
||||
bool binding_modifier_ext = false;
|
||||
bool threshold_ext = false;
|
||||
};
|
||||
|
||||
class OpenXRAnalogThresholdModifier : public OpenXRActionBindingModifier {
|
||||
GDCLASS(OpenXRAnalogThresholdModifier, OpenXRActionBindingModifier);
|
||||
|
||||
private:
|
||||
XrInteractionProfileAnalogThresholdVALVE analog_threshold;
|
||||
Ref<OpenXRHapticBase> on_haptic;
|
||||
Ref<OpenXRHapticBase> off_haptic;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
OpenXRAnalogThresholdModifier();
|
||||
|
||||
void set_on_threshold(float p_threshold);
|
||||
float get_on_threshold() const;
|
||||
|
||||
void set_off_threshold(float p_threshold);
|
||||
float get_off_threshold() const;
|
||||
|
||||
void set_on_haptic(const Ref<OpenXRHapticBase> &p_haptic);
|
||||
Ref<OpenXRHapticBase> get_on_haptic() const;
|
||||
|
||||
void set_off_haptic(const Ref<OpenXRHapticBase> &p_haptic);
|
||||
Ref<OpenXRHapticBase> get_off_haptic() const;
|
||||
|
||||
virtual String get_description() const override { return "Analog threshold modifier"; }
|
||||
virtual PackedByteArray get_ip_modification() override;
|
||||
};
|
||||
|
||||
#endif // OPENXR_VALVE_ANALOG_THRESHOLD_EXTENSION_H
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_visibility_mask_extension.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_visibility_mask_extension.h"
|
||||
|
||||
#include "../openxr_api.h"
|
||||
#include "core/string/print_string.h"
|
||||
#include "core/variant/array.h"
|
||||
#include "core/variant/variant.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
static const char *VISIBILITY_MASK_SHADER_CODE =
|
||||
"shader_type spatial;\n"
|
||||
"render_mode unshaded, shadows_disabled, cull_disabled;\n"
|
||||
"void vertex() {\n"
|
||||
"\tif (int(VERTEX.z) == VIEW_INDEX) {\n"
|
||||
"\t\tVERTEX.z = -1.0;\n"
|
||||
"\t\tVERTEX += EYE_OFFSET;\n"
|
||||
"\t\tPOSITION = PROJECTION_MATRIX * vec4(VERTEX, 1.0);\n"
|
||||
"\t\tPOSITION.xy /= POSITION.w;\n"
|
||||
"\t\tPOSITION.z = 1.0;\n"
|
||||
"\t\tPOSITION.w = 1.0;\n"
|
||||
"\t} else {\n"
|
||||
"\t\tPOSITION = vec4(2.0, 2.0, 2.0, 1.0);\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void fragment() {\n"
|
||||
"\tALBEDO = vec3(0.0, 0.0, 0.0);\n"
|
||||
"}\n";
|
||||
|
||||
OpenXRVisibilityMaskExtension *OpenXRVisibilityMaskExtension::singleton = nullptr;
|
||||
|
||||
OpenXRVisibilityMaskExtension *OpenXRVisibilityMaskExtension::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
OpenXRVisibilityMaskExtension::OpenXRVisibilityMaskExtension() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
OpenXRVisibilityMaskExtension::~OpenXRVisibilityMaskExtension() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
HashMap<String, bool *> OpenXRVisibilityMaskExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
request_extensions[XR_KHR_VISIBILITY_MASK_EXTENSION_NAME] = &available;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::on_instance_created(const XrInstance p_instance) {
|
||||
if (available) {
|
||||
EXT_INIT_XR_FUNC(xrGetVisibilityMaskKHR);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::on_session_created(const XrSession p_instance) {
|
||||
if (available) {
|
||||
RS *rendering_server = RS::get_singleton();
|
||||
ERR_FAIL_NULL(rendering_server);
|
||||
|
||||
OpenXRAPI *openxr_api = (OpenXRAPI *)OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL(openxr_api);
|
||||
|
||||
// Create our shader.
|
||||
shader = rendering_server->shader_create();
|
||||
rendering_server->shader_set_code(shader, VISIBILITY_MASK_SHADER_CODE);
|
||||
|
||||
// Create our material.
|
||||
material = rendering_server->material_create();
|
||||
rendering_server->material_set_shader(material, shader);
|
||||
rendering_server->material_set_render_priority(material, 99);
|
||||
|
||||
// Create our mesh.
|
||||
mesh = rendering_server->mesh_create();
|
||||
|
||||
// Get our initial mesh data.
|
||||
mesh_count = openxr_api->get_view_count(); // We need a mesh for each view.
|
||||
for (uint32_t i = 0; i < mesh_count; i++) {
|
||||
_update_mesh_data(i);
|
||||
}
|
||||
|
||||
// And update our mesh
|
||||
_update_mesh();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::on_session_destroyed() {
|
||||
RS *rendering_server = RS::get_singleton();
|
||||
ERR_FAIL_NULL(rendering_server);
|
||||
|
||||
// Free our mesh.
|
||||
if (mesh.is_valid()) {
|
||||
rendering_server->free(mesh);
|
||||
mesh = RID();
|
||||
}
|
||||
|
||||
// Free our material.
|
||||
if (material.is_valid()) {
|
||||
rendering_server->free(material);
|
||||
material = RID();
|
||||
}
|
||||
|
||||
// Free our shader.
|
||||
if (shader.is_valid()) {
|
||||
rendering_server->free(shader);
|
||||
shader = RID();
|
||||
}
|
||||
|
||||
mesh_count = 0;
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::on_pre_render() {
|
||||
// Update mesh data if its dirty.
|
||||
// Here we call this from the rendering thread however as we're going through the rendering server this is safe.
|
||||
_update_mesh();
|
||||
}
|
||||
|
||||
bool OpenXRVisibilityMaskExtension::on_event_polled(const XrEventDataBuffer &event) {
|
||||
if (event.type == XR_TYPE_EVENT_DATA_VISIBILITY_MASK_CHANGED_KHR) {
|
||||
XrEventDataVisibilityMaskChangedKHR *vismask_event = (XrEventDataVisibilityMaskChangedKHR *)&event;
|
||||
|
||||
print_verbose("OpenXR EVENT: Visibility mask changed for view " + String::num_uint64(vismask_event->viewIndex));
|
||||
|
||||
if (available) { // This event won't be called if this extension is not available but better safe than sorry.
|
||||
_update_mesh_data(vismask_event->viewIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OpenXRVisibilityMaskExtension::is_available() {
|
||||
return available;
|
||||
}
|
||||
|
||||
RID OpenXRVisibilityMaskExtension::get_mesh() {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::_update_mesh_data(uint32_t p_view) {
|
||||
if (available) {
|
||||
ERR_FAIL_UNSIGNED_INDEX(p_view, 4);
|
||||
|
||||
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL(openxr_api);
|
||||
|
||||
XrSession session = openxr_api->get_session();
|
||||
XrViewConfigurationType view_configuration_type = openxr_api->get_view_configuration();
|
||||
|
||||
// Figure out how much data we're getting.
|
||||
XrVisibilityMaskKHR visibility_mask_data = {
|
||||
XR_TYPE_VISIBILITY_MASK_KHR,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
XrResult result = xrGetVisibilityMaskKHR(session, view_configuration_type, p_view, XR_VISIBILITY_MASK_TYPE_HIDDEN_TRIANGLE_MESH_KHR, &visibility_mask_data);
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Unable to obtain visibility mask metrics [", openxr_api->get_error_string(result), "]");
|
||||
return;
|
||||
}
|
||||
|
||||
// Resize buffers
|
||||
mesh_data[p_view].vertices.resize(visibility_mask_data.vertexCountOutput);
|
||||
mesh_data[p_view].indices.resize(visibility_mask_data.indexCountOutput);
|
||||
|
||||
visibility_mask_data.vertexCapacityInput = visibility_mask_data.vertexCountOutput;
|
||||
visibility_mask_data.vertices = mesh_data[p_view].vertices.ptrw();
|
||||
visibility_mask_data.indexCapacityInput = visibility_mask_data.indexCountOutput;
|
||||
visibility_mask_data.indices = mesh_data[p_view].indices.ptrw();
|
||||
|
||||
result = xrGetVisibilityMaskKHR(session, view_configuration_type, p_view, XR_VISIBILITY_MASK_TYPE_HIDDEN_TRIANGLE_MESH_KHR, &visibility_mask_data);
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Unable to obtain visibility mask data [", openxr_api->get_error_string(result), "]");
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark as dirty, we have updated mesh data.
|
||||
is_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXRVisibilityMaskExtension::_update_mesh() {
|
||||
if (available && is_dirty && mesh_count > 0) {
|
||||
RS *rendering_server = RS::get_singleton();
|
||||
ERR_FAIL_NULL(rendering_server);
|
||||
|
||||
OpenXRAPI *openxr_api = (OpenXRAPI *)OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL(openxr_api);
|
||||
|
||||
// Combine all vertex and index buffers into one.
|
||||
PackedVector3Array vertices;
|
||||
PackedInt32Array indices;
|
||||
|
||||
uint64_t vertice_count = 0;
|
||||
uint64_t index_count = 0;
|
||||
|
||||
for (uint32_t i = 0; i < mesh_count; i++) {
|
||||
vertice_count += mesh_data[i].vertices.size();
|
||||
index_count += mesh_data[i].indices.size();
|
||||
}
|
||||
|
||||
vertices.resize(vertice_count);
|
||||
indices.resize(index_count);
|
||||
uint64_t offset = 0;
|
||||
|
||||
Vector3 *v_out = vertices.ptrw();
|
||||
int32_t *i_out = indices.ptrw();
|
||||
|
||||
for (uint32_t i = 0; i < mesh_count; i++) {
|
||||
const XrVector2f *v_in = mesh_data[i].vertices.ptr();
|
||||
for (uint32_t j = 0; j < mesh_data[i].vertices.size(); j++) {
|
||||
v_out->x = v_in->x;
|
||||
v_out->y = v_in->y;
|
||||
v_out->z = float(i); // We store our view in our Z component, our shader will filter the right faces out.
|
||||
v_out++;
|
||||
v_in++;
|
||||
}
|
||||
const uint32_t *i_in = mesh_data[i].indices.ptr();
|
||||
for (uint32_t j = 0; j < mesh_data[i].indices.size(); j++) {
|
||||
*i_out = offset + *i_in;
|
||||
i_out++;
|
||||
i_in++;
|
||||
}
|
||||
|
||||
offset += mesh_data[i].vertices.size();
|
||||
}
|
||||
|
||||
// Update our mesh.
|
||||
Array arr;
|
||||
arr.resize(RS::ARRAY_MAX);
|
||||
arr[RS::ARRAY_VERTEX] = vertices;
|
||||
arr[RS::ARRAY_INDEX] = indices;
|
||||
|
||||
rendering_server->mesh_clear(mesh);
|
||||
rendering_server->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr);
|
||||
rendering_server->mesh_surface_set_material(mesh, 0, material);
|
||||
|
||||
// Set no longer dirty.
|
||||
is_dirty = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_visibility_mask_extension.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_VISIBILITY_MASK_EXTENSION_H
|
||||
#define OPENXR_VISIBILITY_MASK_EXTENSION_H
|
||||
|
||||
#include "../util.h"
|
||||
|
||||
#include "core/templates/vector.h"
|
||||
#include "openxr_extension_wrapper.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
|
||||
// The OpenXR visibility mask extension provides a mesh for each eye that
|
||||
// can be used as a mask to determine which part of our rendered result
|
||||
// is actually visible to the user. Due to lens distortion the edges of
|
||||
// the rendered image are never used in the final result output on the HMD.
|
||||
//
|
||||
// Blacking out this are of the render result can remove a fair amount of
|
||||
// overhead in rendering part of the screen that is unused.
|
||||
//
|
||||
// https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_visibility_mask
|
||||
|
||||
class OpenXRVisibilityMaskExtension : public OpenXRExtensionWrapper {
|
||||
public:
|
||||
static OpenXRVisibilityMaskExtension *get_singleton();
|
||||
|
||||
OpenXRVisibilityMaskExtension();
|
||||
virtual ~OpenXRVisibilityMaskExtension() override;
|
||||
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
|
||||
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||
|
||||
virtual void on_session_created(const XrSession p_instance) override;
|
||||
virtual void on_session_destroyed() override;
|
||||
|
||||
virtual void on_pre_render() override;
|
||||
virtual bool on_event_polled(const XrEventDataBuffer &event) override;
|
||||
|
||||
bool is_available();
|
||||
RID get_mesh();
|
||||
|
||||
private:
|
||||
static OpenXRVisibilityMaskExtension *singleton;
|
||||
|
||||
bool available = false;
|
||||
bool is_dirty = false;
|
||||
|
||||
RID shader;
|
||||
RID material;
|
||||
RID mesh;
|
||||
|
||||
struct MeshData {
|
||||
Vector<XrVector2f> vertices;
|
||||
Vector<uint32_t> indices;
|
||||
};
|
||||
|
||||
uint32_t mesh_count = 0;
|
||||
MeshData mesh_data[4];
|
||||
|
||||
void _update_mesh_data(uint32_t p_view);
|
||||
void _update_mesh();
|
||||
|
||||
// OpenXR API call wrappers
|
||||
EXT_PROTO_XRRESULT_FUNC5(xrGetVisibilityMaskKHR, (XrSession), session, (XrViewConfigurationType), viewConfigurationType, (uint32_t), viewIndex, (XrVisibilityMaskTypeKHR), visibilityMaskType, (XrVisibilityMaskKHR *), visibilityMask);
|
||||
};
|
||||
|
||||
#endif // OPENXR_VISIBILITY_MASK_EXTENSION_H
|
||||
|
|
@ -51,90 +51,85 @@ void OpenXRWMRControllerExtension::on_register_metadata() {
|
|||
OpenXRInteractionProfileMetadata *metadata = OpenXRInteractionProfileMetadata::get_singleton();
|
||||
ERR_FAIL_NULL(metadata);
|
||||
|
||||
// HP MR controller (newer G2 controllers)
|
||||
metadata->register_interaction_profile("HPMR controller", "/interaction_profiles/hp/mixed_reality_controller", XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // HP MR controller (newer G2 controllers)
|
||||
const String profile_path = "/interaction_profiles/hp/mixed_reality_controller";
|
||||
metadata->register_interaction_profile("HPMR controller", profile_path, XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Menu click", "/user/hand/right", "/user/hand/right/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", user_path, user_path + "/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Trigger click", "/user/hand/left", "/user/hand/left/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/hp/mixed_reality_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
}
|
||||
|
||||
// Samsung Odyssey controller
|
||||
metadata->register_interaction_profile("Samsung Odyssey controller", "/interaction_profiles/samsung/odyssey_controller", XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // Samsung Odyssey controller
|
||||
const String profile_path = "/interaction_profiles/samsung/odyssey_controller";
|
||||
metadata->register_interaction_profile("Samsung Odyssey controller", profile_path, XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Menu click", "/user/hand/right", "/user/hand/right/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Menu click", user_path, user_path + "/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trigger click", "/user/hand/left", "/user/hand/left/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Squeeze click", "/user/hand/left", "/user/hand/left/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Squeeze click", "/user/hand/right", "/user/hand/right/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Squeeze click", user_path, user_path + "/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick", user_path, user_path + "/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Thumbstick click", user_path, user_path + "/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Up", user_path, user_path + "/input/thumbstick/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Down", user_path, user_path + "/input/thumbstick/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Left", user_path, user_path + "/input/thumbstick/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Thumbstick Dpad Right", user_path, user_path + "/input/thumbstick/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad", "/user/hand/left", "/user/hand/left/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad click", "/user/hand/left", "/user/hand/left/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad touch", "/user/hand/left", "/user/hand/left/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad", "/user/hand/right", "/user/hand/right/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad click", "/user/hand/right", "/user/hand/right/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Trackpad touch", "/user/hand/right", "/user/hand/right/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad", user_path, user_path + "/input/trackpad", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
|
||||
metadata->register_io_path(profile_path, "Trackpad click", user_path, user_path + "/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad touch", user_path, user_path + "/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Up", user_path, user_path + "/input/trackpad/dpad_up", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Down", user_path, user_path + "/input/trackpad/dpad_down", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Left", user_path, user_path + "/input/trackpad/dpad_left", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Right", user_path, user_path + "/input/trackpad/dpad_right", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
metadata->register_io_path(profile_path, "Trackpad Dpad Center", user_path, user_path + "/input/trackpad/dpad_center", "XR_EXT_dpad_binding", OpenXRAction::OPENXR_ACTION_BOOL);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path("/interaction_profiles/samsung/odyssey_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
|
||||
}
|
||||
}
|
||||
|
||||
// MSFT Hand interaction profile, also supported by other headsets
|
||||
metadata->register_interaction_profile("MSFT Hand interaction", "/interaction_profiles/microsoft/hand_interaction", XR_MSFT_HAND_INTERACTION_EXTENSION_NAME);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Pinch pose", "/user/hand/left", "/user/hand/left/input/pinch_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Pinch pose", "/user/hand/right", "/user/hand/right/input/pinch_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Poke pose", "/user/hand/left", "/user/hand/left/input/poke_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Poke pose", "/user/hand/right", "/user/hand/right/input/poke_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
{ // MSFT Hand interaction profile, also supported by other headsets
|
||||
const String profile_path = "/interaction_profiles/microsoft/hand_interaction";
|
||||
metadata->register_interaction_profile("MSFT Hand interaction", profile_path, XR_MSFT_HAND_INTERACTION_EXTENSION_NAME);
|
||||
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
|
||||
metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Pinch pose", user_path, user_path + "/input/pinch_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Poke pose", user_path, user_path + "/input/poke_ext/pose", XR_EXT_HAND_INTERACTION_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
metadata->register_io_path(profile_path, "Palm pose", user_path, user_path + "/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Select (pinch)", "/user/hand/left", "/user/hand/left/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Select (pinch)", "/user/hand/right", "/user/hand/right/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Select (pinch)", user_path, user_path + "/input/select/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Squeeze (grab)", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path("/interaction_profiles/microsoft/hand_interaction", "Squeeze (grab)", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
metadata->register_io_path(profile_path, "Squeeze (grab)", user_path, user_path + "/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_metal_extension.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_METAL_EXTENSION_H
|
||||
#define OPENXR_METAL_EXTENSION_H
|
||||
|
||||
#include "../../openxr_api.h"
|
||||
#include "../../util.h"
|
||||
#include "../openxr_extension_wrapper.h"
|
||||
|
||||
#include "core/templates/vector.h"
|
||||
|
||||
// Always include this as late as possible.
|
||||
#include "../../openxr_platform_inc.h"
|
||||
|
||||
class OpenXRMetalExtension : public OpenXRGraphicsExtensionWrapper {
|
||||
public:
|
||||
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||
|
||||
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
|
||||
|
||||
virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override;
|
||||
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override;
|
||||
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override;
|
||||
virtual bool get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) override;
|
||||
virtual void cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) override;
|
||||
virtual bool create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) override;
|
||||
virtual RID get_texture(void *p_swapchain_graphics_data, int p_image_index) override;
|
||||
|
||||
private:
|
||||
static XrGraphicsBindingMetalKHR graphics_binding_metal;
|
||||
|
||||
struct SwapchainGraphicsData {
|
||||
bool is_multiview;
|
||||
Vector<RID> texture_rids;
|
||||
};
|
||||
|
||||
bool check_graphics_api_support();
|
||||
|
||||
EXT_PROTO_XRRESULT_FUNC3(xrGetMetalGraphicsRequirementsKHR, (XrInstance), p_instance, (XrSystemId), p_system_id, (XrGraphicsRequirementsMetalKHR *), p_graphics_requirements)
|
||||
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateSwapchainImages, (XrSwapchain), p_swapchain, (uint32_t), p_image_capacity_input, (uint32_t *), p_image_count_output, (XrSwapchainImageBaseHeader *), p_images)
|
||||
};
|
||||
|
||||
#endif // OPENXR_METAL_EXTENSION_H
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
/**************************************************************************/
|
||||
/* openxr_metal_extension.mm */
|
||||
/**************************************************************************/
|
||||
/* 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_metal_extension.h"
|
||||
|
||||
#include "../../openxr_util.h"
|
||||
#include "drivers/metal/rendering_device_driver_metal.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
|
||||
HashMap<String, bool *> OpenXRMetalExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
request_extensions[XR_KHR_METAL_ENABLE_EXTENSION_NAME] = nullptr;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
void OpenXRMetalExtension::on_instance_created(const XrInstance p_instance) {
|
||||
// Obtain pointers to functions we're accessing here.
|
||||
ERR_FAIL_NULL(OpenXRAPI::get_singleton());
|
||||
|
||||
EXT_INIT_XR_FUNC(xrGetMetalGraphicsRequirementsKHR);
|
||||
EXT_INIT_XR_FUNC(xrEnumerateSwapchainImages);
|
||||
}
|
||||
|
||||
bool OpenXRMetalExtension::check_graphics_api_support() {
|
||||
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false);
|
||||
|
||||
// TODO We may need to do a callback like we do in Vulkan where we run this first
|
||||
// and provide the obtained metalDevice to our Metal driver to use.
|
||||
// But according to Stuart Macs only have 1 device so it should always be the
|
||||
// same one and we should be able to get away with not doing this just yet.
|
||||
// If we do go forward with this, this means that just like with Vulkan,
|
||||
// we have to start with OpenXR before Metal can be setup, and we thus
|
||||
// can't support applications that want to add XR as an optional/temporary
|
||||
// feature that users enable when needed.
|
||||
|
||||
XrSystemId system_id = OpenXRAPI::get_singleton()->get_system_id();
|
||||
XrInstance instance = OpenXRAPI::get_singleton()->get_instance();
|
||||
|
||||
XrGraphicsRequirementsMetalKHR metal_requirements;
|
||||
metal_requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_METAL_KHR;
|
||||
metal_requirements.next = nullptr;
|
||||
metal_requirements.metalDevice = nullptr;
|
||||
|
||||
XrResult result = xrGetMetalGraphicsRequirementsKHR(instance, system_id, &metal_requirements);
|
||||
if (!OpenXRAPI::get_singleton()->xr_result(result, "Failed to get Metal graphics requirements!")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// See what metal device we are using...
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(rendering_server, false);
|
||||
RenderingDevice *rendering_device = rendering_server->get_rendering_device();
|
||||
ERR_FAIL_NULL_V(rendering_device, false);
|
||||
|
||||
void *our_metal_device = (void *)rendering_device->get_driver_resource(RD::DRIVER_RESOURCE_LOGICAL_DEVICE);
|
||||
|
||||
// Make sure we're using the same one.
|
||||
ERR_FAIL_COND_V(metal_requirements.metalDevice != our_metal_device, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
XrGraphicsBindingMetalKHR OpenXRMetalExtension::graphics_binding_metal;
|
||||
|
||||
void *OpenXRMetalExtension::set_session_create_and_get_next_pointer(void *p_next_pointer) {
|
||||
if (!check_graphics_api_support()) {
|
||||
return p_next_pointer;
|
||||
}
|
||||
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(rendering_server, p_next_pointer);
|
||||
RenderingDevice *rendering_device = rendering_server->get_rendering_device();
|
||||
ERR_FAIL_NULL_V(rendering_device, p_next_pointer);
|
||||
|
||||
graphics_binding_metal.type = XR_TYPE_GRAPHICS_BINDING_METAL_KHR;
|
||||
graphics_binding_metal.next = p_next_pointer;
|
||||
graphics_binding_metal.commandQueue = (void *)rendering_device->get_driver_resource(RD::DRIVER_RESOURCE_COMMAND_QUEUE);
|
||||
|
||||
return &graphics_binding_metal;
|
||||
}
|
||||
|
||||
void OpenXRMetalExtension::get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) {
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatRGBA8Unorm_sRGB);
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatBGRA8Unorm_sRGB);
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatRGBA8Uint);
|
||||
}
|
||||
|
||||
void OpenXRMetalExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) {
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatDepth24Unorm_Stencil8);
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatDepth32Float_Stencil8);
|
||||
p_usable_swap_chains.push_back(MTLPixelFormatDepth32Float);
|
||||
}
|
||||
|
||||
#define ENUM_TO_STRING_CASE(m_e) \
|
||||
case m_e: { \
|
||||
return String(#m_e); \
|
||||
} break;
|
||||
|
||||
String OpenXRMetalExtension::get_swapchain_format_name(int64_t p_swapchain_format) const {
|
||||
// This really should be in vulkan_context...
|
||||
MTLPixelFormat format = MTLPixelFormat(p_swapchain_format);
|
||||
switch (format) {
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatRGBA8Unorm)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatRGBA8Unorm_sRGB)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatBGRA8Unorm)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatBGRA8Unorm_sRGB)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatRGBA8Uint)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatDepth24Unorm_Stencil8)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatDepth32Float_Stencil8)
|
||||
ENUM_TO_STRING_CASE(MTLPixelFormatDepth32Float)
|
||||
default: {
|
||||
return String("Swapchain format ") + String::num_int64(int64_t(p_swapchain_format));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenXRMetalExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
|
||||
LocalVector<XrSwapchainImageMetalKHR, uint32_t, false, true> images;
|
||||
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(rendering_server, false);
|
||||
RenderingDevice *rendering_device = rendering_server->get_rendering_device();
|
||||
ERR_FAIL_NULL_V(rendering_device, false);
|
||||
|
||||
uint32_t swapchain_length;
|
||||
XrResult result = xrEnumerateSwapchainImages(p_swapchain, 0, &swapchain_length, nullptr);
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Failed to get swapchaim image count [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
images.resize(swapchain_length);
|
||||
|
||||
for (XrSwapchainImageMetalKHR &image : images) {
|
||||
image.type = XR_TYPE_SWAPCHAIN_IMAGE_METAL_KHR;
|
||||
image.next = nullptr;
|
||||
image.texture = nullptr;
|
||||
}
|
||||
|
||||
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images.ptr());
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Failed to get swapchaim images [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapchainGraphicsData *data = memnew(SwapchainGraphicsData);
|
||||
if (data == nullptr) {
|
||||
print_line("OpenXR: Failed to allocate memory for swapchain data");
|
||||
return false;
|
||||
}
|
||||
*r_swapchain_graphics_data = data;
|
||||
data->is_multiview = (p_array_size > 1);
|
||||
|
||||
RenderingDevice::DataFormat format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
RenderingDevice::TextureSamples samples = RenderingDevice::TEXTURE_SAMPLES_1;
|
||||
uint64_t usage_flags = RenderingDevice::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
|
||||
switch (p_swapchain_format) {
|
||||
case MTLPixelFormatRGBA8Unorm_sRGB:
|
||||
// Even though this is an sRGB framebuffer format we're using UNORM here.
|
||||
// The reason here is because Godot does a linear to sRGB conversion while
|
||||
// with the sRGB format, this conversion would be doubled by the hardware.
|
||||
// This also means we're reading the values as is for our preview on screen.
|
||||
// The OpenXR runtime however is still treating this as an sRGB format and
|
||||
// will thus do an sRGB -> Linear conversion as expected.
|
||||
//format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
format = RenderingDevice::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
case MTLPixelFormatBGRA8Unorm_sRGB:
|
||||
format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UNORM;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
case MTLPixelFormatRGBA8Uint:
|
||||
format = RenderingDevice::DATA_FORMAT_R8G8B8A8_UINT;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
case MTLPixelFormatDepth32Float:
|
||||
format = RenderingDevice::DATA_FORMAT_D32_SFLOAT;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
break;
|
||||
case MTLPixelFormatDepth24Unorm_Stencil8:
|
||||
format = RenderingDevice::DATA_FORMAT_D24_UNORM_S8_UINT;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
break;
|
||||
case MTLPixelFormatDepth32Float_Stencil8:
|
||||
format = RenderingDevice::DATA_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
break;
|
||||
default:
|
||||
// Continue with our default value.
|
||||
print_line("OpenXR: Unsupported swapchain format", p_swapchain_format);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (p_sample_count) {
|
||||
case 1:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_1;
|
||||
break;
|
||||
case 2:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_2;
|
||||
break;
|
||||
case 4:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_4;
|
||||
break;
|
||||
case 8:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_8;
|
||||
break;
|
||||
case 16:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_16;
|
||||
break;
|
||||
case 32:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_32;
|
||||
break;
|
||||
case 64:
|
||||
samples = RenderingDevice::TEXTURE_SAMPLES_64;
|
||||
break;
|
||||
default:
|
||||
// Continue with our default value.
|
||||
print_line("OpenXR: Unsupported sample count", p_sample_count);
|
||||
break;
|
||||
}
|
||||
|
||||
Vector<RID> texture_rids;
|
||||
|
||||
// Create Godot texture objects for each entry in our swapchain.
|
||||
for (uint64_t i = 0; i < swapchain_length; i++) {
|
||||
// Note, the formats we sent to render_device are ignored on metal.
|
||||
RID image_rid = rendering_device->texture_create_from_extension(
|
||||
p_array_size == 1 ? RenderingDevice::TEXTURE_TYPE_2D : RenderingDevice::TEXTURE_TYPE_2D_ARRAY,
|
||||
format,
|
||||
samples,
|
||||
usage_flags,
|
||||
(uint64_t)images[i].texture,
|
||||
p_width,
|
||||
p_height,
|
||||
1,
|
||||
p_array_size);
|
||||
|
||||
texture_rids.push_back(image_rid);
|
||||
}
|
||||
|
||||
data->texture_rids = texture_rids;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenXRMetalExtension::cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) {
|
||||
if (*p_swapchain_graphics_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
SwapchainGraphicsData *data = (SwapchainGraphicsData *)*p_swapchain_graphics_data;
|
||||
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL(rendering_server);
|
||||
RenderingDevice *rendering_device = rendering_server->get_rendering_device();
|
||||
ERR_FAIL_NULL(rendering_device);
|
||||
|
||||
for (const RID &texture_rid : data->texture_rids) {
|
||||
rendering_device->free(texture_rid);
|
||||
}
|
||||
data->texture_rids.clear();
|
||||
|
||||
memdelete(data);
|
||||
*p_swapchain_graphics_data = nullptr;
|
||||
}
|
||||
|
||||
bool OpenXRMetalExtension::create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) {
|
||||
// Even though this is a Metal renderer we're using OpenGL coordinate systems.
|
||||
OpenXRUtil::XrMatrix4x4f matrix;
|
||||
OpenXRUtil::XrMatrix4x4f_CreateProjectionFov(&matrix, OpenXRUtil::GRAPHICS_OPENGL, p_fov, (float)p_z_near, (float)p_z_far);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r_camera_matrix.columns[j][i] = matrix.m[j * 4 + i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RID OpenXRMetalExtension::get_texture(void *p_swapchain_graphics_data, int p_image_index) {
|
||||
SwapchainGraphicsData *data = (SwapchainGraphicsData *)p_swapchain_graphics_data;
|
||||
ERR_FAIL_NULL_V(data, RID());
|
||||
|
||||
ERR_FAIL_INDEX_V(p_image_index, data->texture_rids.size(), RID());
|
||||
return data->texture_rids[p_image_index];
|
||||
}
|
||||
|
|
@ -56,11 +56,6 @@
|
|||
// feature off.
|
||||
// See: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_sRGB_write_control.txt
|
||||
|
||||
// On OpenGLES this is not defined in our standard headers..
|
||||
#ifndef GL_FRAMEBUFFER_SRGB
|
||||
#define GL_FRAMEBUFFER_SRGB 0x8DB9
|
||||
#endif
|
||||
|
||||
HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
|
|
@ -69,6 +64,9 @@ HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() {
|
|||
#else
|
||||
request_extensions[XR_KHR_OPENGL_ENABLE_EXTENSION_NAME] = nullptr;
|
||||
#endif
|
||||
#if defined(LINUXBSD_ENABLED) && defined(EGL_ENABLED) && defined(WAYLAND_ENABLED)
|
||||
request_extensions[XR_MNDX_EGL_ENABLE_EXTENSION_NAME] = &egl_extension_enabled;
|
||||
#endif
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
|
@ -133,9 +131,14 @@ bool OpenXROpenGLExtension::check_graphics_api_support(XrVersion p_desired_versi
|
|||
XrGraphicsBindingOpenGLWin32KHR OpenXROpenGLExtension::graphics_binding_gl;
|
||||
#elif defined(ANDROID_ENABLED)
|
||||
XrGraphicsBindingOpenGLESAndroidKHR OpenXROpenGLExtension::graphics_binding_gl;
|
||||
#elif defined(X11_ENABLED)
|
||||
#elif defined(LINUXBSD_ENABLED)
|
||||
#ifdef X11_ENABLED
|
||||
XrGraphicsBindingOpenGLXlibKHR OpenXROpenGLExtension::graphics_binding_gl;
|
||||
#endif
|
||||
#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED)
|
||||
XrGraphicsBindingEGLMNDX OpenXROpenGLExtension::graphics_binding_egl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_next_pointer) {
|
||||
XrVersion desired_version = XR_MAKE_VERSION(3, 3, 0);
|
||||
|
|
@ -147,10 +150,6 @@ void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_nex
|
|||
|
||||
DisplayServer *display_server = DisplayServer::get_singleton();
|
||||
|
||||
#ifdef WAYLAND_ENABLED
|
||||
ERR_FAIL_COND_V_MSG(display_server->get_name() == "Wayland", p_next_pointer, "OpenXR is not yet supported on OpenGL Wayland.");
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
graphics_binding_gl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR,
|
||||
graphics_binding_gl.next = p_next_pointer;
|
||||
|
|
@ -164,7 +163,23 @@ void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_nex
|
|||
graphics_binding_gl.display = (void *)display_server->window_get_native_handle(DisplayServer::DISPLAY_HANDLE);
|
||||
graphics_binding_gl.config = (EGLConfig)0; // https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/tests/hello_xr/graphicsplugin_opengles.cpp#L122
|
||||
graphics_binding_gl.context = (void *)display_server->window_get_native_handle(DisplayServer::OPENGL_CONTEXT);
|
||||
#elif defined(X11_ENABLED)
|
||||
#else
|
||||
#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED)
|
||||
if (display_server->get_name() == "Wayland") {
|
||||
ERR_FAIL_COND_V_MSG(!egl_extension_enabled, p_next_pointer, "OpenXR cannot initialize on Wayland without the XR_MNDX_egl_enable extension.");
|
||||
|
||||
graphics_binding_egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
|
||||
graphics_binding_egl.next = p_next_pointer;
|
||||
|
||||
graphics_binding_egl.getProcAddress = eglGetProcAddress;
|
||||
graphics_binding_egl.display = (void *)display_server->window_get_native_handle(DisplayServer::EGL_DISPLAY);
|
||||
graphics_binding_egl.config = (void *)display_server->window_get_native_handle(DisplayServer::EGL_CONFIG);
|
||||
graphics_binding_egl.context = (void *)display_server->window_get_native_handle(DisplayServer::OPENGL_CONTEXT);
|
||||
|
||||
return &graphics_binding_egl;
|
||||
}
|
||||
#endif
|
||||
#if defined(X11_ENABLED)
|
||||
graphics_binding_gl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR;
|
||||
graphics_binding_gl.next = p_next_pointer;
|
||||
|
||||
|
|
@ -178,10 +193,15 @@ void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_nex
|
|||
|
||||
// spec says to use proper values but runtimes don't care
|
||||
graphics_binding_gl.visualid = 0;
|
||||
graphics_binding_gl.glxFBConfig = 0;
|
||||
graphics_binding_gl.glxFBConfig = nullptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(ANDROID_ENABLED) || defined(X11_ENABLED)
|
||||
return &graphics_binding_gl;
|
||||
#else
|
||||
return p_next_pointer;
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenXROpenGLExtension::get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) {
|
||||
|
|
@ -196,23 +216,6 @@ void OpenXROpenGLExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_d
|
|||
p_usable_depth_formats.push_back(GL_DEPTH_COMPONENT24);
|
||||
}
|
||||
|
||||
void OpenXROpenGLExtension::on_pre_draw_viewport(RID p_render_target) {
|
||||
if (srgb_ext_is_available) {
|
||||
hw_linear_to_srgb_is_enabled = glIsEnabled(GL_FRAMEBUFFER_SRGB);
|
||||
if (hw_linear_to_srgb_is_enabled) {
|
||||
// Disable this.
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenXROpenGLExtension::on_post_draw_viewport(RID p_render_target) {
|
||||
if (srgb_ext_is_available && hw_linear_to_srgb_is_enabled) {
|
||||
// Re-enable this.
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
|
||||
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
|
||||
ERR_FAIL_NULL_V(texture_storage, false);
|
||||
|
|
@ -225,33 +228,32 @@ bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
}
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
XrSwapchainImageOpenGLESKHR *images = (XrSwapchainImageOpenGLESKHR *)memalloc(sizeof(XrSwapchainImageOpenGLESKHR) * swapchain_length);
|
||||
LocalVector<XrSwapchainImageOpenGLESKHR> images;
|
||||
#else
|
||||
XrSwapchainImageOpenGLKHR *images = (XrSwapchainImageOpenGLKHR *)memalloc(sizeof(XrSwapchainImageOpenGLKHR) * swapchain_length);
|
||||
LocalVector<XrSwapchainImageOpenGLKHR> images;
|
||||
#endif
|
||||
ERR_FAIL_NULL_V_MSG(images, false, "OpenXR Couldn't allocate memory for swap chain image");
|
||||
images.resize(swapchain_length);
|
||||
|
||||
for (uint64_t i = 0; i < swapchain_length; i++) {
|
||||
#ifdef ANDROID_ENABLED
|
||||
images[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR;
|
||||
for (XrSwapchainImageOpenGLESKHR &image : images) {
|
||||
image.type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR;
|
||||
#else
|
||||
images[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR;
|
||||
for (XrSwapchainImageOpenGLKHR &image : images) {
|
||||
image.type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR;
|
||||
#endif
|
||||
images[i].next = nullptr;
|
||||
images[i].image = 0;
|
||||
image.next = nullptr;
|
||||
image.image = 0;
|
||||
}
|
||||
|
||||
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images);
|
||||
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images.ptr());
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Failed to get swapchaim images [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
||||
memfree(images);
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapchainGraphicsData *data = memnew(SwapchainGraphicsData);
|
||||
if (data == nullptr) {
|
||||
print_line("OpenXR: Failed to allocate memory for swapchain data");
|
||||
memfree(images);
|
||||
return false;
|
||||
}
|
||||
*r_swapchain_graphics_data = data;
|
||||
|
|
@ -262,8 +264,8 @@ bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
Vector<RID> texture_rids;
|
||||
|
||||
for (uint64_t i = 0; i < swapchain_length; i++) {
|
||||
RID texture_rid = texture_storage->texture_create_external(
|
||||
p_array_size == 1 ? GLES3::Texture::TYPE_2D : GLES3::Texture::TYPE_LAYERED,
|
||||
RID texture_rid = texture_storage->texture_create_from_native_handle(
|
||||
p_array_size == 1 ? RS::TEXTURE_TYPE_2D : RS::TEXTURE_TYPE_LAYERED,
|
||||
format,
|
||||
images[i].image,
|
||||
p_width,
|
||||
|
|
@ -276,8 +278,6 @@ bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
|
||||
data->texture_rids = texture_rids;
|
||||
|
||||
memfree(images);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +312,8 @@ void OpenXROpenGLExtension::cleanup_swapchain_graphics_data(void **p_swapchain_g
|
|||
|
||||
SwapchainGraphicsData *data = (SwapchainGraphicsData *)*p_swapchain_graphics_data;
|
||||
|
||||
for (int i = 0; i < data->texture_rids.size(); i++) {
|
||||
texture_storage->texture_free(data->texture_rids[i]);
|
||||
for (const RID &texture_rid : data->texture_rids) {
|
||||
texture_storage->texture_free(texture_rid);
|
||||
}
|
||||
data->texture_rids.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ public:
|
|||
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
|
||||
|
||||
virtual void on_pre_draw_viewport(RID p_render_target) override;
|
||||
virtual void on_post_draw_viewport(RID p_render_target) override;
|
||||
|
||||
virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override;
|
||||
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override;
|
||||
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override;
|
||||
|
|
@ -67,8 +64,17 @@ private:
|
|||
static XrGraphicsBindingOpenGLWin32KHR graphics_binding_gl;
|
||||
#elif defined(ANDROID_ENABLED)
|
||||
static XrGraphicsBindingOpenGLESAndroidKHR graphics_binding_gl;
|
||||
#else // Linux/X11
|
||||
#elif defined(LINUXBSD_ENABLED)
|
||||
#ifdef X11_ENABLED
|
||||
static XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl;
|
||||
#endif
|
||||
#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED)
|
||||
static XrGraphicsBindingEGLMNDX graphics_binding_egl;
|
||||
|
||||
bool egl_extension_enabled = false;
|
||||
#endif
|
||||
#else
|
||||
#error "OpenXR with OpenGL isn't supported on this platform"
|
||||
#endif
|
||||
|
||||
struct SwapchainGraphicsData {
|
||||
|
|
@ -76,9 +82,6 @@ private:
|
|||
Vector<RID> texture_rids;
|
||||
};
|
||||
|
||||
bool srgb_ext_is_available = true;
|
||||
bool hw_linear_to_srgb_is_enabled = false;
|
||||
|
||||
bool check_graphics_api_support(XrVersion p_desired_version);
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ void OpenXRVulkanExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_s
|
|||
}
|
||||
|
||||
bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
|
||||
XrSwapchainImageVulkanKHR *images = nullptr;
|
||||
LocalVector<XrSwapchainImageVulkanKHR> images;
|
||||
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(rendering_server, false);
|
||||
|
|
@ -253,27 +253,23 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
return false;
|
||||
}
|
||||
|
||||
images = (XrSwapchainImageVulkanKHR *)memalloc(sizeof(XrSwapchainImageVulkanKHR) * swapchain_length);
|
||||
ERR_FAIL_NULL_V_MSG(images, false, "OpenXR Couldn't allocate memory for swap chain image");
|
||||
images.resize(swapchain_length);
|
||||
|
||||
for (uint64_t i = 0; i < swapchain_length; i++) {
|
||||
images[i].type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR;
|
||||
images[i].next = nullptr;
|
||||
images[i].image = VK_NULL_HANDLE;
|
||||
for (XrSwapchainImageVulkanKHR &image : images) {
|
||||
image.type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR;
|
||||
image.next = nullptr;
|
||||
image.image = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images);
|
||||
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images.ptr());
|
||||
if (XR_FAILED(result)) {
|
||||
print_line("OpenXR: Failed to get swapchaim images [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
||||
memfree(images);
|
||||
return false;
|
||||
}
|
||||
|
||||
// SwapchainGraphicsData *data = (SwapchainGraphicsData *)memalloc(sizeof(SwapchainGraphicsData));
|
||||
SwapchainGraphicsData *data = memnew(SwapchainGraphicsData);
|
||||
if (data == nullptr) {
|
||||
print_line("OpenXR: Failed to allocate memory for swapchain data");
|
||||
memfree(images);
|
||||
return false;
|
||||
}
|
||||
*r_swapchain_graphics_data = data;
|
||||
|
|
@ -291,12 +287,12 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
// This also means we're reading the values as is for our preview on screen.
|
||||
// The OpenXR runtime however is still treating this as an sRGB format and
|
||||
// will thus do an sRGB -> Linear conversion as expected.
|
||||
// format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
//format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
format = RenderingDevice::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
||||
// format = RenderingDevice::DATA_FORMAT_B8G8R8A8_SRGB;
|
||||
//format = RenderingDevice::DATA_FORMAT_B8G8R8A8_SRGB;
|
||||
format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UNORM;
|
||||
usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
|
|
@ -322,7 +318,7 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
break;
|
||||
default:
|
||||
// continue with our default value
|
||||
print_line("Unsupported swapchain format ", p_swapchain_format);
|
||||
print_line("OpenXR: Unsupported swapchain format", p_swapchain_format);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -350,20 +346,20 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
break;
|
||||
default:
|
||||
// continue with our default value
|
||||
print_line("Unsupported sample count ", p_sample_count);
|
||||
print_line("OpenXR: Unsupported sample count", p_sample_count);
|
||||
break;
|
||||
}
|
||||
|
||||
Vector<RID> texture_rids;
|
||||
|
||||
// create Godot texture objects for each entry in our swapchain
|
||||
for (uint64_t i = 0; i < swapchain_length; i++) {
|
||||
for (const XrSwapchainImageVulkanKHR &swapchain_image : images) {
|
||||
RID image_rid = rendering_device->texture_create_from_extension(
|
||||
p_array_size == 1 ? RenderingDevice::TEXTURE_TYPE_2D : RenderingDevice::TEXTURE_TYPE_2D_ARRAY,
|
||||
format,
|
||||
samples,
|
||||
usage_flags,
|
||||
(uint64_t)images[i].image,
|
||||
(uint64_t)swapchain_image.image,
|
||||
p_width,
|
||||
p_height,
|
||||
1,
|
||||
|
|
@ -374,13 +370,11 @@ bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
|
|||
|
||||
data->texture_rids = texture_rids;
|
||||
|
||||
memfree(images);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenXRVulkanExtension::create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) {
|
||||
// Even though this is a Vulkan renderer we're using OpenGL coordinate systems
|
||||
// Even though this is a Vulkan renderer we're using OpenGL coordinate systems.
|
||||
OpenXRUtil::XrMatrix4x4f matrix;
|
||||
OpenXRUtil::XrMatrix4x4f_CreateProjectionFov(&matrix, OpenXRUtil::GRAPHICS_OPENGL, p_fov, (float)p_z_near, (float)p_z_far);
|
||||
|
||||
|
|
@ -413,9 +407,9 @@ void OpenXRVulkanExtension::cleanup_swapchain_graphics_data(void **p_swapchain_g
|
|||
RenderingDevice *rendering_device = rendering_server->get_rendering_device();
|
||||
ERR_FAIL_NULL(rendering_device);
|
||||
|
||||
for (int i = 0; i < data->texture_rids.size(); i++) {
|
||||
// This should clean up our RIDs and associated texture objects but shouldn't destroy the images, they are owned by our XrSwapchain
|
||||
rendering_device->free(data->texture_rids[i]);
|
||||
for (const RID &texture_rid : data->texture_rids) {
|
||||
// This should clean up our RIDs and associated texture objects but shouldn't destroy the images, they are owned by our XrSwapchain.
|
||||
rendering_device->free(texture_rid);
|
||||
}
|
||||
data->texture_rids.clear();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue