mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 10:42:10 +02:00
Cleanup code, comment out log, simplify radar is valid touch code (no more flag)
This commit is contained in:
parent
f0bcaa47c8
commit
fe9481b28d
2 changed files with 6 additions and 56 deletions
|
@ -167,31 +167,28 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event)
|
||||||
case QEvent::TouchEnd: {
|
case QEvent::TouchEnd: {
|
||||||
QTouchEvent *originalEvent = static_cast<QTouchEvent *>(event);
|
QTouchEvent *originalEvent = static_cast<QTouchEvent *>(event);
|
||||||
QEvent::Type fakeMouseEventType = QEvent::None;
|
QEvent::Type fakeMouseEventType = QEvent::None;
|
||||||
Qt::MouseButton fakeMouseButton = Qt::NoButton;
|
Qt::MouseButton fakeMouseButton = Qt::LeftButton;
|
||||||
Qt::MouseButtons fakeMouseButtons = Qt::NoButton;
|
Qt::MouseButtons fakeMouseButtons = Qt::NoButton;
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::TouchBegin:
|
case QEvent::TouchBegin:
|
||||||
fakeMouseEventType = QEvent::MouseButtonPress;
|
fakeMouseEventType = QEvent::MouseButtonPress;
|
||||||
fakeMouseButton = Qt::LeftButton;
|
|
||||||
fakeMouseButtons = Qt::LeftButton;
|
fakeMouseButtons = Qt::LeftButton;
|
||||||
break;
|
break;
|
||||||
case QEvent::TouchUpdate:
|
case QEvent::TouchUpdate:
|
||||||
fakeMouseEventType = QEvent::MouseMove;
|
fakeMouseEventType = QEvent::MouseMove;
|
||||||
fakeMouseButton = Qt::LeftButton;
|
|
||||||
fakeMouseButtons = Qt::LeftButton;
|
fakeMouseButtons = Qt::LeftButton;
|
||||||
break;
|
break;
|
||||||
case QEvent::TouchEnd:
|
case QEvent::TouchEnd:
|
||||||
fakeMouseEventType = QEvent::MouseButtonRelease;
|
fakeMouseEventType = QEvent::MouseButtonRelease;
|
||||||
fakeMouseButton = Qt::LeftButton;
|
|
||||||
fakeMouseButtons = Qt::NoButton;
|
fakeMouseButtons = Qt::NoButton;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fakeMouseEventType == QEvent::None) break;
|
// Same case as OffscreenUi.cpp::eventFilter: touch events are always being accepted so we now use mouse events and consider one touch, touchPoints()[0].
|
||||||
QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier);
|
QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier);
|
||||||
fakeMouseEvent.ignore();
|
fakeMouseEvent.ignore();
|
||||||
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) {
|
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) {
|
||||||
qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type()
|
/*qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type()
|
||||||
<< "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();
|
<< "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();*/
|
||||||
return fakeMouseEvent.isAccepted();
|
return fakeMouseEvent.isAccepted();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -118,19 +118,10 @@ function actionOnObjectFromEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePress(event) {
|
function mousePress(event) {
|
||||||
if (!isTouchValid(coords)) {
|
|
||||||
currentTouchIsValid = false;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
currentTouchIsValid = true;
|
|
||||||
}
|
|
||||||
mousePressOrTouchEnd(event);
|
mousePressOrTouchEnd(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressOrTouchEnd(event) {
|
function mousePressOrTouchEnd(event) {
|
||||||
if (!currentTouchIsValid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (radar) {
|
if (radar) {
|
||||||
if (actionOnObjectFromEvent(event)) {
|
if (actionOnObjectFromEvent(event)) {
|
||||||
return;
|
return;
|
||||||
|
@ -155,9 +146,6 @@ function fakeDoubleTap(event) {
|
||||||
teleporter.dragTeleportRelease(event);
|
teleporter.dragTeleportRelease(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentTouchIsValid = false; // Currently used to know if touch hasn't
|
|
||||||
// started on a UI overlay
|
|
||||||
|
|
||||||
var DOUBLE_TAP_TIME = 300;
|
var DOUBLE_TAP_TIME = 300;
|
||||||
var fakeDoubleTapStart = Date.now();
|
var fakeDoubleTapStart = Date.now();
|
||||||
var touchEndCount = 0;
|
var touchEndCount = 0;
|
||||||
|
@ -238,12 +226,6 @@ function touchEnd(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if touch is invalid, cancel
|
|
||||||
if (!currentTouchIsValid) {
|
|
||||||
printd("touchEnd fail because !currentTouchIsValid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (analyzeDoubleTap(event))
|
if (analyzeDoubleTap(event))
|
||||||
return; // double tap detected, finish
|
return; // double tap detected, finish
|
||||||
|
|
||||||
|
@ -345,20 +327,6 @@ function computePointAtPlaneY(x, y, py) {
|
||||||
p2.z, py);
|
p2.z, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
function isTouchValid(coords) {
|
|
||||||
// TODO: Extend to the detection of touches on new menu bars
|
|
||||||
var radarModeTouchValid = radarModeInterface.isTouchValid(coords);
|
|
||||||
|
|
||||||
// getItemAtPoint does not exist anymore, look for another way to know if we
|
|
||||||
// are touching buttons
|
|
||||||
// is it still needed?
|
|
||||||
return /* !tablet.getItemAtPoint(coords) && */radarModeTouchValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -373,16 +341,8 @@ function touchBegin(event) {
|
||||||
x : event.x,
|
x : event.x,
|
||||||
y : event.y
|
y : event.y
|
||||||
};
|
};
|
||||||
if (!isTouchValid(coords)) {
|
touchStartingCoordinates = coords;
|
||||||
printd("analyze touch - RADAR_TOUCH - INVALID");
|
touchBeginTime = Date.now();
|
||||||
currentTouchIsValid = false;
|
|
||||||
touchStartingCoordinates = null;
|
|
||||||
} else {
|
|
||||||
printd("analyze touch - RADAR_TOUCH - ok");
|
|
||||||
currentTouchIsValid = true;
|
|
||||||
touchStartingCoordinates = coords;
|
|
||||||
touchBeginTime = Date.now();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var startedDraggingCamera = false; // first time
|
var startedDraggingCamera = false; // first time
|
||||||
|
@ -848,9 +808,6 @@ function oneFingerTouchUpdate(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function touchUpdate(event) {
|
function touchUpdate(event) {
|
||||||
if (!currentTouchIsValid) {
|
|
||||||
return; // avoid moving and zooming when tap is over UI entities
|
|
||||||
}
|
|
||||||
if (event.isPinching || event.isPinchOpening) {
|
if (event.isPinching || event.isPinchOpening) {
|
||||||
pinchUpdate(event);
|
pinchUpdate(event);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1390,10 +1347,6 @@ radarModeInterface.setUniqueColor = function(c) {
|
||||||
uniqueColor = c;
|
uniqueColor = c;
|
||||||
};
|
};
|
||||||
|
|
||||||
radarModeInterface.isTouchValid = function(coords) {
|
|
||||||
return true; // by default
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = radarModeInterface;
|
module.exports = radarModeInterface;
|
||||||
|
|
||||||
function updateRadar() {
|
function updateRadar() {
|
||||||
|
|
Loading…
Reference in a new issue