Disable VPAD on bottom bar tapping and modes bar tapping

This commit is contained in:
Gabriel Calero 2018-02-20 17:20:48 -03:00
parent 4839a8c720
commit 5e3ad3fe9a
4 changed files with 37 additions and 0 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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());

View file

@ -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<QTouchEvent::TouchPoint>& 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<QPinchGesture*>(gesture);
_pinchScale = pinch->totalScaleFactor();