protected override void AddGestureEventToCurrentList(GestureState state) { var deltaTrans = currPosition - lastPosition; CurrentGestureEvents.Add(new GestureEventDrag(state, ConfigDrag.RequiredNumberOfFingers, ElapsedSinceLast, ElapsedSinceBeginning, ConfigDrag.DragShape, NormalizeVector(startPosition), NormalizeVector(currPosition), NormalizeVector(deltaTrans))); lastPosition = currPosition; base.AddGestureEventToCurrentList(state); }
protected override void ProcessPointerEventsImpl(TimeSpan deltaTime, List <PointerEvent> events) { AnalysePointerEvents(events); if (HasGestureStarted && ElapsedSinceBeginning >= ConfigLongPress.RequiredPressTime) { var avgPosition = ComputeMeanPosition(FingerIdToBeginPositions.Values); CurrentGestureEvents.Add(new GestureEventLongPress(ConfigLongPress.RequiredNumberOfFingers, ElapsedSinceBeginning, NormalizeVector(avgPosition))); HasGestureStarted = false; } }
protected override void AddGestureEventToCurrentList(GestureState state) { var deltaRotation = currentRotation - lastRotation; var deltaScale = currentScale - lastScale; CurrentGestureEvents.Add(new GestureEventComposite(state, ElapsedSinceLast, ElapsedSinceBeginning, deltaRotation, currentRotation, deltaScale, currentScale, NormalizeVector(beginCenter), NormalizeVector(lastCenter), NormalizeVector(currentCenter))); lastRotation = currentRotation; lastScale = currentScale; lastCenter = currentCenter; base.AddGestureEventToCurrentList(state); }
private void EndCurrentTap() { // add the gesture to the tap event list if the number of tap requirement is fulfilled if (currentNumberOfTaps == ConfigTap.RequiredNumberOfTaps) { var tapMeanPosition = ComputeMeanPosition(FingerIdToBeginPositions.Values); CurrentGestureEvents.Add(new GestureEventTap(ElapsedSinceBeginning, ConfigTap.RequiredNumberOfFingers, currentNumberOfTaps, NormalizeVector(tapMeanPosition))); } currentNumberOfTaps = 0; HasGestureStarted = false; FingerIdToBeginPositions.Clear(); }
protected override void ProcessMoveEventPointers(Dictionary <int, Vector2> fingerIdsToMovePos) { if (!HasGestureStarted) { return; } foreach (var id in fingerIdsToMovePos.Keys) { var newPos = fingerIdsToMovePos[id]; // check that the shape of the flick is respected, stop the gesture if it is not the case if (ConfigFlick.FlickShape != GestureShape.Free) { var compIndex = ConfigFlick.FlickShape == GestureShape.Horizontal ? 1 : 0; if (Math.Abs(newPos[compIndex] - FingerIdToBeginPositions[id][compIndex]) > ConfigFlick.AllowedErrorMargins[compIndex]) { HasGestureStarted = false; } } // Update the last position of the finger FingerIdsToLastPos[id] = newPos; } if (HasGestureStarted) { // trigger the event if the conditions are fulfilled var startPos = ComputeMeanPosition(FingerIdToBeginPositions.Values); var currPos = ComputeMeanPosition(FingerIdsToLastPos.Values); var translDist = (currPos - startPos).Length(); if (translDist > ConfigFlick.MinimumFlickLength && translDist / ElapsedSinceBeginning.TotalSeconds > ConfigFlick.MinimumAverageSpeed) { var evt = CurrentGestureEvents.Add() as GestureEventFlick; evt.Set(ConfigFlick.RequiredNumberOfFingers, ElapsedSinceBeginning, ConfigFlick.FlickShape, NormalizeVector(startPos), NormalizeVector(currPos)); HasGestureStarted = false; } } }