mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
more work on dragging in hmd
This commit is contained in:
parent
279519b6d5
commit
c4fc3e4057
3 changed files with 13 additions and 23 deletions
|
@ -1743,7 +1743,7 @@ bool Application::event(QEvent* event) {
|
||||||
|
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
qDebug() << __FUNCTION__ << "(QEvent::MouseMove)... line:" << __LINE__;
|
//qDebug() << __FUNCTION__ << "(QEvent::MouseMove)... line:" << __LINE__;
|
||||||
mouseMoveEvent((QMouseEvent*)event);
|
mouseMoveEvent((QMouseEvent*)event);
|
||||||
return true;
|
return true;
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
|
@ -1781,7 +1781,7 @@ bool Application::event(QEvent* event) {
|
||||||
dropEvent(static_cast<QDropEvent*>(event));
|
dropEvent(static_cast<QDropEvent*>(event));
|
||||||
return true;
|
return true;
|
||||||
case QEvent::Leave:
|
case QEvent::Leave:
|
||||||
qDebug() << __FUNCTION__ << "().... QEvent::Leave";
|
//qDebug() << __FUNCTION__ << "().... QEvent::Leave";
|
||||||
break; // fall through
|
break; // fall through
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1813,7 +1813,7 @@ bool Application::event(QEvent* event) {
|
||||||
bool Application::eventFilter(QObject* object, QEvent* event) {
|
bool Application::eventFilter(QObject* object, QEvent* event) {
|
||||||
|
|
||||||
if (event->type() == QEvent::Leave) {
|
if (event->type() == QEvent::Leave) {
|
||||||
qDebug() << __FUNCTION__ << "().... QEvent::Leave";
|
//qDebug() << __FUNCTION__ << "().... QEvent::Leave";
|
||||||
_compositor.handleLeaveEvent();
|
_compositor.handleLeaveEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2204,7 +2204,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
if (_aboutToQuit) {
|
if (_aboutToQuit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << __FUNCTION__ << "line:" << __LINE__ << "event:" << event << "_fakedMouseEvent:" << _fakedMouseEvent;
|
//qDebug() << __FUNCTION__ << "line:" << __LINE__ << "event:" << event << "_fakedMouseEvent:" << _fakedMouseEvent;
|
||||||
|
|
||||||
maybeToggleMenuVisible(event);
|
maybeToggleMenuVisible(event);
|
||||||
|
|
||||||
|
@ -2261,13 +2261,13 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
// keyboard shortcuts not to be swallowed by them. In particular, WebEngineViews
|
// keyboard shortcuts not to be swallowed by them. In particular, WebEngineViews
|
||||||
// will consume all keyboard events.
|
// will consume all keyboard events.
|
||||||
offscreenUi->unfocusWindows();
|
offscreenUi->unfocusWindows();
|
||||||
qDebug() << __FUNCTION__ << "event:" << event;
|
//qDebug() << __FUNCTION__ << "event:" << event;
|
||||||
|
|
||||||
auto eventPosition = _compositor.getMouseEventPosition(event);
|
auto eventPosition = _compositor.getMouseEventPosition(event);
|
||||||
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
|
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
|
||||||
|
|
||||||
qDebug() << __FUNCTION__ << " eventPosition:" << eventPosition;
|
//qDebug() << __FUNCTION__ << " eventPosition:" << eventPosition;
|
||||||
qDebug() << __FUNCTION__ << "transformedPos:" << transformedPos;
|
//qDebug() << __FUNCTION__ << "transformedPos:" << transformedPos;
|
||||||
|
|
||||||
QMouseEvent mappedEvent(event->type(),
|
QMouseEvent mappedEvent(event->type(),
|
||||||
transformedPos,
|
transformedPos,
|
||||||
|
|
|
@ -313,7 +313,6 @@ QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
|
||||||
void ApplicationCompositor::handleLeaveEvent() {
|
void ApplicationCompositor::handleLeaveEvent() {
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
auto applicationGeometry = qApp->getApplicationGeometry();
|
auto applicationGeometry = qApp->getApplicationGeometry();
|
||||||
qDebug() << "SENDING mouse back to center:" << applicationGeometry.center();
|
|
||||||
_ignoreMouseMove = true;
|
_ignoreMouseMove = true;
|
||||||
auto sendToPos = applicationGeometry.center();
|
auto sendToPos = applicationGeometry.center();
|
||||||
QCursor::setPos(sendToPos);
|
QCursor::setPos(sendToPos);
|
||||||
|
@ -322,31 +321,19 @@ void ApplicationCompositor::handleLeaveEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationCompositor::trackRealMouseMoveEvent() {
|
void ApplicationCompositor::trackRealMouseMoveEvent() {
|
||||||
qDebug() << __FUNCTION__ << "(event) BEFORE _lastKnownRealMouse:" << _lastKnownRealMouse;
|
|
||||||
_lastKnownRealMouse = QCursor::pos();
|
_lastKnownRealMouse = QCursor::pos();
|
||||||
qDebug() << __FUNCTION__ << "(event) AFTER _lastKnownRealMouse:" << _lastKnownRealMouse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
|
void ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
|
||||||
qDebug() << __FUNCTION__ << "()";
|
|
||||||
if (_ignoreMouseMove) {
|
if (_ignoreMouseMove) {
|
||||||
qDebug() << __FUNCTION__ << "() IGNORE MOUSE MOVE!!!";
|
|
||||||
_ignoreMouseMove = false;
|
_ignoreMouseMove = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto applicationGeometry = qApp->getApplicationGeometry();
|
auto applicationGeometry = qApp->getApplicationGeometry();
|
||||||
qDebug() << ".... applicationGeometry:" << applicationGeometry;
|
|
||||||
|
|
||||||
auto newPosition = QCursor::pos();
|
auto newPosition = QCursor::pos();
|
||||||
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
|
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
|
||||||
qDebug() << __FUNCTION__ << "() ..... _lastKnownRealMouse:" << _lastKnownRealMouse;
|
|
||||||
qDebug() << __FUNCTION__ << "() ............. newPosition:" << newPosition;
|
|
||||||
qDebug() << __FUNCTION__ << "() ....... changeInRealMouse:" << changeInRealMouse;
|
|
||||||
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
|
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
|
||||||
_lastKnownRealMouse = newPosition;
|
_lastKnownRealMouse = newPosition;
|
||||||
|
|
||||||
qDebug() << ".... about to call setReticlePosition() newReticlePosition:" << newReticlePosition;
|
|
||||||
setReticlePosition(newReticlePosition, sendFakeEvent);
|
setReticlePosition(newReticlePosition, sendFakeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,9 +350,12 @@ void ApplicationCompositor::setReticlePosition(glm::vec2 position, bool sendFake
|
||||||
if (sendFakeEvent) {
|
if (sendFakeEvent) {
|
||||||
// in HMD mode we need to fake our mouse moves...
|
// in HMD mode we need to fake our mouse moves...
|
||||||
QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
||||||
QMouseEvent event(QEvent::MouseMove, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
auto button = Qt::NoButton;
|
||||||
|
auto buttons = QApplication::mouseButtons();
|
||||||
|
auto modifiers = QApplication::keyboardModifiers();
|
||||||
|
QMouseEvent event(QEvent::MouseMove, globalPos, button, buttons, modifiers);
|
||||||
|
|
||||||
qDebug() << "about to call .... qApp->fakeMouseEvent(&event);";
|
//qDebug() << "about to call .... qApp->fakeMouseEvent(&event);";
|
||||||
qApp->fakeMouseEvent(&event);
|
qApp->fakeMouseEvent(&event);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -576,7 +576,7 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even
|
||||||
//qDebug() << __FUNCTION__ << "event:" << event;
|
//qDebug() << __FUNCTION__ << "event:" << event;
|
||||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos(), originalDestination);
|
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos(), originalDestination);
|
||||||
qDebug() << __FUNCTION__ << "transformedPos:" << transformedPos;
|
//qDebug() << __FUNCTION__ << "transformedPos:" << transformedPos;
|
||||||
QMouseEvent mappedEvent(mouseEvent->type(),
|
QMouseEvent mappedEvent(mouseEvent->type(),
|
||||||
transformedPos,
|
transformedPos,
|
||||||
mouseEvent->screenPos(), mouseEvent->button(),
|
mouseEvent->screenPos(), mouseEvent->button(),
|
||||||
|
|
Loading…
Reference in a new issue