From e0acb03cc055105243d53b8fd40eb5367843dfaa Mon Sep 17 00:00:00 2001 From: oahc09 Date: Mon, 9 Oct 2023 17:15:56 +0800 Subject: [PATCH] feat:[xr] support dispatch xr event to ts --- native/cocos/platform/interfaces/modules/XRCommon.h | 1 + native/cocos/platform/java/modules/XRInterface.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/native/cocos/platform/interfaces/modules/XRCommon.h b/native/cocos/platform/interfaces/modules/XRCommon.h index 682c448c005..d33f2115081 100644 --- a/native/cocos/platform/interfaces/modules/XRCommon.h +++ b/native/cocos/platform/interfaces/modules/XRCommon.h @@ -120,6 +120,7 @@ enum class XRConfigKey { ASYNC_LOAD_ASSETS_IMAGE_RESULTS = 56, LEFT_CONTROLLER_ACTIVE = 57, RIGHT_CONTROLLER_ACTIVE= 58, + TS_EVENT_CALLBACK = 59, MAX_COUNT }; diff --git a/native/cocos/platform/java/modules/XRInterface.cpp b/native/cocos/platform/java/modules/XRInterface.cpp index b6224a9f137..ee74e100889 100644 --- a/native/cocos/platform/java/modules/XRInterface.cpp +++ b/native/cocos/platform/java/modules/XRInterface.cpp @@ -499,6 +499,10 @@ void XRInterface::initialize(void *javaVM, void *activity) { }); } else if (key == xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE && value.isInt()) { _isFlipPixelY = value.getInt() == static_cast(gfx::API::GLES3); + } else if (key == xr::XRConfigKey::TS_EVENT_CALLBACK) { + se::ValueArray args; + args.emplace_back(se::Value(value.getString())); + EventDispatcher::doDispatchJsEvent("onXREvent", args); } }); #if XR_OEM_PICO