slight rework of handleRealMouseMoveEvent

This commit is contained in:
Brad Hefta-Gaub 2016-02-18 14:40:55 -08:00
parent 843039f741
commit adcadedc65
3 changed files with 20 additions and 16 deletions

View file

@ -2203,11 +2203,9 @@ 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) {
if (isHMDMode()) {
_compositor.handleRealMouseMoveEvent();
// handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
if (_compositor.handleRealMouseMoveEvent()) {
return; // bail
} else {
_compositor.trackRealMouseMoveEvent(); // FIXME - super janky
}
}

View file

@ -319,20 +319,26 @@ void ApplicationCompositor::handleLeaveEvent() {
}
}
void ApplicationCompositor::trackRealMouseMoveEvent() {
_lastKnownRealMouse = QCursor::pos();
}
bool ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
void ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
// If the mouse move came from a capture mouse related move, we completely ignore it.
if (_ignoreMouseMove) {
_ignoreMouseMove = false;
return;
return true; // swallow the event
}
auto newPosition = QCursor::pos();
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
_lastKnownRealMouse = newPosition;
setReticlePosition(newReticlePosition, sendFakeEvent);
// If we're in HMD mode
if (qApp->isHMDMode()) {
auto newPosition = QCursor::pos();
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
_lastKnownRealMouse = newPosition;
setReticlePosition(newReticlePosition, sendFakeEvent);
return true; // swallow the event
} else {
_lastKnownRealMouse = QCursor::pos();
}
return false; // let the caller know to process the event
}
glm::vec2 ApplicationCompositor::getReticlePosition() {

View file

@ -98,8 +98,8 @@ public:
ReticleInterface* getReticleInterface() { return _reticleInterface; }
void handleRealMouseMoveEvent(bool sendFakeEvent = true);
void trackRealMouseMoveEvent();
/// return value - true means the caller should not process the event further
bool handleRealMouseMoveEvent(bool sendFakeEvent = true);
void handleLeaveEvent();
QPointF getMouseEventPosition(QMouseEvent* event);