mirror of
https://github.com/overte-org/overte.git
synced 2025-07-25 11:52:06 +02:00
adjust the timer for touch event to work around the missing touch begin / touch end
This commit is contained in:
parent
ae14396fd7
commit
116e29ae57
2 changed files with 13 additions and 2 deletions
|
@ -73,16 +73,25 @@ void KeyboardMouseDevice::touchBeginEvent(const QTouchEvent* event) {
|
|||
_isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
|
||||
|
||||
_lastTouch = evalAverageTouchPoints(event->touchPoints());
|
||||
_lastTouchTime = _clock.now();
|
||||
}
|
||||
void KeyboardMouseDevice::touchEndEvent(const QTouchEvent* event) {
|
||||
_isTouching = false;
|
||||
_lastTouch = evalAverageTouchPoints(event->touchPoints());
|
||||
_lastTouchTime = _clock.now();
|
||||
}
|
||||
void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) {
|
||||
auto currentPos = evalAverageTouchPoints(event->touchPoints());
|
||||
|
||||
auto currentTime = _clock.now();
|
||||
auto sinceLastTouch = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - _lastTouchTime);
|
||||
if (sinceLastTouch.count() > 50) {
|
||||
_isTouching = false;
|
||||
}
|
||||
|
||||
if (!_isTouching) {
|
||||
_isTouching = event->touchPointStates().testFlag(Qt::TouchPointPressed);
|
||||
_lastTouchTime = _clock.now();
|
||||
} else {
|
||||
auto currentMove = currentPos - _lastTouch;
|
||||
|
||||
|
@ -131,7 +140,7 @@ void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {
|
|||
void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
|
||||
const float BUTTON_MOVE_SPEED = 1.0f;
|
||||
const float BUTTON_ROTATION_SPEED = 30.0f;
|
||||
const float MOUSE_ROTATION_SPEED = 1.0f;
|
||||
const float MOUSE_ROTATION_SPEED = 0.5f;
|
||||
const float BUTTON_BOOM_SPEED = 0.1f;
|
||||
|
||||
// AWSD keys mapping
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <unordered_set>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class UserInputMapper : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -258,6 +258,8 @@ public:
|
|||
}
|
||||
|
||||
glm::vec2 evalAverageTouchPoints(const QList<QTouchEvent::TouchPoint>& points) const;
|
||||
std::chrono::high_resolution_clock _clock;
|
||||
std::chrono::high_resolution_clock::time_point _lastTouchTime;
|
||||
};
|
||||
|
||||
#endif // hifi_UserInputMapper_h
|
Loading…
Reference in a new issue