Esempio n. 1
0
        protected virtual void OnDoubleTapState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            if (!info.touchQueue.IsActived())
            {
                info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                mCurrentGestureEvent = new GestureDoubleClickEvent(x, y, time, 1);
            }
            else
            {
                info.touchQueue.GetAbsMaxMovingDistance(ref x, ref y);
                if ((x > mMaxSteadyMoveDistanceX) || (y > mMaxSteadyMoveDistanceY))
                {
                    // point moved, change to swipe state
                    info.curState = TouchState.STATE_SWIPE;
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
                if (info.touchQueue.GetCurrentDuration(time) > mMinSteadyTimeForDrag)
                {
                    info.curState = TouchState.STATE_DRAG;
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
                mChangedTouchQueues.AddLast(info);
            }
        }
Esempio n. 2
0
        protected virtual void OnDragState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            if (!info.touchQueue.IsActived())
            {
                //release touch in drag state, triggered tap or long-tap event
                info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                if (info.touchQueue.GetCurrentDuration(time) >= mMinTimeForLongTap)
                {
                    mCurrentGestureEvent = new GestureLongTapEvent(x, y, time, 1, info.touchQueue.GetDuration());
                }
                else
                {
                    mCurrentGestureEvent = new GestureTapEvent(x, y, time, 1);
                }
            }
            else
            {
                info.touchQueue.GetAbsMaxMovingDistance(ref x, ref y);
                if ((x > mMaxSteadyMoveDistanceX) || (y > mMaxSteadyMoveDistanceY))
                {
                    // point moved, trigger drag event and change to drag-move state
                    info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                    mCurrentGestureEvent = new GestureDragEvent(x, y, time, 1);
                    info.curState        = TouchState.STATE_DRAG_MOVE;
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
                mChangedTouchQueues.AddLast(info);
            }
        }
Esempio n. 3
0
        protected virtual void OnSwipeState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            info.touchQueue.GetTrackStartingPosition(ref x, ref y);
            if (!info.touchQueue.IsActived() || (info.touchQueue.GetCurrentDuration(time) >= mMaxSwipeDuration))
            {
                TouchArcShape  arcType   = TouchArcShape.ARC_NONE;
                TouchDirection direction = TouchDirection.DIR_NONE;
                bool           isArc     = info.touchQueue.IsArcTrack(mMinXDistanceForArc, mMinYChangePersentForArc, ref arcType, ref direction);
                if (isArc)
                {
                    mCurrentGestureEvent = new GestureArcEvent(x, y, time, 1, arcType, direction);
                }
                else
                {
                    mCurrentGestureEvent = new GestureSwipeEvent(x, y, time, 1, direction);
                }

                //force deactive the touch queue when it expired
                if (info.touchQueue.IsActived())
                {
                    info.touchQueue.ForceReleaseTouch();
                }
            }
            else
            {
                mChangedTouchQueues.AddLast(info);
            }
        }
Esempio n. 4
0
        public bool TryAddTouchQueueChanging(TouchQueue queue, TouchQueueChangingMode changingMode, long time)
        {
            TouchQueueInfomation info = FindQueueInfomation(queue);

            if (info.IsEmpty())
            {
                if (changingMode == TouchQueueChangingMode.TQC_PRESS)
                {
                    TouchQueueInfomation tqcInfo = new TouchQueueInfomation(queue, changingMode, time);
                    mChangedTouchQueues.AddLast(tqcInfo);
                    return(true);
                }
                return(false);
            }
            else
            {
                if (changingMode == TouchQueueChangingMode.TQC_RELEASE)
                {
                    Debug.Assert((info.lastChangingMode == TouchQueueChangingMode.TQC_PRESS) || (info.lastChangingMode == TouchQueueChangingMode.TQC_MOVE));
                    info.releaseTime = time;
                    info.repeatTimes++;
                }
                bool changed = (info.lastChangingMode == changingMode);
                info.lastChangingMode = changingMode;

                return(changed);
            }
        }
Esempio n. 5
0
 protected void TryRemoveTouchQueueInfomation(TouchQueue queue)
 {
     for (int i = 0; i < mChangedTouchQueues.Count; i++)
     {
         TouchQueueInfomation info = mChangedTouchQueues.ElementAt(i);
         if (info.touchQueue == queue)
         {
             mChangedTouchQueues.Remove(info);
             queue.Clear();
             break;
         }
     }
 }
Esempio n. 6
0
        protected virtual void OnLongTapState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            info.touchQueue.GetTrackStartingPosition(ref x, ref y);
            if (!info.touchQueue.IsActived())
            {
                mCurrentGestureEvent = new GestureLongTapEvent(x, y, time, 1, info.touchQueue.GetDuration());
            }
            else
            {
                mChangedTouchQueues.AddLast(info);
            }
        }
Esempio n. 7
0
        protected virtual void OnDragMoveState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            info.touchQueue.GetTrackEndingPosition(ref x, ref y);
            if (!info.touchQueue.IsActived())
            {
                mCurrentGestureEvent = new GestureDropEvent(x, y, time, 1);
            }
            else
            {
                mCurrentGestureEvent = new GestureDragMoveEvent(x, y, time, 1);
                mChangedTouchQueues.AddLast(info);
            }
        }
Esempio n. 8
0
        public virtual void Update(long currentTime)
        {
            int count = mChangedTouchQueues.Count;

            if (GetActiveTouchQueueCount() > 1)
            {
                OnMultiTouch(currentTime);
            }
            else
            {
                if (_inMultiTouchMove)
                {
                    mCurrentGestureEvent = new GestureEndMoveEvent(_lastMultiTouchMoveX, _lastMultiTouchMoveY, currentTime, 2);
                    _lastMultiTouchMoveX = _lastMultiTouchMoveY = 0;
                    _inMultiTouchMove    = false;
                }
                int idx = 0;
                while (mChangedTouchQueues.Count > 0 && (idx < count))
                {
                    TouchQueueInfomation info = mChangedTouchQueues.First.Value;
                    mChangedTouchQueues.RemoveFirst();
                    idx++;
                    int x = 0;
                    int y = 0;
                    info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                    switch (info.curState)
                    {
                    case TouchState.STATE_TAP:
                        OnTapState(ref info, currentTime);
                        break;

                    case TouchState.STATE_SWIPE:
                        OnSwipeState(ref info, currentTime);
                        break;

                    case TouchState.STATE_MOVE:
                        OnMoveState(ref info, currentTime);
                        break;

                    case TouchState.STATE_LONG_TAP:
                        OnLongTapState(ref info, currentTime);
                        break;

                    case TouchState.STATE_DOUBLE_TAP:
                        OnDoubleTapState(ref info, currentTime);
                        break;

                    case TouchState.STATE_DRAG:
                        OnDragState(ref info, currentTime);
                        break;

                    case TouchState.STATE_DRAG_MOVE:
                        OnDragMoveState(ref info, currentTime);
                        break;

                    case TouchState.STATE_MULTI:
                        info.touchQueue.ForceReleaseTouch();
                        break;

                    case TouchState.STATE_NONE:
                        info.touchQueue.ForceReleaseTouch();
                        break;

                    default:
                        info.touchQueue.ForceReleaseTouch();
                        break;
                    }
                }
            }
        }
Esempio n. 9
0
        protected virtual void OnTapState(ref TouchQueueInfomation info, long time)
        {
            int x = 0;
            int y = 0;

            if (!info.touchQueue.IsActived())
            {
                // touch release
                if (info.repeatTimes <= 1)
                {
                    info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                    if (info.releaseTime + mMaxIntervalOfDoubleClick < time)
                    {
                        // tap event
                        // ResetCurrentGesture();
                        mCurrentGestureEvent = new GestureTapEvent(x, y, time, 1);
                    }
                    else
                    {
                        mChangedTouchQueues.AddLast(info);
                    }
                    return;
                }
                else
                {
                    // double click
                    info.curState = TouchState.STATE_DOUBLE_TAP;
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
            }
            else
            {
                info.touchQueue.GetAbsMaxMovingDistance(ref x, ref y);
                if ((x > mMaxSteadyMoveDistanceX) || (y > mMaxSteadyMoveDistanceY))
                {
                    // point moved, change to swipe or move state
                    float maxSpeed = 0;
                    float avgSpeed = 0;
                    bool  gotSpeed = info.touchQueue.GetMovingSpeeds(ref maxSpeed, ref avgSpeed);
                    if (gotSpeed && (maxSpeed < mMinSpeedForSwipe))
                    {
                        info.curState = TouchState.STATE_MOVE;
                    }
                    else
                    {
                        info.curState = TouchState.STATE_SWIPE;
                    }
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
                info.touchQueue.GetTrackStartingPosition(ref x, ref y);
                if (info.touchQueue.GetCurrentDuration(time) > mMinSteadyTimeForDrag)
                {
                    info.curState = TouchState.STATE_DRAG;

                    /*
                     * ResetCurrentGesture();
                     * new (mCurrentGestureEvent) GestureDragEvent(x, y, time, 1);
                     */
                    mChangedTouchQueues.AddLast(info);
                    return;
                }
                mChangedTouchQueues.AddLast(info);
            }
        }