coding standard fix and renaming

This commit is contained in:
Triplelexx 2016-06-28 17:57:38 +01:00
parent cc6dca853c
commit efdee523fb
5 changed files with 15 additions and 16 deletions

View file

@ -12,7 +12,7 @@
"to": "Actions.Yaw"
},
{ "from": { "makeAxis" : [
{ "from": { "makeAxis" : [
[ "Touchscreen.DragUp" ],
[ "Touchscreen.DragDown" ]
]

View file

@ -19,7 +19,7 @@
#include <NumericalConstants.h>
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<controller::UserInputMapper>();
@ -133,7 +133,7 @@ glm::vec2 evalAverageTouchPoints(const QList<QTouchEvent::TouchPoint>& 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);

View file

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

View file

@ -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<QPinchGesture*>(gesture);
_scaleFactor = pinch->totalScaleFactor();
_pinchScale = pinch->totalScaleFactor();
}
}

View file

@ -72,7 +72,7 @@ public:
protected:
qreal _lastPinchScale;
qreal _scaleFactor;
qreal _pinchScale;
qreal _screenDPI;
glm::vec2 _screenDPIScale;
glm::vec2 _firstTouchVec;