From 5e3ad3fe9a3b05cb3e43a0f621c9f3d77d8510f8 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Tue, 20 Feb 2018 17:20:48 -0300 Subject: [PATCH] Disable VPAD on bottom bar tapping and modes bar tapping --- .../resources/qml/hifi/+android/bottombar.qml | 9 +++++++++ .../resources/qml/hifi/+android/button.qml | 4 ++++ .../resources/qml/hifi/+android/modesbar.qml | 6 ++++++ .../TouchscreenVirtualPadDevice.cpp | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/interface/resources/qml/hifi/+android/bottombar.qml b/interface/resources/qml/hifi/+android/bottombar.qml index 2a34b7fe19..e861d441d9 100644 --- a/interface/resources/qml/hifi/+android/bottombar.qml +++ b/interface/resources/qml/hifi/+android/bottombar.qml @@ -41,6 +41,15 @@ Item { Styles.HifiConstants { id: hifi } HifiConstants { id: android } + MouseArea { + anchors.fill: parent + onEntered: { + Controller.setVPadEnabled(false); + } + onExited: { + Controller.setVPadEnabled(true); + } + } Rectangle { id: background diff --git a/interface/resources/qml/hifi/+android/button.qml b/interface/resources/qml/hifi/+android/button.qml index ec7af2ab92..4822b6bf33 100644 --- a/interface/resources/qml/hifi/+android/button.qml +++ b/interface/resources/qml/hifi/+android/button.qml @@ -40,6 +40,8 @@ Item { property bool isActive: false signal clicked() + signal entered() + signal exited() onIsActiveChanged: { if (button.isEntered) { @@ -118,6 +120,7 @@ Item { } onEntered: { button.isEntered = true; + button.entered(); if (button.isActive) { button.state = "hover active state"; } else { @@ -126,6 +129,7 @@ Item { } onExited: { button.isEntered = false; + button.exited() if (button.isActive) { button.state = "active state"; } else { diff --git a/interface/resources/qml/hifi/+android/modesbar.qml b/interface/resources/qml/hifi/+android/modesbar.qml index fe71314ece..552ca80778 100644 --- a/interface/resources/qml/hifi/+android/modesbar.qml +++ b/interface/resources/qml/hifi/+android/modesbar.qml @@ -40,6 +40,12 @@ Item { var keys = Object.keys(properties).forEach(function (key) { button[key] = properties[key]; }); + button.entered.connect(function() { + Controller.setVPadEnabled(false); + }); + button.exited.connect(function() { + Controller.setVPadEnabled(true); + }); return button; } else if( component.status == Component.Error) { console.log("Load button errors " + component.errorString()); diff --git a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp index 8e1e6c2fba..53683870df 100644 --- a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp +++ b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp @@ -127,6 +127,10 @@ void TouchscreenVirtualPadDevice::debugPoints(const QTouchEvent* event, QString void TouchscreenVirtualPadDevice::touchBeginEvent(const QTouchEvent* event) { // touch begin here is a big begin -> begins both pads? maybe it does nothing debugPoints(event, " BEGIN ++++++++++++++++"); + auto& virtualPadManager = VirtualPad::Manager::instance(); + if (!virtualPadManager.isEnabled()) { + return; + } KeyboardMouseDevice::enableTouch(false); QScreen* eventScreen = event->window()->screen(); _screenWidthCenter = eventScreen->size().width() / 2; @@ -138,6 +142,10 @@ void TouchscreenVirtualPadDevice::touchBeginEvent(const QTouchEvent* event) { } void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) { + auto& virtualPadManager = VirtualPad::Manager::instance(); + if (!virtualPadManager.isEnabled()) { + return; + } // touch end here is a big reset -> resets both pads _touchPointCount = 0; KeyboardMouseDevice::enableTouch(true); @@ -148,6 +156,12 @@ void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) { } void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) { + auto& virtualPadManager = VirtualPad::Manager::instance(); + if (!virtualPadManager.isEnabled()) { + touchLeftEnd(); + touchRightEnd(); + return; + } _touchPointCount = event->touchPoints().count(); const QList& tPoints = event->touchPoints(); @@ -224,6 +238,10 @@ void TouchscreenVirtualPadDevice::touchRightEnd() { } void TouchscreenVirtualPadDevice::touchGestureEvent(const QGestureEvent* event) { + auto& virtualPadManager = VirtualPad::Manager::instance(); + if (!virtualPadManager.isEnabled()) { + return; + } if (QGesture* gesture = event->gesture(Qt::PinchGesture)) { QPinchGesture* pinch = static_cast(gesture); _pinchScale = pinch->totalScaleFactor();