diff --git a/interface/resources/controllers/touchscreen.json b/interface/resources/controllers/touchscreen.json index 1b4e9723ce..21362ce8fb 100644 --- a/interface/resources/controllers/touchscreen.json +++ b/interface/resources/controllers/touchscreen.json @@ -12,7 +12,7 @@ "to": "Actions.Yaw" }, - { "from": { "makeAxis" : [ + { "from": { "makeAxis" : [ [ "Touchscreen.DragUp" ], [ "Touchscreen.DragDown" ] ] diff --git a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp index 6edaddb24a..56894efc4c 100755 --- a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp +++ b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp @@ -19,7 +19,7 @@ #include const QString KeyboardMouseDevice::NAME = "Keyboard/Mouse"; -bool KeyboardMouseDevice::_enableTouchpad = true; +bool KeyboardMouseDevice::_enableTouch = true; void KeyboardMouseDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { auto userInputMapper = DependencyManager::get(); @@ -133,7 +133,7 @@ glm::vec2 evalAverageTouchPoints(const QList& points) { } void KeyboardMouseDevice::touchBeginEvent(const QTouchEvent* event) { - if (_enableTouchpad) { + if (_enableTouch) { _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed); _lastTouch = evalAverageTouchPoints(event->touchPoints()); _lastTouchTime = _clock.now(); @@ -141,7 +141,7 @@ void KeyboardMouseDevice::touchBeginEvent(const QTouchEvent* event) { } void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) { - if (_enableTouchpad) { + if (_enableTouch) { _isTouching = false; _lastTouch = evalAverageTouchPoints(event->touchPoints()); _lastTouchTime = _clock.now(); @@ -149,14 +149,13 @@ void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) { } void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) { - if (_enableTouchpad) { + if (_enableTouch) { auto currentPos = evalAverageTouchPoints(event->touchPoints()); _lastTouchTime = _clock.now(); if (!_isTouching) { _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed); - } - else { + } else { auto currentMove = currentPos - _lastTouch; _inputDevice->_axisStateMap[_inputDevice->makeInput(TOUCH_AXIS_X_POS).getChannel()] = (currentMove.x > 0 ? currentMove.x : 0.0f); diff --git a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.h b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.h index d88c410ade..2fdecf0bba 100644 --- a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.h +++ b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.h @@ -85,7 +85,7 @@ public: void wheelEvent(QWheelEvent* event); - static void enableTouchpad(bool enableTouchpad) { _enableTouchpad = enableTouchpad; } + static void enableTouch(bool enableTouch) { _enableTouch = enableTouch; } static const QString NAME; @@ -125,7 +125,7 @@ protected: std::chrono::high_resolution_clock _clock; std::chrono::high_resolution_clock::time_point _lastTouchTime; - static bool _enableTouchpad; + static bool _enableTouch; }; #endif // hifi_KeyboardMouseDevice_h diff --git a/libraries/input-plugins/src/input-plugins/TouchscreenDevice.cpp b/libraries/input-plugins/src/input-plugins/TouchscreenDevice.cpp index 10bca75e0a..e9553c1785 100644 --- a/libraries/input-plugins/src/input-plugins/TouchscreenDevice.cpp +++ b/libraries/input-plugins/src/input-plugins/TouchscreenDevice.cpp @@ -56,12 +56,12 @@ void TouchscreenDevice::pluginUpdate(float deltaTime, const controller::InputCal _inputDevice->_axisStateMap[_inputDevice->makeInput(TOUCH_AXIS_Y_NEG).getChannel()] = distanceScaleY; } } else if (_touchPointCount == 2) { - if (_scaleFactor > _lastPinchScale && _scaleFactor != 0) { + if (_pinchScale > _lastPinchScale && _pinchScale != 0) { _inputDevice->_axisStateMap[_inputDevice->makeInput(TOUCH_GESTURE_PINCH_POS).getChannel()] = 1.0f; - } else if (_scaleFactor != 0) { + } else if (_pinchScale != 0) { _inputDevice->_axisStateMap[_inputDevice->makeInput(TOUCH_GESTURE_PINCH_NEG).getChannel()] = 1.0f; } - _lastPinchScale = _scaleFactor; + _lastPinchScale = _pinchScale; } } @@ -75,7 +75,7 @@ void TouchscreenDevice::InputDevice::focusOutEvent() { void TouchscreenDevice::touchBeginEvent(const QTouchEvent* event) { const QTouchEvent::TouchPoint& point = event->touchPoints().at(0); _firstTouchVec = glm::vec2(point.pos().x(), point.pos().y()); - KeyboardMouseDevice::enableTouchpad(false); + KeyboardMouseDevice::enableTouch(false); if (_screenDPI != event->window()->screen()->physicalDotsPerInch()) { // at DPI 100 use these arbitrary values to divide dragging distance // the value is clamped from 1 to 10 so up to 1000 DPI would be supported atm @@ -89,7 +89,7 @@ void TouchscreenDevice::touchBeginEvent(const QTouchEvent* event) { void TouchscreenDevice::touchEndEvent(const QTouchEvent* event) { _touchPointCount = 0; - KeyboardMouseDevice::enableTouchpad(true); + KeyboardMouseDevice::enableTouch(true); } void TouchscreenDevice::touchUpdateEvent(const QTouchEvent* event) { @@ -101,7 +101,7 @@ void TouchscreenDevice::touchUpdateEvent(const QTouchEvent* event) { void TouchscreenDevice::touchGestureEvent(const QGestureEvent* event) { if (QGesture* gesture = event->gesture(Qt::PinchGesture)) { QPinchGesture* pinch = static_cast(gesture); - _scaleFactor = pinch->totalScaleFactor(); + _pinchScale = pinch->totalScaleFactor(); } } diff --git a/libraries/input-plugins/src/input-plugins/TouchscreenDevice.h b/libraries/input-plugins/src/input-plugins/TouchscreenDevice.h index b354b7e9ec..f89f247ce8 100644 --- a/libraries/input-plugins/src/input-plugins/TouchscreenDevice.h +++ b/libraries/input-plugins/src/input-plugins/TouchscreenDevice.h @@ -72,7 +72,7 @@ public: protected: qreal _lastPinchScale; - qreal _scaleFactor; + qreal _pinchScale; qreal _screenDPI; glm::vec2 _screenDPIScale; glm::vec2 _firstTouchVec;