feat:[xr] support dispatch xr event to ts (#16382)

* feat:[xr] support dispatch xr event to ts

* improve:add se::AutoHandleScope scope;
This commit is contained in:
oahc09
2023-10-10 13:53:38 +08:00
committed by GitHub
parent 093bc8724e
commit fcb95b5a37
2 changed files with 8 additions and 0 deletions
@@ -499,6 +499,11 @@ void XRInterface::initialize(void *javaVM, void *activity) {
});
} else if (key == xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE && value.isInt()) {
_isFlipPixelY = value.getInt() == static_cast<int>(gfx::API::GLES3);
} else if (key == xr::XRConfigKey::TS_EVENT_CALLBACK) {
se::AutoHandleScope scope;
se::ValueArray args;
args.emplace_back(se::Value(value.getString()));
EventDispatcher::doDispatchJsEvent("onXREvent", args);
}
});
#if XR_OEM_PICO
@@ -871,6 +876,7 @@ bool XRInterface::beginRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] beginRenderEyeFrame %d", eye);
if (_isEnabledEyeRenderJsCallback) {
se::AutoHandleScope scope;
se::ValueArray args;
args.emplace_back(se::Value(eye));
EventDispatcher::doDispatchJsEvent("onXREyeRenderBegin", args);
@@ -895,6 +901,7 @@ bool XRInterface::endRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] endRenderEyeFrame %d", eye);
if (_isEnabledEyeRenderJsCallback) {
se::AutoHandleScope scope;
se::ValueArray args;
args.emplace_back(se::Value(eye));
EventDispatcher::doDispatchJsEvent("onXREyeRenderEnd", args);