private void OnPressedSecond(PointerInput input, double time) { _pinching = true; _secondPressed = true; _pinchPosStartFirst = _posLastFirst; _pinchPosStartSecond = input.Position; _posLastSecond = _pinchPosStartSecond; _pinchStartDistance = Vector2.Distance(_pinchPosStartFirst, _pinchPosStartSecond); _pinchLastDistance = _pinchStartDistance; PinchStarted?.Invoke(new PinchInput() { InputId = input.InputId, PinchDeltaDistance = 0, PinchDistance = _pinchStartDistance, Pointer0CurrentPosition = _pinchPosStartFirst, Pointer0StartPosition = _pinchPosStartFirst, Pointer1CurrentPosition = _pinchPosStartSecond, Pointer1StartPosition = _pinchPosStartSecond }); }
private void OnDraggedFirst(PointerInput input, double time) { if (!activeGestures.TryGetValue(input.InputId, out var existingGesture)) { // Probably caught by UI, or the input was otherwise lost return; } existingGesture.SubmitPoint(input.Position, time); if (IsValidSwipe(ref existingGesture)) { PotentiallySwiped?.Invoke(new SwipeInput(existingGesture)); } _posLastFirst = input.Position; if (_pinching) { OnPinch(input); } DebugInfo(existingGesture); }
private void OnPressedFirst(PointerInput input, double time) { Debug.Assert(!activeGestures.ContainsKey(input.InputId)); var newGesture = new ActiveGesture(input.InputId, input.Position, time); activeGestures.Add(input.InputId, newGesture); DebugInfo(newGesture); _posLastFirst = input.Position; if (_secondPressed) { _pinching = true; _pinchPosStartFirst = _posLastFirst; _pinchPosStartSecond = _posLastSecond; _pinchStartDistance = Vector2.Distance(_pinchPosStartFirst, _pinchPosStartSecond); _pinchLastDistance = _pinchStartDistance; PinchStarted?.Invoke(new PinchInput() { InputId = input.InputId, PinchDeltaDistance = 0, PinchDistance = _pinchStartDistance, Pointer0CurrentPosition = _pinchPosStartFirst, Pointer0StartPosition = _pinchPosStartFirst, Pointer1CurrentPosition = _pinchPosStartSecond, Pointer1StartPosition = _pinchPosStartSecond }); } PressedFirst?.Invoke(new SwipeInput(newGesture)); }