mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 12:17:31 +02:00
Merge pull request #4689 from Atlante45/master
Send generated touchEndEvent if we don't get one from Qt
This commit is contained in:
commit
b387c3e93a
2 changed files with 27 additions and 8 deletions
|
@ -31,7 +31,9 @@ var yawFromTouch = 0;
|
|||
var pitchFromTouch = 0;
|
||||
|
||||
// Touch Data
|
||||
var TIME_BEFORE_GENERATED_END_TOUCH_EVENT = 50; // ms
|
||||
var startedTouching = false;
|
||||
var lastTouchEvent = 0;
|
||||
var lastMouseX = 0;
|
||||
var lastMouseY = 0;
|
||||
var yawFromMouse = 0;
|
||||
|
@ -80,11 +82,17 @@ function touchBeginEvent(event) {
|
|||
yawFromTouch = 0;
|
||||
pitchFromTouch = 0;
|
||||
startedTouching = true;
|
||||
var d = new Date();
|
||||
lastTouchEvent = d.getTime();
|
||||
}
|
||||
|
||||
function touchEndEvent(event) {
|
||||
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;
|
||||
}
|
||||
|
@ -96,16 +104,17 @@ function touchUpdateEvent(event) {
|
|||
}
|
||||
|
||||
if (!startedTouching) {
|
||||
// handle Qt 5.4.x bug where we get touch update without a touch begin event
|
||||
startedTouching = true;
|
||||
lastTouchX = event.x;
|
||||
lastTouchY = event.y;
|
||||
// handle Qt 5.4.x bug where we get touch update without a touch begin event
|
||||
touchBeginEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
yawFromTouch += ((event.x - lastTouchX) * TOUCH_YAW_SCALE * FIXED_TOUCH_TIMESTEP);
|
||||
pitchFromTouch += ((event.y - lastTouchY) * TOUCH_PITCH_SCALE * FIXED_TOUCH_TIMESTEP);
|
||||
lastTouchX = event.x;
|
||||
lastTouchY = event.y;
|
||||
var d = new Date();
|
||||
lastTouchEvent = d.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,6 +122,14 @@ function update(deltaTime) {
|
|||
if (wantDebugging) {
|
||||
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) {
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromTouch + yawFromMouse, 0));
|
||||
|
|
|
@ -1492,9 +1492,11 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
|||
}
|
||||
|
||||
void Application::touchUpdateEvent(QTouchEvent* event) {
|
||||
TouchEvent thisEvent(*event, _lastTouchEvent);
|
||||
_controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
|
||||
_lastTouchEvent = thisEvent;
|
||||
if (event->type() == QEvent::TouchUpdate) {
|
||||
TouchEvent thisEvent(*event, _lastTouchEvent);
|
||||
_controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
|
||||
_lastTouchEvent = thisEvent;
|
||||
}
|
||||
|
||||
// if one of our scripts have asked to capture this event, then stop processing it
|
||||
if (_controllerScriptingInterface.isTouchCaptured()) {
|
||||
|
|
Loading…
Reference in a new issue