Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit ac8aeb0

Browse files
MortimerGorokeianhzo
authored andcommitted
Fix movable keyboard in lay down mode (#1576)
1 parent 1863e60 commit ac8aeb0

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

app/src/main/cpp/WidgetMover.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,19 @@ struct WidgetMover::State {
6262

6363
vrb::Vector result = ProjectPoint(widget, hitPoint);
6464

65-
if (parentWidget && moveBehaviour == WidgetMoveBehaviour::KEYBOARD && widget->GetCylinder()) {
66-
// For Cylindrical keyboard move we want to use the x translation from the parent widget (the window)
67-
parentWidget->TestControllerIntersection(aStart, aDirection, hitPoint, hitNormal, false, isInWidget, hitDistance);
68-
if (hitDistance >= 0) {
69-
vrb::Vector point = ProjectPoint(parentWidget, hitPoint);
70-
result.x() = point.x();
71-
result.z() = point.z();
65+
if (parentWidget && moveBehaviour == WidgetMoveBehaviour::KEYBOARD) {
66+
if (widget->GetCylinder()) {
67+
// For Cylindrical keyboard move we want to use the x translation from the parent widget (the window)
68+
parentWidget->TestControllerIntersection(aStart, aDirection, hitPoint, hitNormal, false, isInWidget, hitDistance);
69+
if (hitDistance >= 0) {
70+
vrb::Vector point = ProjectPoint(parentWidget, hitPoint);
71+
result.x() = point.x();
72+
result.z() = point.z();
73+
}
7274
}
75+
76+
// Convert the world point to a point relative to the window.
77+
result = parentWidget->GetTransformNode()->GetWorldTransform().AfineInverse().MultiplyPosition(result);
7378
}
7479

7580
return result;
@@ -150,10 +155,8 @@ WidgetMover::HandleMove(const vrb::Vector& aStart, const vrb::Vector& aDirection
150155

151156
vrb::Vector delta = hitPoint - m.initialPoint;
152157
delta.y() = hitPoint.y() - m.initialPoint.y();
153-
delta.x() = vrb::Vector(hitPoint.x() - m.initialPoint.x(), 0.0f, hitPoint.z() - m.initialPoint.z()).Magnitude();
154-
if (hitPoint.x() < m.initialPoint.x()) {
155-
delta.x() *= -1.0f;
156-
}
158+
delta.x() = hitPoint.x() - m.initialPoint.x();
159+
157160

158161
if (m.moveBehaviour == WidgetMoveBehaviour::KEYBOARD) {
159162
return m.HandleKeyboardMove(delta);

0 commit comments

Comments
 (0)