public void TouchesEnded(NSSet touches, UIEvent evt) { Debug.WriteLine("GamePad.TouchesEnded: " + touches.Count); if (touches.Count == 1 && _currentNumberOfTouches == 1) { Debug.WriteLine("GamePad.TouchesEnded: touches.Count == 1 && _currentNumberOfTouches == 1"); var touch = (UITouch)touches.ElementAt(0); var viewTouchPoint = touch.LocationInNode(_scene); if (SingleFingerTouchEvent != null) { var touchData = new SingleFingerTouch(0, viewTouchPoint, GestureState.End); SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData)); } } else if (touches.Count == _currentNumberOfTouches) { Debug.WriteLine("GamePad.TouchesEnded: touches.Count == _currentNumberOfTouches"); if (IllegalTouchEvent != null) { var touchData = new IllegalTouch(GestureState.End); IllegalTouchEvent(this, new EventArgs <IllegalTouch>(touchData)); } } _currentNumberOfTouches = _currentNumberOfTouches - touches.Count; Debug.WriteLine("GamePad.TouchesBegan: _currentNumberOfTouches=" + _currentNumberOfTouches); }
public void TouchesEnded(NSSet touches, UIEvent evt) { Debug.WriteLine("TouchesEnded: " + touches.Count); if (touches.Count == 1 && _currentTouchType == TouchType.OneFingerTouch) { Debug.WriteLine("TouchesEnded (TouchType.SingleTouch): " + touches.Count); if (SingleFingerTouchEvent != null) { var touch = (UITouch)touches.First(); var touchData = new SingleFingerTouch(0, touch.LocationInView(_view), GestureState.End); SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData)); } _currentTouchType = TouchType.None; } if (_currentTouchType == TouchType.TwoFingerTouch) { if (TwoFingerTouchEvent != null) { Debug.WriteLine("TouchesEnded"); var firstViewTouchPoint = _touchDictionary[_touchList[0]]; var secondViewTouchPoint = _touchDictionary[_touchList[1]]; var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.End); TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData)); } _currentTouchType = TouchType.None; } foreach (UITouch touch in touches.Cast <UITouch>()) { var handle = touch.Handle; _touchDictionary.Remove(handle); _touchList.Remove(handle); } Debug.WriteLine("TouchesEnded: type: " + _currentTouchType); }
public void TouchesBegan(NSSet touches, UIEvent evt) { Debug.WriteLine("TouchesBegan: " + touches.Count); if (touches.Count == 1 && _currentTouchType == TouchType.None) { _currentTouchType = TouchType.OneFingerTouch; var touch = (UITouch)touches.ElementAt(0); var handle = touch.Handle; var viewTouchPoint = touch.LocationInView(_view); Debug.WriteLine("TouchesBegan (TouchType.None): " + touches.Count + ", TouchType: " + _currentTouchType + ", Handle: " + handle + ", Point: " + viewTouchPoint); _touchDictionary.Add(handle, viewTouchPoint); _touchList.Add(handle); if (SingleFingerTouchEvent != null) { var firstViewTouchPoint = _touchDictionary[_touchList[0]]; var touchData = new SingleFingerTouch(0, firstViewTouchPoint, GestureState.Start); SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData)); } } else if (touches.Count == 1 && _currentTouchType == TouchType.OneFingerTouch) { var touch = (UITouch)touches.ElementAt(0); var handle = touch.Handle; var viewTouchPoint = touch.LocationInView(_view); Debug.WriteLine("TouchesBegan: " + touches.Count + ", TouchType.SingleTouch, Handle: " + handle + ", Point: " + viewTouchPoint); _touchDictionary.Add(handle, viewTouchPoint); _touchList.Add(handle); if (SingleFingerTouchEvent != null) { var existingViewTouchPoint = _touchDictionary[_touchList[0]]; var touchData = new SingleFingerTouch(0, existingViewTouchPoint, GestureState.Cancelled); SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData)); } if (TwoFingerTouchEvent != null) { var firstViewTouchPoint = _touchDictionary[_touchList[0]]; var secondViewTouchPoint = _touchDictionary[_touchList[1]]; Debug.WriteLine("firstViewTouchPoint: " + firstViewTouchPoint.ToString() + ", secondViewTouchPoint:" + secondViewTouchPoint.ToString()); var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Start); TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData)); } _currentTouchType = TouchType.TwoFingerTouch; } else if (touches.Count == 2 && _currentTouchType == TouchType.None) { foreach (UITouch touch in touches.Cast <UITouch>()) { var handle = touch.Handle; var viewTouchPoint = touch.LocationInView(_view); _touchDictionary.Add(handle, viewTouchPoint); _touchList.Add(handle); } if (TwoFingerTouchEvent != null) { var firstViewTouchPoint = _touchDictionary[_touchList[0]]; var secondViewTouchPoint = _touchDictionary[_touchList[1]]; var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Start); TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData)); } _currentTouchType = TouchType.TwoFingerTouch; } else if (_currentTouchType == TouchType.TwoFingerTouch) { foreach (UITouch touch in touches.Cast <UITouch>()) { var handle = touch.Handle; var viewTouchPoint = touch.LocationInView(_view); _touchDictionary.Add(handle, viewTouchPoint); _touchList.Add(handle); } if (TwoFingerTouchEvent != null) { var firstViewTouchPoint = _touchDictionary[_touchList[0]]; var secondViewTouchPoint = _touchDictionary[_touchList[1]]; var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Cancelled); TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData)); } _currentTouchType = TouchType.None; } Debug.WriteLine("TouchesBegan: type: " + _currentTouchType); }