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
7373 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
7474
7575 _lastTouch = evalAverageTouchPoints(event->touchPoints());
76+ _lastTouchTime = _clock.now();
7677 }
7778 void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) {
7879 _isTouching = false;
7980 _lastTouch = evalAverageTouchPoints(event->touchPoints());
81+ _lastTouchTime = _clock.now();
8082 }
8183 void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) {
8284 auto currentPos = evalAverageTouchPoints(event->touchPoints());
8385
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+
8492 if (!_isTouching) {
8593 _isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
94+ _lastTouchTime = _clock.now();
8695 } else {
8796 auto currentMove = currentPos - _lastTouch;
8897
@@ -131,7 +140,7 @@ void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) { · 42 unmodified lines
131140 void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
132141 const float BUTTON_MOVE_SPEED = 1.0f;
133142 const float BUTTON_ROTATION_SPEED = 30.0f;
134− const float MOUSE_ROTATION_SPEED = 1.0f;
143+ const float MOUSE_ROTATION_SPEED = 0.5f;
135144 const float BUTTON_BOOM_SPEED = 0.1f;
136145
137146 // AWSD keys mapping