Esempio n. 1
0
        /// <summary>
        /// Manages the listener logic
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
Esempio n. 2
0
        public override void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
        public override void TouchesMoved(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            var touch = touches.AnyObject as UITouch;

            if (touch != null)
            {
                TouchMoved?.Invoke(this, touch);
            }
        }
        public override void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            if (TouchPanel.IsGestureAvailable)
            {
                var gesture = TouchPanel.ReadGesture();
                if (gesture.GestureType == GestureType.Tap)
                {
                    int x = 0;
                }
                if (gesture.GestureType == GestureType.DoubleTap)
                {
                    int y = 0;
                }
            }

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
Esempio n. 5
0
        private void OnDevicePacket()
        {
            // WARNING: This is called on a separate thread from the thread
            // that initialized the object!
            if (!LoadPacket())
            {
                return;
            }
            int  fingerState = _packet.FingerState;
            bool touching    = (fingerState & (int)SynFingerFlags.SF_FingerPresent) != 0;

            if (touching != _touching)
            {
                _touching = touching;
                EventHandler handler = touching ? TouchStarted : TouchEnded;
                handler?.Invoke(this, EventArgs.Empty);
            }
            if (touching)
            {
                int x = NormalizeX(_packet.XRaw);
                int y = NormalizeY(_packet.YRaw);
                TouchMoved?.Invoke(this, new RawTouchEventArgs(x, y));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Check if mouse clicked and call certain events of start, hover and finish of input
        /// </summary>
        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                _isTouching = true;
                TouchEnter?.Invoke(Input.mousePosition);
            }

            if (Input.GetMouseButton(0))
            {
                TouchStay?.Invoke(Input.mousePosition);
                if (Math.Abs(Input.GetAxis("Mouse X")) < MoveDelta && Math.Abs(Input.GetAxis("Mouse Y")) < MoveDelta)
                {
                    return;
                }
                TouchMoved?.Invoke(Input.mousePosition);
            }

            if (Input.GetMouseButtonUp(0))
            {
                _isTouching = false;
                TouchExit?.Invoke(Input.mousePosition);
            }
        }
Esempio n. 7
0
 public virtual void OnTouchMoved()
 {
     TouchMoved.Invoke(this);
 }
Esempio n. 8
0
 public virtual void OnTouchMoved()
 {
     IsTouchInside = true;
     TouchMoved.Invoke(this);
 }
Esempio n. 9
0
 /// <summary>
 /// Protected overridable handler that raises TouchMoved event.
 /// </summary>
 protected virtual void OnTouchMoved(TouchEventArgs args)
 {
     TouchMoved?.Invoke(this, args);
 }
Esempio n. 10
0
 protected void SingleTouchMoved()
 {
     TouchMoved?.Invoke(FirstTouch);
 }
Esempio n. 11
0
 protected virtual void OnTouchMoved(ITouchEventArgs e) =>
 TouchMoved?.Invoke(this, e);