add sendClickToUI

This commit is contained in:
amwatson 2024-02-09 00:24:11 -06:00
parent 8c3780f546
commit 32d8f8dc32
3 changed files with 17 additions and 20 deletions

View file

@ -255,7 +255,7 @@ bool UILayer::GetRayIntersectionWithPanel(const XrVector3f& start,
result2d, result3d);
}
// Next error code: -6
// Next error code: -7
int32_t UILayer::Init(const std::string& className,
const jobject activityObject, const XrVector3f& position,
const XrSession& session)
@ -283,6 +283,13 @@ int32_t UILayer::Init(const std::string& className,
"(Landroid/view/Surface;II)I");
BAIL_ON_COND(mSetSurfaceMethodId == nullptr, "could not find setSurface()",
-5);
mSendClickToUIMethodID =
mEnv->GetMethodID(mVrUILayerClass, "sendClickToUI", "(FFI)I");
BAIL_ON_COND(mSendClickToUIMethodID == nullptr,
"could not find sendClickToUI()", -6);
return 0;
}
@ -373,6 +380,6 @@ void UILayer::TryCreateSwapchain()
void UILayer::SendClickToUI(const XrVector2f& pos2d, const int type)
{
mEnv->CallIntMethod(mVrUILayerObject, mSendClickToWindowMethodID, pos2d.x,
mEnv->CallIntMethod(mVrUILayerObject, mSendClickToUIMethodID, pos2d.x,
pos2d.y, type);
}

View file

@ -96,6 +96,6 @@ private:
// the x, y offset of the view within the window, in case there are things
// like window decorations or status bars.
jmethodID mGetBoundsMethodID = nullptr;
jmethodID mSendClickToWindowMethodID = nullptr;
jmethodID mSendClickToUIMethodID = nullptr;
jmethodID mSetSurfaceMethodId = nullptr;
};

View file

@ -613,12 +613,12 @@ private:
layers[layerCount++].Quad = quadLayer;
}
#endif
if (mUILayer->IsSwapchainCreated()) {
if (mUILayer->IsSwapchainCreated())
{
mUILayer->Frame(gOpenXr->mLocalSpace, layers, layerCount);
mUILayer->Frame(gOpenXr->mLocalSpace, layers, layerCount);
}
{
{
bool shouldRenderCursor = false;
@ -663,26 +663,16 @@ private:
.mHandPositions[mInputStateFrame.mPreferredHand]
.pose,
XrVector3f{0, 0, -3.5f});
if (gShouldShowErrorMessage)
if (true)
{
#if defined(UI_LAYER)
shouldRenderCursor =
mErrorMessageLayer->GetRayIntersectionWithPanel(
start, end, cursorPos2d, pos3d);
position = pos3d;
// ALOGI("Cursor 3D pos: {} {} {}",
// cursorPos3d.x,
// cursorPos3d.y,
// cursorPos3d.z);
// ALOGI("Cursor 2D coords: {} {}", cursorPos2d.x,
// cursorPos2d.y);
mUILayer->GetRayIntersectionWithPanel(
start, end, cursorPos2d, cursorPose3d);
if (triggerState.changedSinceLastSync)
{
mErrorMessageLayer->SendClickToWindow(
mUILayer->SendClickToUI(
cursorPos2d, triggerState.currentState);
}
#endif
}
else
{