mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
Generate touchEndEvent if last event was more than 50 ms ago
This commit is contained in:
parent
a3edb7b02a
commit
e2b60d35f0
1 changed files with 22 additions and 6 deletions
|
@ -31,7 +31,9 @@ var yawFromTouch = 0;
|
||||||
var pitchFromTouch = 0;
|
var pitchFromTouch = 0;
|
||||||
|
|
||||||
// Touch Data
|
// Touch Data
|
||||||
|
var TIME_BEFORE_GENERATED_END_TOUCH_EVENT = 50; // ms
|
||||||
var startedTouching = false;
|
var startedTouching = false;
|
||||||
|
var lastTouchEvent = 0;
|
||||||
var lastMouseX = 0;
|
var lastMouseX = 0;
|
||||||
var lastMouseY = 0;
|
var lastMouseY = 0;
|
||||||
var yawFromMouse = 0;
|
var yawFromMouse = 0;
|
||||||
|
@ -80,11 +82,17 @@ function touchBeginEvent(event) {
|
||||||
yawFromTouch = 0;
|
yawFromTouch = 0;
|
||||||
pitchFromTouch = 0;
|
pitchFromTouch = 0;
|
||||||
startedTouching = true;
|
startedTouching = true;
|
||||||
|
var d = new Date();
|
||||||
|
lastTouchEvent = d.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
function touchEndEvent(event) {
|
function touchEndEvent(event) {
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
|
if (event) {
|
||||||
|
print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
|
||||||
|
} else {
|
||||||
|
print("touchEndEvent generated");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
startedTouching = false;
|
startedTouching = false;
|
||||||
}
|
}
|
||||||
|
@ -96,23 +104,31 @@ function touchUpdateEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!startedTouching) {
|
if (!startedTouching) {
|
||||||
// handle Qt 5.4.x bug where we get touch update without a touch begin event
|
// handle Qt 5.4.x bug where we get touch update without a touch begin event
|
||||||
startedTouching = true;
|
touchBeginEvent(event);
|
||||||
lastTouchX = event.x;
|
return;
|
||||||
lastTouchY = event.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
yawFromTouch += ((event.x - lastTouchX) * TOUCH_YAW_SCALE * FIXED_TOUCH_TIMESTEP);
|
yawFromTouch += ((event.x - lastTouchX) * TOUCH_YAW_SCALE * FIXED_TOUCH_TIMESTEP);
|
||||||
pitchFromTouch += ((event.y - lastTouchY) * TOUCH_PITCH_SCALE * FIXED_TOUCH_TIMESTEP);
|
pitchFromTouch += ((event.y - lastTouchY) * TOUCH_PITCH_SCALE * FIXED_TOUCH_TIMESTEP);
|
||||||
lastTouchX = event.x;
|
lastTouchX = event.x;
|
||||||
lastTouchY = event.y;
|
lastTouchY = event.y;
|
||||||
}
|
var d = new Date();
|
||||||
|
lastTouchEvent = d.getTime();}
|
||||||
|
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print("update()...");
|
print("update()...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(startedTouching) {
|
||||||
|
var d = new Date();
|
||||||
|
var sinceLastTouch = d.getTime() - lastTouchEvent;
|
||||||
|
if (sinceLastTouch > TIME_BEFORE_GENERATED_END_TOUCH_EVENT) {
|
||||||
|
touchEndEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (yawFromTouch != 0 || yawFromMouse != 0) {
|
if (yawFromTouch != 0 || yawFromMouse != 0) {
|
||||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromTouch + yawFromMouse, 0));
|
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromTouch + yawFromMouse, 0));
|
||||||
|
|
Loading…
Reference in a new issue