Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions native/cocos/platform/interfaces/modules/XRCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
7 changes: 7 additions & 0 deletions native/cocos/platform/java/modules/XRInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Loading