if (e.getType().equals("touchstart")) {
this.justTouched = true;
JsArray<Touch> touches = e.getChangedTouches();
for (int i = 0, j = touches.length(); i < j; i++) {
Touch touch = touches.get(i);
int touchId = touch.getIdentifier();
touched[touchId] = true;
touchX[touchId] = touch.getRelativeX(canvas);
touchY[touchId] = touch.getRelativeY(canvas);
deltaX[touchId] = 0;
deltaY[touchId] = 0;
if (processor != null) {
processor.touchDown(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
}
}
this.currentEventTimeStamp = TimeUtils.nanoTime();
e.preventDefault();
}
if (e.getType().equals("touchmove")) {
JsArray<Touch> touches = e.getChangedTouches();
for (int i = 0, j = touches.length(); i < j; i++) {
Touch touch = touches.get(i);
int touchId = touch.getIdentifier();
deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];
touchX[touchId] = touch.getRelativeX(canvas);
touchY[touchId] = touch.getRelativeY(canvas);
if (processor != null) {
processor.touchDragged(touchX[touchId], touchY[touchId], touchId);
}
}
this.currentEventTimeStamp = TimeUtils.nanoTime();
e.preventDefault();
}
if (e.getType().equals("touchcancel")) {
JsArray<Touch> touches = e.getChangedTouches();
for (int i = 0, j = touches.length(); i < j; i++) {
Touch touch = touches.get(i);
int touchId = touch.getIdentifier();
touched[touchId] = false;
deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];
touchX[touchId] = touch.getRelativeX(canvas);
touchY[touchId] = touch.getRelativeY(canvas);
if (processor != null) {
processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
}
}
this.currentEventTimeStamp = TimeUtils.nanoTime();
e.preventDefault();
}
if (e.getType().equals("touchend")) {
JsArray<Touch> touches = e.getChangedTouches();
for (int i = 0, j = touches.length(); i < j; i++) {
Touch touch = touches.get(i);
int touchId = touch.getIdentifier();
touched[touchId] = false;
deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];
touchX[touchId] = touch.getRelativeX(canvas);
touchY[touchId] = touch.getRelativeY(canvas);
if (processor != null) {
processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
}
}
this.currentEventTimeStamp = TimeUtils.nanoTime();