Esempio n. 1
0
 public FNodeEnablerForSingleTouch(FNode node)
 {
     singleTouchable = node as FSingleTouchableInterface;
     if (singleTouchable == null)
     {
         throw new FutileException("Trying to enable single touch on a node that doesn't implement FSingleTouchableInterface");
     }
 }
Esempio n. 2
0
 public void AddSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     if (!_capturedTouchables.Contains(touchable))
     {
         _capturedTouchables.Add(touchable);
         _needsPrioritySort = true;
     }
 }
Esempio n. 3
0
	public FNodeEnablerForSingleTouch(FNode node)
	{
		singleTouchable = node as FSingleTouchableInterface;
		if(singleTouchable == null)
		{
			throw new FutileException("Trying to enable single touch on a node that doesn't implement FSingleTouchableInterface");	
		}
	}
Esempio n. 4
0
 /**
  * Targeted touch disabling, intended to ensure a particular button is not
  * signalled to release by the currently-active touch.
  */
 public bool CancelSingleTouch(FSingleTouchableInterface target, FTouch touch)
 {
     if (target == _theSingleTouchable)
     {
         _theSingleTouchable.HandleSingleTouchCanceled(touch);
         _theSingleTouchable = null;
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 /**
  * Targeted touch disabling, intended to ensure none of a particular set of buttons
  * is signalled to release by the currently-active touch.
  */
 public bool CancelSingleTouches(ICollection <FSingleTouchableInterface> targets, FTouch touch)
 {
     if (targets.Contains(_theSingleTouchable))
     {
         _theSingleTouchable.HandleSingleTouchCanceled(touch);
         _theSingleTouchable = null;
         return(true);
     }
     return(false);
 }
Esempio n. 6
0
 /**
  * Targeted touch disabling, intended to ensure none of a particular set of buttons
  * is signalled to release by the currently-active touch.  Overload is included to
  * circumvent Mono's inability to recognized an ICollection<FSingleTouchableInterface>
  * in a Dictionary<string, FButton>.ValueCollection.
  */
 public bool CancelSingleTouches(ICollection targets, FTouch touch)
 {
     foreach (object obj in targets)
     {
         if (obj == _theSingleTouchable)
         {
             _theSingleTouchable.HandleSingleTouchCanceled(touch);
             _theSingleTouchable = null;
             return(true);
         }
     }
     return(false);
 }
Esempio n. 7
0
 public void RemoveSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     if (_isUpdating)
     {
         if (!_singleTouchablesToRemove.Contains(touchable))
         {
             int index = _singleTouchablesToAdd.IndexOf(touchable);
             if (index != -1)
             {
                 _singleTouchablesToAdd.RemoveAt(index);
             }
             _singleTouchablesToRemove.Add(touchable);
         }
     }
     else
     {
         _singleTouchables.Remove(touchable);
     }
 }
Esempio n. 8
0
 public void AddSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     if (_isUpdating)
     {
         if (!_singleTouchablesToAdd.Contains(touchable))
         {
             int index = _singleTouchablesToRemove.IndexOf(touchable);
             if (index != -1)
             {
                 _singleTouchablesToRemove.RemoveAt(index);
             }
             _singleTouchablesToAdd.Add(touchable);
         }
     }
     else
     {
         if (!_singleTouchables.Contains(touchable))
         {
             _singleTouchables.Add(touchable);
         }
     }
     _needsPrioritySort = true;
 }
Esempio n. 9
0
 public void RemoveSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     if(_isUpdating)
     {
         if(!_singleTouchablesToRemove.Contains(touchable))
         {
             int index = _singleTouchablesToAdd.IndexOf(touchable);
             if(index != -1) _singleTouchablesToAdd.RemoveAt(index);
             _singleTouchablesToRemove.Add(touchable);
         }
     }
     else
     {
         _singleTouchables.Remove(touchable);
     }
 }
Esempio n. 10
0
    public void Update()
    {
        _isUpdating = true;

        if (_needsPrioritySort)
        {
            UpdatePrioritySorting();
        }

        float touchScale = 1.0f / Futile.displayScale;

        //the offsets account for the camera's 0,0 point (eg, center, bottom left, etc.)
        float offsetX = -Futile.screen.originX * Futile.screen.pixelWidth;
        float offsetY = -Futile.screen.originY * Futile.screen.pixelHeight;

        //Debug.Log ("Touch offset " + offsetX + " , " + offsetY);

        bool   wasMouseTouch = false;
        FTouch mouseTouch    = new FTouch();

        if (shouldMouseEmulateTouch)
        {
            mouseTouch.position = new Vector2((Input.mousePosition.x + offsetX) * touchScale, (Input.mousePosition.y + offsetY) * touchScale);

            mouseTouch.fingerId  = 0;
            mouseTouch.tapCount  = 1;
            mouseTouch.deltaTime = Time.deltaTime;

            if (Input.GetMouseButtonDown(0))
            {
                mouseTouch.deltaPosition = new Vector2(0, 0);
                _previousMousePosition   = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Began;
                wasMouseTouch    = true;
            }
            else if (Input.GetMouseButtonUp(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition   = mouseTouch.position;
                mouseTouch.phase         = TouchPhase.Ended;
                wasMouseTouch            = true;
            }
            else if (Input.GetMouseButton(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition   = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Moved;
                wasMouseTouch    = true;
            }
        }

        int touchCount = Input.touchCount;
        int offset     = 0;

        if (wasMouseTouch)
        {
            touchCount++;
        }

        FTouch[] touches = new FTouch[touchCount];

        if (wasMouseTouch)
        {
            touches[0] = mouseTouch;
            offset     = 1;
        }

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch  sourceTouch = Input.GetTouch(i);
            FTouch resultTouch = new FTouch();

            resultTouch.deltaPosition = new Vector2(sourceTouch.deltaPosition.x * touchScale, sourceTouch.deltaPosition.y * touchScale);
            resultTouch.deltaTime     = sourceTouch.deltaTime;
            resultTouch.fingerId      = sourceTouch.fingerId + offset;
            resultTouch.phase         = sourceTouch.phase;
            resultTouch.position      = new Vector2((sourceTouch.position.x + offsetX) * touchScale, (sourceTouch.position.y + offsetY) * touchScale);
            resultTouch.tapCount      = sourceTouch.tapCount;

            touches[i + offset] = resultTouch;
        }

        int singleTouchableCount = _singleTouchables.Count;

        for (int t = 0; t < touchCount; t++)
        {
            FTouch touch = touches[t];

            if (touch.fingerId == 0)            // we only care about the first touch for the singleTouchables
            {
                if (touch.phase == TouchPhase.Began)
                {
                    for (int s = 0; s < singleTouchableCount; s++)
                    {
                        FSingleTouchableInterface singleTouchable = _singleTouchables[s];
                        if (singleTouchable.HandleSingleTouchBegan(touch))                        //the first touchable to return true becomes theSingleTouchable
                        {
                            _theSingleTouchable = singleTouchable;
                            break;
                        }
                    }
                }
                else if (touch.phase == TouchPhase.Ended)
                {
                    if (_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchEnded(touch);
                    }
                    _theSingleTouchable = null;
                }
                else if (touch.phase == TouchPhase.Canceled)
                {
                    if (_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchCanceled(touch);
                    }
                    _theSingleTouchable = null;
                }
                else                 //moved or stationary
                {
                    if (_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchMoved(touch);
                    }
                }

                break;                 //break out from the foreach, once we've found the first touch we don't care about the others
            }
        }

        if (touchCount > 0)
        {
            int multiTouchableCount = _multiTouchables.Count;
            for (int m = 0; m < multiTouchableCount; m++)
            {
                _multiTouchables[m].HandleMultiTouch(touches);
            }
        }

        //now add or remove anything that was changed while we were looping through

        for (int s = 0; s < _singleTouchablesToRemove.Count; s++)
        {
            _singleTouchables.Remove(_singleTouchablesToRemove[s]);
        }

        for (int s = 0; s < _singleTouchablesToAdd.Count; s++)
        {
            _singleTouchables.Add(_singleTouchablesToAdd[s]);
        }

        for (int m = 0; m < _multiTouchablesToRemove.Count; m++)
        {
            _multiTouchables.Remove(_multiTouchablesToRemove[m]);
        }

        for (int m = 0; m < _multiTouchablesToAdd.Count; m++)
        {
            _multiTouchables.Add(_multiTouchablesToAdd[m]);
        }

        _singleTouchablesToRemove.Clear();
        _singleTouchablesToAdd.Clear();
        _multiTouchablesToRemove.Clear();
        _multiTouchablesToAdd.Clear();

        _isUpdating = false;
    }
Esempio n. 11
0
 public void AddSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     if(_isUpdating)
     {
         if(!_singleTouchablesToAdd.Contains(touchable))
         {
             int index = _singleTouchablesToRemove.IndexOf(touchable);
             if(index != -1) _singleTouchablesToRemove.RemoveAt(index);
             _singleTouchablesToAdd.Add(touchable);
         }
     }
     else
     {
         if(!_singleTouchables.Contains(touchable))
         {
             _singleTouchables.Add(touchable);
         }
     }
     _needsPrioritySort = true;
 }
Esempio n. 12
0
 private static int PriorityComparison(FSingleTouchableInterface a, FSingleTouchableInterface b)
 {
     return(b.touchPriority - a.touchPriority);
 }
Esempio n. 13
0
	public void AddSingleTouchTarget(FSingleTouchableInterface touchable)
	{
		if(!_capturedTouchables.Contains(touchable))
		{
			_capturedTouchables.Add(touchable);
			_needsPrioritySort = true;
		}
	}
Esempio n. 14
0
 public void RemoveSingleTouchTarget(FSingleTouchableInterface touchable)
 {
     _capturedTouchables.Remove(touchable);
 }
Esempio n. 15
0
	public void RemoveSingleTouchTarget(FSingleTouchableInterface touchable)
	{
		_capturedTouchables.Remove(touchable);
	}
Esempio n. 16
0
    public void Update()
    {
        _isUpdating = true;

        float touchScale = 1.0f/Futile.displayScale;

        //the offsets account for the camera's 0,0 point (eg, center, bottom left, etc.)
        float offsetX = -Futile.instance.originX * Futile.pixelWidth;
        float offsetY = -Futile.instance.originY * Futile.pixelHeight;

        //Debug.Log ("Touch offset " + offsetX + " , " + offsetY);

        bool wasMouseTouch = false;
        FTouch mouseTouch = new FTouch();

        if(shouldMouseEmulateTouch)
        {
            mouseTouch.position = new Vector2((Input.mousePosition.x+offsetX)*touchScale, (Input.mousePosition.y+offsetY)*touchScale);
            mouseTouch.fingerId = 0;
            mouseTouch.tapCount = 1;
            mouseTouch.deltaPosition = new Vector2(0,0);
            mouseTouch.deltaTime = 0;

            if(Input.GetMouseButtonDown(0))
            {
                mouseTouch.phase = TouchPhase.Began;
                wasMouseTouch = true;
            }
            else if(Input.GetMouseButtonUp(0))
            {
                mouseTouch.phase = TouchPhase.Ended;
                wasMouseTouch = true;
            }
            else if(Input.GetMouseButton(0))
            {
                mouseTouch.phase = TouchPhase.Moved;
                wasMouseTouch = true;
            }
        }

        int touchCount = Input.touchCount;
        int offset = 0;

        if(wasMouseTouch) touchCount++;

        FTouch[] touches = new FTouch[touchCount];

        if(wasMouseTouch)
        {
            touches[0] = mouseTouch;
            offset = 1;
        }

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch sourceTouch = Input.GetTouch (i);
            FTouch resultTouch = new FTouch();

            resultTouch.deltaPosition = new Vector2(sourceTouch.deltaPosition.x*touchScale, sourceTouch.deltaPosition.y*touchScale);
            resultTouch.deltaTime = sourceTouch.deltaTime;
            resultTouch.fingerId = sourceTouch.fingerId+offset;
            resultTouch.phase = sourceTouch.phase;
            resultTouch.position = new Vector2((sourceTouch.position.x+offsetX)*touchScale, (sourceTouch.position.y+offsetY)*touchScale);
            resultTouch.tapCount = sourceTouch.tapCount;

            touches[i+offset] = resultTouch;
        }

        if(touches.Length > 0 )
        {
            foreach(FTouch touch in touches)
            {
                if(touch.fingerId == 0) // we only care about the first touch for the singleTouchables
                {
                    if(touch.phase == TouchPhase.Began)
                    {

                        foreach(FSingleTouchableInterface singleTouchable in _singleTouchables)
                        {
                            if(singleTouchable.HandleSingleTouchBegan(touch)) //the first touchable to return true becomes theSingleTouchable
                            {
                                _theSingleTouchable = singleTouchable;
                                break;
                            }
                        }
                    }
                    else if(touch.phase == TouchPhase.Ended)
                    {
                        if(_theSingleTouchable != null)
                        {
                            _theSingleTouchable.HandleSingleTouchEnded(touch);
                        }
                        _theSingleTouchable = null;
                    }
                    else if(touch.phase == TouchPhase.Canceled)
                    {
                        if(_theSingleTouchable != null)
                        {
                            _theSingleTouchable.HandleSingleTouchCanceled(touch);
                        }
                        _theSingleTouchable = null;
                    }
                    else //moved or stationary
                    {
                        if(_theSingleTouchable != null)
                        {
                            _theSingleTouchable.HandleSingleTouchMoved(touch);
                        }
                    }

                    break; //break out from the foreach, once we've found the first touch we don't care about the others
                }
            }

            foreach(FMultiTouchableInterface multiTouchable in _multiTouchables)
            {
                multiTouchable.HandleMultiTouch(touches);
            }
        }

        //now add or remove anything that was changed while we were looping through

        foreach(FSingleTouchableInterface singleTouchableToRemove in _singleTouchablesToRemove)
        {
            _singleTouchables.Remove(singleTouchableToRemove);
        }

        foreach(FSingleTouchableInterface singleTouchableToAdd in _singleTouchablesToAdd)
        {
            _singleTouchables.Add(singleTouchableToAdd);
        }

        foreach(FMultiTouchableInterface multiTouchableToRemove in _multiTouchablesToRemove)
        {
            _multiTouchables.Remove(multiTouchableToRemove);
        }

        foreach(FMultiTouchableInterface multiTouchableToAdd in _multiTouchablesToAdd)
        {
            _multiTouchables.Add(multiTouchableToAdd);
        }

        _singleTouchablesToRemove.Clear();
        _singleTouchablesToAdd.Clear();
        _multiTouchablesToRemove.Clear();
        _multiTouchablesToAdd.Clear();

        _isUpdating = false;
    }
Esempio n. 17
0
    public virtual void Update()
    {
        if (!isEnabled) return;

        _isUpdating = true;

        if(_needsPrioritySort)
        {
            UpdatePrioritySorting();
        }

        float touchScale = 1.0f/Futile.displayScale;

        //the offsets account for the camera's 0,0 point (eg, center, bottom left, etc.)
        float offsetX = -Futile.screen.originX * Futile.screen.pixelWidth;
        float offsetY = -Futile.screen.originY * Futile.screen.pixelHeight;

        //Debug.Log ("Touch offset " + offsetX + " , " + offsetY);

        bool wasMouseTouch = false;
        FTouch mouseTouch = new FTouch();

        if(shouldMouseEmulateTouch)
        {
            mouseTouch.position = new Vector2((Input.mousePosition.x+offsetX)*touchScale, (Input.mousePosition.y+offsetY)*touchScale);

            mouseTouch.fingerId = 0;
            mouseTouch.tapCount = 1;
            mouseTouch.deltaTime = Time.deltaTime;

            if(Input.GetMouseButtonDown(0))
            {
                mouseTouch.deltaPosition = new Vector2(0,0);
                _previousMousePosition = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Began;
                wasMouseTouch = true;
            }
            else if(Input.GetMouseButtonUp(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition = mouseTouch.position;
                mouseTouch.phase = TouchPhase.Ended;
                wasMouseTouch = true;
            }
            else if(Input.GetMouseButton(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Moved;
                wasMouseTouch = true;
            }
        }

        int touchCount = Input.touchCount;
        int offset = 0;

        if(wasMouseTouch) touchCount++;

        FTouch[] touches = new FTouch[touchCount];

        if(wasMouseTouch)
        {
            touches[0] = mouseTouch;
            offset = 1;
        }

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch sourceTouch = Input.GetTouch (i);
            FTouch resultTouch = new FTouch();

            resultTouch.deltaPosition = new Vector2(sourceTouch.deltaPosition.x*touchScale, sourceTouch.deltaPosition.y*touchScale);
            resultTouch.deltaTime = sourceTouch.deltaTime;
            resultTouch.fingerId = sourceTouch.fingerId+offset;
            resultTouch.phase = sourceTouch.phase;
            resultTouch.position = new Vector2((sourceTouch.position.x+offsetX)*touchScale, (sourceTouch.position.y+offsetY)*touchScale);
            resultTouch.tapCount = sourceTouch.tapCount;

            touches[i+offset] = resultTouch;
        }

        int singleTouchableCount = _singleTouchables.Count;

        int lowestFingerId = int.MaxValue;

        for(int t = 0; t<touchCount; t++)
        {
            FTouch touch = touches[t];
            if(touch.fingerId < lowestFingerId)
            {
                lowestFingerId = touch.fingerId;
            }
        }

        for(int t = 0; t<touchCount; t++)
        {
            FTouch touch = touches[t];

            if(touch.fingerId == lowestFingerId) // we only care about the first touch for the singleTouchables
            {
                if(touch.phase == TouchPhase.Began)
                {
                    for(int s = 0; s<singleTouchableCount; s++)
                    {
                        FSingleTouchableInterface singleTouchable = _singleTouchables[s];
                        if(singleTouchable.HandleSingleTouchBegan(touch)) //the first touchable to return true becomes theSingleTouchable
                        {
                            _theSingleTouchable = singleTouchable;
                            break;
                        }
                    }
                }
                else if(touch.phase == TouchPhase.Ended)
                {
                    if(_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchEnded(touch);
                    }
                    _theSingleTouchable = null;
                }
                else if(touch.phase == TouchPhase.Canceled)
                {
                    if(_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchCanceled(touch);
                    }
                    _theSingleTouchable = null;
                }
                else //moved or stationary
                {
                    if(_theSingleTouchable != null)
                    {
                        _theSingleTouchable.HandleSingleTouchMoved(touch);
                    }
                }

                break; //break out from the foreach, once we've found the first touch we don't care about the others
            }
        }

        if(touchCount > 0)
        {
            int multiTouchableCount = _multiTouchables.Count;
            for(int m = 0; m<multiTouchableCount; m++)
            {
                _multiTouchables[m].HandleMultiTouch(touches);
            }
        }

        //now add or remove anything that was changed while we were looping through

        for(int s = 0; s<_singleTouchablesToRemove.Count; s++)
        {
            _singleTouchables.Remove(_singleTouchablesToRemove[s]);
        }

        for(int s = 0; s<_singleTouchablesToAdd.Count; s++)
        {
            _singleTouchables.Add(_singleTouchablesToAdd[s]);
        }

        for(int m = 0; m<_multiTouchablesToRemove.Count; m++)
        {
            _multiTouchables.Remove(_multiTouchablesToRemove[m]);
        }

        for(int m = 0; m<_multiTouchablesToAdd.Count; m++)
        {
            _multiTouchables.Add(_multiTouchablesToAdd[m]);
        }

        _singleTouchablesToRemove.Clear();
        _singleTouchablesToAdd.Clear();
        _multiTouchablesToRemove.Clear();
        _multiTouchablesToAdd.Clear();

        _isUpdating = false;
    }
Esempio n. 18
0
 /**
  * Naive touch disabling, mainly intended for preventing a detected touch from
  * pressing any buttons at all.
  */
 public void CancelSingleTouch(FTouch touch)
 {
     _theSingleTouchable.HandleSingleTouchCanceled(touch);
     _theSingleTouchable = null;
 }
Esempio n. 19
0
 private static int PriorityComparison(FSingleTouchableInterface a, FSingleTouchableInterface b)
 {
     return b.touchPriority - a.touchPriority;
 }
Esempio n. 20
0
    public void Update()
    {
        if (!isEnabled)
        {
            return;
        }

        if (_needsPrioritySort)
        {
            UpdatePrioritySorting();
        }

        //create non-changeable temporary copies of the lists
        //this is so that there won't be problems if touchables are removed/added while being iterated through
        FMultiTouchableInterface[]    tempMultiTouchables    = _multiTouchables.ToArray();
        FCapturedTouchableInterface[] tempCapturedTouchables = _capturedTouchables.ToArray();

        float touchScale = 1.0f / Futile.displayScale;

        //the offsets account for the camera's 0,0 point (eg, center, bottom left, etc.)
        float offsetX = -Futile.screen.originX * Futile.screen.pixelWidth;
        float offsetY = -Futile.screen.originY * Futile.screen.pixelHeight;

        //Debug.Log ("Touch offset " + offsetX + " , " + offsetY);

        bool   wasMouseTouch = false;
        FTouch mouseTouch    = new FTouch();

        if (shouldMouseEmulateTouch)
        {
            mouseTouch.position = new Vector2((Input.mousePosition.x + offsetX) * touchScale, (Input.mousePosition.y + offsetY) * touchScale);

            mouseTouch.fingerId  = 0;
            mouseTouch.tapCount  = 1;
            mouseTouch.deltaTime = Time.deltaTime;

            if (Input.GetMouseButtonDown(0))
            {
                mouseTouch.deltaPosition = new Vector2(0, 0);
                _previousMousePosition   = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Began;
                wasMouseTouch    = true;
            }
            else if (Input.GetMouseButtonUp(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition   = mouseTouch.position;
                mouseTouch.phase         = TouchPhase.Ended;
                wasMouseTouch            = true;
            }
            else if (Input.GetMouseButton(0))
            {
                mouseTouch.deltaPosition = new Vector2(mouseTouch.position.x - _previousMousePosition.x, mouseTouch.position.y - _previousMousePosition.y);
                _previousMousePosition   = mouseTouch.position;

                mouseTouch.phase = TouchPhase.Moved;
                wasMouseTouch    = true;
            }
        }

        int touchCount = Input.touchCount;
        int offset     = 0;

        if (wasMouseTouch)
        {
            touchCount++;
        }

        FTouch[] touches = new FTouch[touchCount];

        if (wasMouseTouch)
        {
            touches[0] = mouseTouch;
            offset     = 1;
        }

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch  sourceTouch = Input.GetTouch(i);
            FTouch resultTouch = new FTouch();

            resultTouch.deltaPosition = new Vector2(sourceTouch.deltaPosition.x * touchScale, sourceTouch.deltaPosition.y * touchScale);
            resultTouch.deltaTime     = sourceTouch.deltaTime;
            resultTouch.fingerId      = sourceTouch.fingerId + offset;
            resultTouch.phase         = sourceTouch.phase;
            resultTouch.position      = new Vector2((sourceTouch.position.x + offsetX) * touchScale, (sourceTouch.position.y + offsetY) * touchScale);
            resultTouch.tapCount      = sourceTouch.tapCount;

            touches[i + offset] = resultTouch;
        }

        int capturedTouchableCount = tempCapturedTouchables.Length;

        //reset the touch slotIndexes so that each slot can pick the touch it needs
        for (int t = 0; t < touchCount; t++)
        {
            FTouch touch = touches[t];
            touch.slot = null;
        }

        //match up slots that are currently active with the touches
        for (int s = 0; s < SLOT_COUNT; s++)
        {
            FTouchSlot slot = _touchSlots[s];

            if (slot.doesHaveTouch)
            {
                bool didFindMatchingTouch = false;

                for (int t = 0; t < touchCount; t++)
                {
                    FTouch touch = touches[t];
                    if (slot.touch.fingerId == touch.fingerId)
                    {
                        didFindMatchingTouch = true;
                        slot.touch           = touch;
                        touch.slot           = slot;
                        break;
                    }
                }

                if (!didFindMatchingTouch)
                {
                    slot.doesHaveTouch = false;
                    slot.touchable     = null;
                }
            }
        }

        //fill any blank slots with the unclaimed touches
        for (int s = 0; s < SLOT_COUNT; s++)
        {
            FTouchSlot slot = _touchSlots[s];

            if (!slot.doesHaveTouch)
            {
                for (int t = 0; t < touchCount; t++)
                {
                    FTouch touch = touches[t];
                    if (touch.slot == null)
                    {
                        slot.touch         = touch;
                        slot.doesHaveTouch = true;
                        touch.slot         = slot;
                        break;
                    }
                }
            }

            if (slot.doesHaveTouch)            //send the touch out to the slots that need it
            {
                if (slot.touch.phase == TouchPhase.Began)
                {
                    for (int c = 0; c < capturedTouchableCount; c++)
                    {
                        FCapturedTouchableInterface capturedTouchable = tempCapturedTouchables[c];

                        FSingleTouchableInterface singleTouchable = capturedTouchable as FSingleTouchableInterface;

                        //the first touchable to return true becomes the active one
                        if (slot.index == 0 && singleTouchable != null && singleTouchable.HandleSingleTouchBegan(slot.touch))
                        {
                            slot.isSingleTouchable = true;
                            slot.touchable         = capturedTouchable;
                            break;
                        }
                        else
                        {
                            FSmartTouchableInterface smartTouchable = capturedTouchable as FSmartTouchableInterface;
                            if (smartTouchable != null && smartTouchable.HandleSmartTouchBegan(slot.index, slot.touch))
                            {
                                slot.isSingleTouchable = false;
                                slot.touchable         = capturedTouchable;
                                break;
                            }
                        }
                    }
                }
                else if (slot.touch.phase == TouchPhase.Moved)
                {
                    if (slot.touchable != null)
                    {
                        if (slot.isSingleTouchable)
                        {
                            (slot.touchable as FSingleTouchableInterface).HandleSingleTouchMoved(slot.touch);
                        }
                        else
                        {
                            (slot.touchable as FSmartTouchableInterface).HandleSmartTouchMoved(slot.index, slot.touch);
                        }
                    }
                }
                else if (slot.touch.phase == TouchPhase.Ended)
                {
                    if (slot.touchable != null)
                    {
                        if (slot.isSingleTouchable)
                        {
                            (slot.touchable as FSingleTouchableInterface).HandleSingleTouchEnded(slot.touch);
                        }
                        else
                        {
                            (slot.touchable as FSmartTouchableInterface).HandleSmartTouchEnded(slot.index, slot.touch);
                        }
                    }

                    slot.touchable     = null;
                    slot.doesHaveTouch = false;
                }
                else if (slot.touch.phase == TouchPhase.Canceled)
                {
                    if (slot.touchable != null)
                    {
                        if (slot.isSingleTouchable)
                        {
                            (slot.touchable as FSingleTouchableInterface).HandleSingleTouchCanceled(slot.touch);
                        }
                        else
                        {
                            (slot.touchable as FSmartTouchableInterface).HandleSmartTouchCanceled(slot.index, slot.touch);
                        }
                    }

                    slot.touchable     = null;
                    slot.doesHaveTouch = false;
                }
            }
            else             //clear the slot here
            {
                slot.touchable     = null;
                slot.doesHaveTouch = false;
            }
        }

        if (touchCount > 0)
        {
            int multiTouchableCount = tempMultiTouchables.Length;
            for (int m = 0; m < multiTouchableCount; m++)
            {
                tempMultiTouchables[m].HandleMultiTouch(touches);
            }
        }
    }