History

adjust the timer for touch event to work around the missing touch begin / touch end

Sam Gateau committed 11 years ago

Commit 116e29a1 parent ae143962 files · +13 −2Browse files

Showing the changes to interface/src/ui/UserInputMapper.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/UserInputMapper.cpp+10−1
@@ -73,16 +73,25 @@ void KeyboardMouseDevice::touchBeginEvent(const QTouchEvent* event) { · 72 unmodified lines
73 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);73 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
74 74
75 _lastTouch = evalAverageTouchPoints(event->touchPoints());75 _lastTouch = evalAverageTouchPoints(event->touchPoints());
76 _lastTouchTime = _clock.now();
76}77}
77void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) {78void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) {
78 _isTouching = false;79 _isTouching = false;
79 _lastTouch = evalAverageTouchPoints(event->touchPoints());80 _lastTouch = evalAverageTouchPoints(event->touchPoints());
81 _lastTouchTime = _clock.now();
80}82}
81void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) {83void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) {
82 auto currentPos = evalAverageTouchPoints(event->touchPoints());84 auto currentPos = evalAverageTouchPoints(event->touchPoints());
83 85
86 auto currentTime = _clock.now();
87 auto sinceLastTouch = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - _lastTouchTime);
88 if (sinceLastTouch.count() > 50) {
89 _isTouching = false;
90 }
91
84 if (!_isTouching) {92 if (!_isTouching) {
85 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);93 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
94 _lastTouchTime = _clock.now();
86 } else {95 } else {
87 auto currentMove = currentPos - _lastTouch;96 auto currentMove = currentPos - _lastTouch;
88 97
@@ -131,7 +140,7 @@ void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) { · 42 unmodified lines
131void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {140void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
132 const float BUTTON_MOVE_SPEED = 1.0f;141 const float BUTTON_MOVE_SPEED = 1.0f;
133 const float BUTTON_ROTATION_SPEED = 30.0f;142 const float BUTTON_ROTATION_SPEED = 30.0f;
134 const float MOUSE_ROTATION_SPEED = 1.0f;143 const float MOUSE_ROTATION_SPEED = 0.5f;
135 const float BUTTON_BOOM_SPEED = 0.1f;144 const float BUTTON_BOOM_SPEED = 0.1f;
136 145
137 // AWSD keys mapping146 // AWSD keys mapping