public static HandSwipe IsHandSwipe(Leap.Frame frame) { if (frame.IsValid) { Leap.HandList hands = frame.Hands; if ((hands[0].IsValid && hands[1].IsValid) && handsTogether(hands[0], hands[1])) { return(null); } if (Math.Abs(hands.Frontmost.PalmVelocity.x) > 900) { HandSwipe handSwipe = new HandSwipe(CustomGestureType.HAND_SWIPE, frame); return(handSwipe); } else if ((other != null)) { if (other.State.Equals(GestureState.END) || other.State.Equals(GestureState.NA)) { other._state = GestureState.NA; return(other); } else { other._state = GestureState.END; return(other); } } } return(null); }
public HandSwipe(CustomGestureType type, Leap.Frame frame) : base(type, frame) { if (other != null) { if (other.State.Equals(GestureState.NA)) { _state = GestureState.START; } else if (other.State.Equals(GestureState.END)) { _state = GestureState.NA; } else { _state = GestureState.MIDDLE; } } other = this; foreach (Leap.Hand hand in _handsForGesture) { if (hand.PalmVelocity.x > 0) { _diretion = SwipeDirection.RIGHT; } else { _diretion = SwipeDirection.LEFT; } } }
public override void OnFrame(Leap.Controller controller) { Leap.Frame frame = controller.Frame(); Leap.InteractionBox interactionBox = frame.InteractionBox; _pointerPosition = interactionBox.NormalizePoint(frame.Pointables.Frontmost.TipPosition); _standardGestures = frame.Gestures(); foreach (Leap.Gesture gesture in _standardGestures) { if (gesture.State.Equals(Leap.Gesture.GestureState.STATESTOP)) { if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPESWIPE)) { Print("Finger Swipe Detected"); Leap.SwipeGesture swipe = new Leap.SwipeGesture(gesture); Events.FingerSwipeEvent swipeEvent = new Events.FingerSwipeEvent(swipe); OnFingerSwipeDetected(swipeEvent); } if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPE_CIRCLE)) { Print("Circle Gesture Detected"); Leap.CircleGesture circle = new Leap.CircleGesture(gesture); Events.CircleEvent circleEvent = new Events.CircleEvent(circle); OnCircleDetected(circleEvent); } if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPE_SCREEN_TAP)) { Print("Screen Tap Detected"); Leap.ScreenTapGesture screenTap = new Leap.ScreenTapGesture(gesture); Events.ScreenTapEvent screenTapEvent = new Events.ScreenTapEvent(screenTap); OnScreenTapDetected(screenTapEvent); } } } Gestures.HandSwipe handSwipe = Gestures.HandSwipe.IsHandSwipe(frame); if (handSwipe != null) { if (handSwipe.State.Equals(Gestures.GestureState.END)) { Print("Hand Swipe Detected"); Events.HandSwipeEvent swipeEvent = new Events.HandSwipeEvent(handSwipe); OnHandSwipeDetected(swipeEvent); } } Gestures.ZoomIn zoomIn = Gestures.ZoomIn.IsZoomIn(frame); if (zoomIn != null) { if (zoomIn.State.Equals(Gestures.GestureState.END)) { Print("ZoomIn Detected"); Events.ZoomInEvent zoomInEvent = new Events.ZoomInEvent(zoomIn); OnZoomInDetected(zoomInEvent); } } Gestures.ZoomOut zoomOut = Gestures.ZoomOut.IsZoomOut(frame); if (zoomOut != null) { if (zoomOut.State.Equals(Gestures.GestureState.END)) { Print("ZoomOut Detected"); Events.ZoomOutEvent zoomOutEvent = new Events.ZoomOutEvent(zoomOut); OnZoomOutDetected(zoomOutEvent); } } }