private void AddEventsForHand(List <IInputEvent> events, GestureSource hand,
                                      KinectPayload currentUserPayload, KinectPayload previousUserPayload)
        {
            KinectHandPayload handPayload         = currentUserPayload.HandPayloads.GetValue(hand);
            KinectHandPayload previousHandPayload = null;

            if (previousUserPayload != null)
            {
                previousHandPayload = previousUserPayload.HandPayloads.GetValue(hand);
            }

            if (handPayload != null)
            {
                events.Add(new MovementEvent(handPayload.Position,
                                             previousHandPayload == null
                                        ? handPayload.Position
                                        : previousHandPayload.Position - handPayload.Position));

                if (handPayload.PressExtent >= 1)
                {
                    events.Add(new GestureEvent(
                                   previousHandPayload == null ? GestureType.Activate :
                                   (previousHandPayload.PressExtent >= 1 ? GestureType.HoldActivate : GestureType.Activate),
                                   hand, handPayload.Position));
                }
            }
        }
        public void Update(Time time)
        {
            _kinectInputStream.Update(time);

            List <IInputEvent> events = new List <IInputEvent>();
            Dictionary <int, KinectPayload> payload = _kinectInputStream.GetState();

            foreach (var kinectPayload in payload)
            {
                KinectPayload currentUserPayload = kinectPayload.Value;

                KinectPayload previousUserPayload;
                _previousPayload.TryGetValue(kinectPayload.Key, out previousUserPayload);

                AddEventsForHand(events, GestureSource.Left, currentUserPayload, previousUserPayload);
                AddEventsForHand(events, GestureSource.Left, currentUserPayload, previousUserPayload);
            }

            _lastEvents      = events;
            _previousPayload = payload;
        }