Revert previous change

This commit is contained in:
drdev
2014-11-29 22:38:36 +00:00
parent d3d8fc8c78
commit 3c06c7ea81

View File

@@ -21,10 +21,10 @@ public abstract class FGestureAdapter extends InputAdapter {
public abstract boolean panStop(float x, float y);
public abstract boolean zoom(float x, float y, float amount);
private float tapSquareSize, longPressDelay, lastTapX, lastTapY, lastTwoFingerTapX, lastTwoFingerTapY, tapSquareCenterX, tapSquareCenterY;
private long tapCountInterval, flingDelay, lastTapTime, gestureStartTime, lastTwoFingerTapTime;
private int tapCount, lastTapButton, lastTapPointer, twoFingerTapCount, lastTwoFingerTapButton;
private boolean inTapSquare, pressed, longPressed, longPressHandled, pinching, panning, inTwoFingerTapSquare;
private float tapSquareSize, longPressDelay, lastTapX, lastTapY, tapSquareCenterX, tapSquareCenterY;
private long tapCountInterval, flingDelay, lastTapTime, gestureStartTime;
private int tapCount, lastTapButton, lastTapPointer;
private boolean inTapSquare, pressed, longPressed, longPressHandled, pinching, panning;
private final VelocityTracker tracker = new VelocityTracker();
private final Vector2 pointer1 = new Vector2();
@@ -83,10 +83,16 @@ public abstract class FGestureAdapter extends InputAdapter {
gestureStartTime = Gdx.input.getCurrentEventTime();
tracker.start(x, y, gestureStartTime);
if (Gdx.input.isTouched(1)) {
startPinch();
// Start pinch.
inTapSquare = false;
pinching = true;
prevPointer1.set(pointer1);
prevPointer2.set(pointer2);
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
endPress(x, y);
}
else {
// Normal touch down.
inTapSquare = true;
pinching = false;
tapSquareCenterX = x;
@@ -95,8 +101,13 @@ public abstract class FGestureAdapter extends InputAdapter {
}
}
else {
// Start pinch.
pointer2.set(x, y);
startPinch();
inTapSquare = false;
pinching = true;
prevPointer1.set(pointer1);
prevPointer2.set(pointer2);
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
endPress(pointer1.x, pointer1.y);
}
return true;
@@ -118,15 +129,8 @@ public abstract class FGestureAdapter extends InputAdapter {
pointer2.set(x, y);
}
// handle pinch zoom if not two finger tapping
// handle pinch zoom
if (pinching) {
if (inTwoFingerTapSquare) {
Vector2 p = pointer == 0 ? pointer1 : pointer2;
if (isWithinTapSquare(x, y, p.x, p.y)) {
return false;
}
inTwoFingerTapSquare = false;
}
return zoom(focalPoint.x, focalPoint.y, pointer1.dst(pointer2) - prevPointer1.dst(prevPointer2));
}
@@ -161,7 +165,7 @@ public abstract class FGestureAdapter extends InputAdapter {
return false;
}
// check if we are still tapping
// check if we are still tapping.
if (inTapSquare && !isWithinTapSquare(x, y, tapSquareCenterX, tapSquareCenterY)) {
inTapSquare = false;
}
@@ -195,34 +199,6 @@ public abstract class FGestureAdapter extends InputAdapter {
return false;
}
if (inTwoFingerTapSquare) {
Vector2 p = pointer == 0 ? pointer1 : pointer2;
if (isWithinTapSquare(x, y, p.x, p.y)) {
if (!pinching) { //don't raise two finger tap until both fingers up
x = focalPoint.x;
y = focalPoint.y;
long time = Gdx.input.getCurrentEventTime();
if (twoFingerTapCount == 2 //treat 3rd tap as a first tap, and 4th as a double tap
|| lastTwoFingerTapButton != button
|| time - lastTwoFingerTapTime > tapCountInterval
|| !isWithinTapSquare(x, y, lastTwoFingerTapX, lastTwoFingerTapY)) {
twoFingerTapCount = 0;
}
twoFingerTapCount++;
lastTwoFingerTapTime = time;
lastTwoFingerTapX = x;
lastTwoFingerTapY = y;
lastTwoFingerTapButton = button;
gestureStartTime = 0;
inTwoFingerTapSquare = false;
return twoFingerTap(x, y, twoFingerTapCount);
}
}
else {
inTwoFingerTapSquare = false;
}
}
if (pinching) {
// handle pinch end
pinching = false;
@@ -280,17 +256,6 @@ public abstract class FGestureAdapter extends InputAdapter {
return Math.abs(x - centerX) < tapSquareSize && Math.abs(y - centerY) < tapSquareSize;
}
private void startPinch() {
if (inTapSquare && pointer2.dst(pointer1) < Utils.AVG_FINGER_WIDTH * 3) {
inTwoFingerTapSquare = true;
}
inTapSquare = false;
pinching = true;
prevPointer1.set(pointer1);
prevPointer2.set(pointer2);
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
}
private static class VelocityTracker {
int sampleSize = 10;
float startX, startY;