v3.0.0: added proper support for touches cancelled by system gestures
This commit is contained in:
@@ -133,11 +133,13 @@ public class InputHandler extends InputAdapter {
|
||||
|
||||
@Override
|
||||
public boolean touchCancelled(int screenX, int screenY, int pointer, int button) {
|
||||
//currently emulating functionality from libGDX 1.11.0, do we keep this?
|
||||
//in particular this is probably a more graceful way to handle things like system swipes on iOS
|
||||
//whereas previously they generated garbage inputs sometimes
|
||||
//which were then fixed in v2.2.2
|
||||
return touchUp(screenX, screenY, pointer, button);
|
||||
|
||||
if (button >= 3 && KeyBindings.isKeyBound( button + 1000 )) {
|
||||
KeyEvent.addKeyEvent( new KeyEvent( button + 1000, false ) );
|
||||
} else if (button < 3) {
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.CANCEL, button));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ public class PointerEvent {
|
||||
public enum Type {
|
||||
DOWN,
|
||||
UP,
|
||||
CANCEL,
|
||||
HOVER
|
||||
}
|
||||
|
||||
@@ -82,6 +83,11 @@ public class PointerEvent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PointerEvent cancel() {
|
||||
if (type == Type.DOWN) type = Type.CANCEL;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PointerEvent handle(){
|
||||
handled = true;
|
||||
return this;
|
||||
@@ -162,9 +168,12 @@ public class PointerEvent {
|
||||
pointerSignal.dispatch( null );
|
||||
} else if (p.type == Type.DOWN) {
|
||||
pointerSignal.dispatch( existing );
|
||||
} else {
|
||||
} else if (p.type == Type.UP){
|
||||
activePointers.remove(existing.id);
|
||||
pointerSignal.dispatch(existing.up());
|
||||
} else if (p.type == Type.CANCEL){
|
||||
activePointers.remove(existing.id);
|
||||
pointerSignal.dispatch(existing.cancel());
|
||||
}
|
||||
} else {
|
||||
if (p.type == Type.DOWN) {
|
||||
@@ -185,12 +194,4 @@ public class PointerEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void clearPointerEvents(){
|
||||
pointerEvents.clear();
|
||||
for (PointerEvent p : activePointers.values()){
|
||||
p.current = p.start = new PointF(-1, -1);
|
||||
pointerSignal.dispatch(p.up());
|
||||
}
|
||||
activePointers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user