From 0d6bfada40f94fe921e78d7a6b17d4eb9f9bb553 Mon Sep 17 00:00:00 2001 From: Cristian Duarte Date: Tue, 20 Mar 2018 17:24:38 -0300 Subject: [PATCH 1/4] Prevent Go To and Avatar windows to move Radar Mode's camera when touched or interacted with --- scripts/+android/defaultScripts.js | 5 +-- scripts/system/+android/androidCombined.js | 24 ++++++++++++++ scripts/system/+android/avatarSelection.js | 1 + scripts/system/+android/bottombar.js | 38 +++++++++++++++++++++- scripts/system/+android/modes.js | 29 ++++++++++++----- 5 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 scripts/system/+android/androidCombined.js diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index a8f6bf42a1..82e32a6d00 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -14,9 +14,10 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", + "system/+android/audio.js", + "system/+android/androidCombined.js"/*, "system/+android/bottombar.js", - "system/+android/audio.js" , - "system/+android/modes.js"/*, + "system/+android/modes.js", "system/away.js", "system/controllers/controllerDisplayManager.js", "system/controllers/handControllerGrabAndroid.js", diff --git a/scripts/system/+android/androidCombined.js b/scripts/system/+android/androidCombined.js new file mode 100644 index 0000000000..76a52bcab7 --- /dev/null +++ b/scripts/system/+android/androidCombined.js @@ -0,0 +1,24 @@ +"use strict"; +// +// androidCombined.js +// scripts/system/ +// +// Created by Gabriel Calero & Cristian Duarte on Mar 20, 2018 +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { // BEGIN LOCAL_SCOPE + +var modesInterface = Script.require('./modes.js'); +var bottombarInterface = Script.require('./bottombar.js'); + +function init() { + modesInterface.isRadarModeValidTouch = bottombarInterface.isRadarModeValidTouch;// set new function +} + +init(); + +}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/system/+android/avatarSelection.js b/scripts/system/+android/avatarSelection.js index 2b28fe2c9b..2946e541b5 100644 --- a/scripts/system/+android/avatarSelection.js +++ b/scripts/system/+android/avatarSelection.js @@ -35,6 +35,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'hide': Controller.setVPadHidden(false); + module.exports.hide(); module.exports.onHidden(); break; default: diff --git a/scripts/system/+android/bottombar.js b/scripts/system/+android/bottombar.js index 3435edb548..2fb332a33d 100644 --- a/scripts/system/+android/bottombar.js +++ b/scripts/system/+android/bottombar.js @@ -21,7 +21,9 @@ var loginBtn; var gotoScript = Script.require('./goto.js'); var avatarSelection = Script.require('./avatarSelection.js'); -var logEnabled = false; +var bottombarInterface = []; + +var logEnabled = true; function printd(str) { if (logEnabled) { @@ -262,6 +264,40 @@ Script.scriptEnding.connect(function () { GlobalServices.disconnected.disconnect(handleLogout); }); +function isRadarModeValidTouch(coords) { + var qmlFragments = [bottombar, bottomHudOptionsBar.qmlFragment]; + var windows = [gotoScript, avatarSelection]; + for (var i=0; i < qmlFragments.length; i++) { + var aQmlFrag = qmlFragments[i]; + if (aQmlFrag != null && aQmlFrag.isVisible() && + coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && + coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y + ) { + printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); + return false; + } + } + + for (var i=0; i < windows.length; i++) { + var aWin = windows[i]; + if (aWin != null && aWin.position() != null && aWin.isVisible() && + coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && + coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() + ) { + printd("isRadarModeValidTouch- false because of windows!? idx " + i); + return false; + } else { + printd("isRadarModeValidTouch- discarded of window idx " + i + " visible= " + aWin.isVisible()); + } + } + printd("isRadarModeValidTouch- true by default "); + return true; +} + +bottombarInterface.isRadarModeValidTouch = isRadarModeValidTouch; + +module.exports = bottombarInterface; + init(); }()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js index 097798e393..4bc4333a09 100644 --- a/scripts/system/+android/modes.js +++ b/scripts/system/+android/modes.js @@ -23,6 +23,8 @@ var logEnabled = true; var radar = Script.require('./radar.js'); var uniqueColor = Script.require('./uniqueColor.js'); +var modesInterface = {}; + function printd(str) { if (logEnabled) { print("[modes.js] " + str); @@ -184,33 +186,44 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) { } function isRadarModeValidTouch(coords) { + if (!modesInterface.isRadarModeValidTouch(coords)) { + printd("isRadarModeValidTouch- false because of modesInterface"); + return false; + } + printd("isRadarModeValidTouch- modesInterface is true, evaluating modesbar qmls.."); + var qmlFragments = [modesbar.qmlFragment]; var windows = []; for (var i=0; i < qmlFragments.length; i++) { var aQmlFrag = qmlFragments[i]; if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x * 3 && coords.x <= aQmlFrag.position.x * 3 + aQmlFrag.size.x * 3 && - coords.y >= aQmlFrag.position.y * 3 && coords.y <= aQmlFrag.position.y * 3 + aQmlFrag.size.y * 3 + coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && + coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y ) { - printd("godViewModeTouchValid- false because of qmlFragments!? idx " + i); + printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); return false; } } for (var i=0; i < windows.length; i++) { var aWin = windows[i]; - if (aWin != null && aWin.position() != null && - coords.x >= aWin.position().x * 3 && coords.x <= aWin.position().x * 3 + aWin.width() * 3 && - coords.y >= aWin.position().y * 3 && coords.y <= aWin.position().y * 3 + aWin.height() * 3 + if (aWin != null && aWin.position() != null && aWin.isVisible() && + coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && + coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() ) { - printd("godViewModeTouchValid- false because of windows!?"); + printd("isRadarModeValidTouch- false because of windows!? idx " + i); return false; } } - printd("godViewModeTouchValid- true by default "); + printd("isRadarModeValidTouch- true by default "); return true; } +// default +modesInterface.isRadarModeValidTouch = function(coords) {return true;}; + +module.exports = modesInterface; + Script.scriptEnding.connect(function () { shutdown(); }); From 242b009562de3f10c7b9f58a35d9a59883369e62 Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Fri, 23 Mar 2018 18:59:55 -0300 Subject: [PATCH 2/4] Android - Use mouse events for interacting with UI. Now LoginDialog UI interation does not move radar camera. Remove repeated tooggle call in audio.js. Adapt button to simulated mouse events. --- .../resources/qml/hifi/+android/button.qml | 4 +- libraries/qml/src/qml/OffscreenSurface.cpp | 37 +++++++++++++------ scripts/system/+android/audio.js | 1 - 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/hifi/+android/button.qml b/interface/resources/qml/hifi/+android/button.qml index 4822b6bf33..3e9ce39351 100644 --- a/interface/resources/qml/hifi/+android/button.qml +++ b/interface/resources/qml/hifi/+android/button.qml @@ -118,7 +118,7 @@ Item { tabletRoot.playButtonClickSound(); }*/ } - onEntered: { + onPressed: { button.isEntered = true; button.entered(); if (button.isActive) { @@ -127,7 +127,7 @@ Item { button.state = "hover state"; } } - onExited: { + onReleased: { button.isEntered = false; button.exited() if (button.isActive) { diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index 6580c5b1e8..ff36589b61 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -166,18 +166,33 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) case QEvent::TouchUpdate: case QEvent::TouchEnd: { QTouchEvent *originalEvent = static_cast(event); - QTouchEvent fakeEvent(*originalEvent); - auto newTouchPoints = fakeEvent.touchPoints(); - for (size_t i = 0; i < newTouchPoints.size(); ++i) { - const auto &originalPoint = originalEvent->touchPoints()[i]; - auto &newPoint = newTouchPoints[i]; - newPoint.setPos(originalPoint.pos()); + QEvent::Type fakeMouseEventType = QEvent::None; + Qt::MouseButton fakeMouseButton = Qt::NoButton; + Qt::MouseButtons fakeMouseButtons = Qt::NoButton; + switch (event->type()) { + case QEvent::TouchBegin: + fakeMouseEventType = QEvent::MouseButtonPress; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::LeftButton; + break; + case QEvent::TouchUpdate: + fakeMouseEventType = QEvent::MouseMove; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::LeftButton; + break; + case QEvent::TouchEnd: + fakeMouseEventType = QEvent::MouseButtonRelease; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::NoButton; + break; } - fakeEvent.setTouchPoints(newTouchPoints); - if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeEvent)) { - qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeEvent.type() - << "_quickWindow handled it... accepted:" << fakeEvent.isAccepted(); - return false; //event->isAccepted(); + if (fakeMouseEventType == QEvent::None) break; + QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier); + fakeMouseEvent.ignore(); + if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) { + qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() + << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted(); + return fakeMouseEvent.isAccepted(); } break; } diff --git a/scripts/system/+android/audio.js b/scripts/system/+android/audio.js index b4f156d4bf..955f74d63a 100644 --- a/scripts/system/+android/audio.js +++ b/scripts/system/+android/audio.js @@ -46,7 +46,6 @@ function onMuteClicked() { printd("On Mute Clicked"); //Menu.setIsOptionChecked("Mute Microphone", !Menu.isOptionChecked("Mute Microphone")); Audio.muted = !Audio.muted; - onMuteToggled(); } function onMuteToggled() { From 686af4ff777e1fa04a226105b2a6078d0877963e Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Fri, 23 Mar 2018 20:02:51 -0300 Subject: [PATCH 3/4] Clean code that manually checked for windows coordinates to disable radar touch --- .../qml/+android/AddressBarDialog.qml | 4 ++ .../qml/hifi/+android/avatarSelection.qml | 4 ++ scripts/+android/defaultScripts.js | 5 +-- scripts/system/+android/androidCombined.js | 24 ----------- scripts/system/+android/bottombar.js | 38 +---------------- scripts/system/+android/modes.js | 42 ------------------- scripts/system/+android/radar.js | 6 ++- 7 files changed, 16 insertions(+), 107 deletions(-) delete mode 100644 scripts/system/+android/androidCombined.js diff --git a/interface/resources/qml/+android/AddressBarDialog.qml b/interface/resources/qml/+android/AddressBarDialog.qml index b8d6b5e270..4477d512fc 100644 --- a/interface/resources/qml/+android/AddressBarDialog.qml +++ b/interface/resources/qml/+android/AddressBarDialog.qml @@ -67,6 +67,10 @@ Item { fill: parent } + MouseArea { + anchors.fill: parent + } + QmlHifi.WindowHeader { id: header iconSource: "../../../icons/goto-i.svg" diff --git a/interface/resources/qml/hifi/+android/avatarSelection.qml b/interface/resources/qml/hifi/+android/avatarSelection.qml index 3090204308..afa5634575 100644 --- a/interface/resources/qml/hifi/+android/avatarSelection.qml +++ b/interface/resources/qml/hifi/+android/avatarSelection.qml @@ -58,6 +58,10 @@ Item { width: parent ? parent.width : 0 height: parent ? parent.height : 0 + MouseArea { + anchors.fill: parent + } + gradient: Gradient { GradientStop { position: 0.0; color: android.color.gradientTop } GradientStop { position: 1.0; color: android.color.gradientBottom } diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index 82e32a6d00..9094952e62 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -14,10 +14,9 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", - "system/+android/audio.js", - "system/+android/androidCombined.js"/*, "system/+android/bottombar.js", - "system/+android/modes.js", + "system/+android/audio.js", + "system/+android/modes.js"/*, "system/away.js", "system/controllers/controllerDisplayManager.js", "system/controllers/handControllerGrabAndroid.js", diff --git a/scripts/system/+android/androidCombined.js b/scripts/system/+android/androidCombined.js deleted file mode 100644 index 76a52bcab7..0000000000 --- a/scripts/system/+android/androidCombined.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -// -// androidCombined.js -// scripts/system/ -// -// Created by Gabriel Calero & Cristian Duarte on Mar 20, 2018 -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -(function() { // BEGIN LOCAL_SCOPE - -var modesInterface = Script.require('./modes.js'); -var bottombarInterface = Script.require('./bottombar.js'); - -function init() { - modesInterface.isRadarModeValidTouch = bottombarInterface.isRadarModeValidTouch;// set new function -} - -init(); - -}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/system/+android/bottombar.js b/scripts/system/+android/bottombar.js index 2fb332a33d..3435edb548 100644 --- a/scripts/system/+android/bottombar.js +++ b/scripts/system/+android/bottombar.js @@ -21,9 +21,7 @@ var loginBtn; var gotoScript = Script.require('./goto.js'); var avatarSelection = Script.require('./avatarSelection.js'); -var bottombarInterface = []; - -var logEnabled = true; +var logEnabled = false; function printd(str) { if (logEnabled) { @@ -264,40 +262,6 @@ Script.scriptEnding.connect(function () { GlobalServices.disconnected.disconnect(handleLogout); }); -function isRadarModeValidTouch(coords) { - var qmlFragments = [bottombar, bottomHudOptionsBar.qmlFragment]; - var windows = [gotoScript, avatarSelection]; - for (var i=0; i < qmlFragments.length; i++) { - var aQmlFrag = qmlFragments[i]; - if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && - coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y - ) { - printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); - return false; - } - } - - for (var i=0; i < windows.length; i++) { - var aWin = windows[i]; - if (aWin != null && aWin.position() != null && aWin.isVisible() && - coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && - coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() - ) { - printd("isRadarModeValidTouch- false because of windows!? idx " + i); - return false; - } else { - printd("isRadarModeValidTouch- discarded of window idx " + i + " visible= " + aWin.isVisible()); - } - } - printd("isRadarModeValidTouch- true by default "); - return true; -} - -bottombarInterface.isRadarModeValidTouch = isRadarModeValidTouch; - -module.exports = bottombarInterface; - init(); }()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js index 4bc4333a09..c41ae1f327 100644 --- a/scripts/system/+android/modes.js +++ b/scripts/system/+android/modes.js @@ -23,8 +23,6 @@ var logEnabled = true; var radar = Script.require('./radar.js'); var uniqueColor = Script.require('./uniqueColor.js'); -var modesInterface = {}; - function printd(str) { if (logEnabled) { print("[modes.js] " + str); @@ -35,7 +33,6 @@ function init() { radar.setUniqueColor(uniqueColor); radar.init(); setupModesBar(); - radar.isTouchValid = isRadarModeValidTouch; } function shutdown() { @@ -185,45 +182,6 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) { } } -function isRadarModeValidTouch(coords) { - if (!modesInterface.isRadarModeValidTouch(coords)) { - printd("isRadarModeValidTouch- false because of modesInterface"); - return false; - } - printd("isRadarModeValidTouch- modesInterface is true, evaluating modesbar qmls.."); - - var qmlFragments = [modesbar.qmlFragment]; - var windows = []; - for (var i=0; i < qmlFragments.length; i++) { - var aQmlFrag = qmlFragments[i]; - if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && - coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y - ) { - printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); - return false; - } - } - - for (var i=0; i < windows.length; i++) { - var aWin = windows[i]; - if (aWin != null && aWin.position() != null && aWin.isVisible() && - coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && - coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() - ) { - printd("isRadarModeValidTouch- false because of windows!? idx " + i); - return false; - } - } - printd("isRadarModeValidTouch- true by default "); - return true; -} - -// default -modesInterface.isRadarModeValidTouch = function(coords) {return true;}; - -module.exports = modesInterface; - Script.scriptEnding.connect(function () { shutdown(); }); diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 84fb66403f..2bcdc60db7 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -13,7 +13,7 @@ var radarModeInterface = {}; -var logEnabled = true; +var logEnabled = false; function printd(str) { if (logEnabled) { print("[radar.js] " + str); @@ -1390,6 +1390,10 @@ radarModeInterface.setUniqueColor = function(c) { uniqueColor = c; }; +radarModeInterface.isTouchValid = function(coords) { + return true; // by default +} + module.exports = radarModeInterface; function updateRadar() { From fe9481b28d9b7c936e1fa23ea05153e52f617084 Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Wed, 28 Mar 2018 19:50:44 -0300 Subject: [PATCH 4/4] Cleanup code, comment out log, simplify radar is valid touch code (no more flag) --- libraries/qml/src/qml/OffscreenSurface.cpp | 11 ++--- scripts/system/+android/radar.js | 51 +--------------------- 2 files changed, 6 insertions(+), 56 deletions(-) diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index ff36589b61..9c1bb79355 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -167,31 +167,28 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) case QEvent::TouchEnd: { QTouchEvent *originalEvent = static_cast(event); QEvent::Type fakeMouseEventType = QEvent::None; - Qt::MouseButton fakeMouseButton = Qt::NoButton; + Qt::MouseButton fakeMouseButton = Qt::LeftButton; Qt::MouseButtons fakeMouseButtons = Qt::NoButton; switch (event->type()) { case QEvent::TouchBegin: fakeMouseEventType = QEvent::MouseButtonPress; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::LeftButton; break; case QEvent::TouchUpdate: fakeMouseEventType = QEvent::MouseMove; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::LeftButton; break; case QEvent::TouchEnd: fakeMouseEventType = QEvent::MouseButtonRelease; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::NoButton; 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); fakeMouseEvent.ignore(); if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) { - qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() - << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted(); + /*qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() + << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();*/ return fakeMouseEvent.isAccepted(); } break; diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 2bcdc60db7..455299dd5f 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -118,19 +118,10 @@ function actionOnObjectFromEvent(event) { } function mousePress(event) { - if (!isTouchValid(coords)) { - currentTouchIsValid = false; - return; - } else { - currentTouchIsValid = true; - } mousePressOrTouchEnd(event); } function mousePressOrTouchEnd(event) { - if (!currentTouchIsValid) { - return; - } if (radar) { if (actionOnObjectFromEvent(event)) { return; @@ -155,9 +146,6 @@ function fakeDoubleTap(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 fakeDoubleTapStart = Date.now(); var touchEndCount = 0; @@ -238,12 +226,6 @@ function touchEnd(event) { return; } - // if touch is invalid, cancel - if (!currentTouchIsValid) { - printd("touchEnd fail because !currentTouchIsValid"); - return; - } - if (analyzeDoubleTap(event)) return; // double tap detected, finish @@ -345,20 +327,6 @@ function computePointAtPlaneY(x, y, 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, y : event.y }; - if (!isTouchValid(coords)) { - printd("analyze touch - RADAR_TOUCH - INVALID"); - currentTouchIsValid = false; - touchStartingCoordinates = null; - } else { - printd("analyze touch - RADAR_TOUCH - ok"); - currentTouchIsValid = true; - touchStartingCoordinates = coords; - touchBeginTime = Date.now(); - } + touchStartingCoordinates = coords; + touchBeginTime = Date.now(); } var startedDraggingCamera = false; // first time @@ -848,9 +808,6 @@ function oneFingerTouchUpdate(event) { } function touchUpdate(event) { - if (!currentTouchIsValid) { - return; // avoid moving and zooming when tap is over UI entities - } if (event.isPinching || event.isPinchOpening) { pinchUpdate(event); } else { @@ -1390,10 +1347,6 @@ radarModeInterface.setUniqueColor = function(c) { uniqueColor = c; }; -radarModeInterface.isTouchValid = function(coords) { - return true; // by default -} - module.exports = radarModeInterface; function updateRadar() {