Ejemplo n.º 1
0
        internal override void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted.Raise(this, new TouchEventArgs(touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved.Raise(this, new TouchEventArgs(touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded.Raise(this, new TouchEventArgs(touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled.Raise(this, new TouchEventArgs(touchLocation));
                    break;
                }
            }
        }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
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));
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
 public virtual void OnTouchMoved()
 {
     TouchMoved.Invoke(this);
 }
Ejemplo n.º 9
0
 public virtual void OnTouchMoved()
 {
     IsTouchInside = true;
     TouchMoved.Invoke(this);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Protected overridable handler that raises TouchMoved event.
 /// </summary>
 protected virtual void OnTouchMoved(TouchEventArgs args)
 {
     TouchMoved?.Invoke(this, args);
 }
Ejemplo n.º 11
0
 protected void SingleTouchMoved()
 {
     TouchMoved?.Invoke(FirstTouch);
 }
Ejemplo n.º 12
0
 protected virtual void OnTouchMoved(ITouchEventArgs e) =>
 TouchMoved?.Invoke(this, e);