mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-19 04:26:36 +02:00
hmd mouse check point
This commit is contained in:
parent
8b8b99c7e0
commit
279519b6d5
4 changed files with 26 additions and 21 deletions
|
@ -1266,6 +1266,7 @@ void Application::initializeUi() {
|
|||
QPointF result = pt;
|
||||
auto displayPlugin = getActiveDisplayPlugin();
|
||||
if (displayPlugin->isHmd()) {
|
||||
_compositor.handleRealMouseMoveEvent(false);
|
||||
auto fakeScreen = _compositor.getReticlePosition();
|
||||
auto resultVec = _compositor.screenToOverlay(fakeScreen); // toGlm(pt));
|
||||
result = QPointF(resultVec.x, resultVec.y);
|
||||
|
@ -2209,12 +2210,13 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
|||
|
||||
// if this is a real mouse event, and we're in HMD mode, then we should use it to move the
|
||||
// compositor reticle
|
||||
if (!_fakedMouseEvent && isHMDMode()) {
|
||||
_compositor.handleRealMouseMoveEvent(event);
|
||||
return; // bail
|
||||
}
|
||||
if (!_fakedMouseEvent) {
|
||||
_compositor.trackRealMouseMoveEvent(event); // FIXME - super janky
|
||||
if (isHMDMode()) {
|
||||
_compositor.handleRealMouseMoveEvent();
|
||||
return; // bail
|
||||
} else {
|
||||
_compositor.trackRealMouseMoveEvent(); // FIXME - super janky
|
||||
}
|
||||
}
|
||||
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
|
|
|
@ -321,14 +321,14 @@ void ApplicationCompositor::handleLeaveEvent() {
|
|||
}
|
||||
}
|
||||
|
||||
void ApplicationCompositor::trackRealMouseMoveEvent(QMouseEvent* event) {
|
||||
qDebug() << __FUNCTION__ << "() BEFORE _lastKnownRealMouse:" << _lastKnownRealMouse;
|
||||
void ApplicationCompositor::trackRealMouseMoveEvent() {
|
||||
qDebug() << __FUNCTION__ << "(event) BEFORE _lastKnownRealMouse:" << _lastKnownRealMouse;
|
||||
_lastKnownRealMouse = QCursor::pos();
|
||||
qDebug() << __FUNCTION__ << "() AFTER _lastKnownRealMouse:" << _lastKnownRealMouse;
|
||||
qDebug() << __FUNCTION__ << "(event) AFTER _lastKnownRealMouse:" << _lastKnownRealMouse;
|
||||
}
|
||||
|
||||
void ApplicationCompositor::handleRealMouseMoveEvent(QMouseEvent* event) {
|
||||
qDebug() << __FUNCTION__ << "() event:" << event;
|
||||
void ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
|
||||
qDebug() << __FUNCTION__ << "()";
|
||||
if (_ignoreMouseMove) {
|
||||
qDebug() << __FUNCTION__ << "() IGNORE MOUSE MOVE!!!";
|
||||
_ignoreMouseMove = false;
|
||||
|
@ -347,7 +347,7 @@ void ApplicationCompositor::handleRealMouseMoveEvent(QMouseEvent* event) {
|
|||
_lastKnownRealMouse = newPosition;
|
||||
|
||||
qDebug() << ".... about to call setReticlePosition() newReticlePosition:" << newReticlePosition;
|
||||
setReticlePosition(newReticlePosition);
|
||||
setReticlePosition(newReticlePosition, sendFakeEvent);
|
||||
}
|
||||
|
||||
glm::vec2 ApplicationCompositor::getReticlePosition() {
|
||||
|
@ -356,17 +356,18 @@ glm::vec2 ApplicationCompositor::getReticlePosition() {
|
|||
}
|
||||
return toGlm(QCursor::pos());
|
||||
}
|
||||
void ApplicationCompositor::setReticlePosition(glm::vec2 position) {
|
||||
void ApplicationCompositor::setReticlePosition(glm::vec2 position, bool sendFakeEvent) {
|
||||
if (qApp->isHMDMode()) {
|
||||
_reticlePositionInHMD = glm::clamp(position, vec2(0), vec2(VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y));
|
||||
|
||||
// in HMD mode we need to fake our mouse moves...
|
||||
QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
||||
QMouseEvent event(QEvent::MouseMove, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
||||
|
||||
qDebug() << "about to call .... qApp->fakeMouseEvent(&event);";
|
||||
qApp->fakeMouseEvent(&event);
|
||||
if (sendFakeEvent) {
|
||||
// in HMD mode we need to fake our mouse moves...
|
||||
QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
||||
QMouseEvent event(QEvent::MouseMove, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
||||
|
||||
qDebug() << "about to call .... qApp->fakeMouseEvent(&event);";
|
||||
qApp->fakeMouseEvent(&event);
|
||||
}
|
||||
} else {
|
||||
// NOTE: This is some debugging code we will leave in while debugging various reticle movement strategies,
|
||||
// remove it after we're done
|
||||
|
|
|
@ -94,12 +94,12 @@ public:
|
|||
Q_INVOKABLE void setReticleDepth(float depth) { _reticleDepth = depth; }
|
||||
|
||||
Q_INVOKABLE glm::vec2 getReticlePosition();
|
||||
Q_INVOKABLE void setReticlePosition(glm::vec2 position);
|
||||
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
|
||||
|
||||
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
||||
|
||||
void handleRealMouseMoveEvent(QMouseEvent* event);
|
||||
void trackRealMouseMoveEvent(QMouseEvent* event);
|
||||
void handleRealMouseMoveEvent(bool sendFakeEvent = true);
|
||||
void trackRealMouseMoveEvent();
|
||||
void handleLeaveEvent();
|
||||
QPointF getMouseEventPosition(QMouseEvent* event);
|
||||
|
||||
|
|
|
@ -573,8 +573,10 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even
|
|||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove: {
|
||||
//qDebug() << __FUNCTION__ << "event:" << event;
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos(), originalDestination);
|
||||
qDebug() << __FUNCTION__ << "transformedPos:" << transformedPos;
|
||||
QMouseEvent mappedEvent(mouseEvent->type(),
|
||||
transformedPos,
|
||||
mouseEvent->screenPos(), mouseEvent->button(),
|
||||
|
|
Loading…
Reference in a new issue