예제 #1
0
        /// <summary>
        /// Handles latest activated touch state change event to produce mouse input from.
        /// </summary>
        /// <param name="e">The latest activated touch state change event.</param>
        /// <returns>Whether mouse input has been performed accordingly.</returns>
        protected virtual bool HandleMouseTouchStateChange(TouchStateChangeEvent e)
        {
            if (!MapMouseToLatestTouch)
            {
                return(false);
            }

            if (e.IsActive == true || e.LastPosition != null)
            {
                new MousePositionAbsoluteInputFromTouch(e)
                {
                    Position = e.Touch.Position
                }.Apply(CurrentState, this);
            }

            switch (e.IsActive)
            {
            case true:
                mouseMappedTouchesDown.Add(e.Touch.Source);
                break;

            case false:
                mouseMappedTouchesDown.Remove(e.Touch.Source);
                break;
            }

            new MouseButtonInputFromTouch(MouseButton.Left, mouseMappedTouchesDown.Count > 0, e).Apply(CurrentState, this);
            return(true);
        }
예제 #2
0
        protected virtual void HandleTouchStateChange(TouchStateChangeEvent e)
        {
            Debug.Assert(e.LastPosition != null || e.IsActive != null, $"A {nameof(TouchStateChangeEvent)} provided with no changes information.");

            var manager = GetButtonEventManagerFor(e.Touch.Source);

            if (e.LastPosition is Vector2 lastPosition)
            {
                manager.HandlePositionChange(e.State, lastPosition);
            }

            if (e.IsActive is bool active)
            {
                manager.HandleButtonStateChange(e.State, active ? ButtonStateChangeKind.Pressed : ButtonStateChangeKind.Released);
            }
        }
예제 #3
0
        /// <summary>
        /// Handles latest activated touch state change event to produce mouse input from.
        /// </summary>
        /// <param name="e">The latest activated touch state change event.</param>
        /// <returns>Whether mouse input has been performed accordingly.</returns>
        protected virtual bool HandleMouseTouchStateChange(TouchStateChangeEvent e)
        {
            if (!MapMouseToLatestTouch)
            {
                return(false);
            }

            if (e.IsActive == true || e.LastPosition != null)
            {
                new MousePositionAbsoluteInputFromTouch(e)
                {
                    Position = e.Touch.Position
                }.Apply(CurrentState, this);
            }

            new MouseButtonInputFromTouch(MouseButton.Left, e.State.Touch.ActiveSources.HasAnyButtonPressed, e).Apply(CurrentState, this);
            return(true);
        }
예제 #4
0
 public MouseButtonInputFromTouch(MouseButton button, bool isPressed, TouchStateChangeEvent touchEvent)
     : base(button, isPressed)
 {
     TouchEvent = touchEvent;
 }
예제 #5
0
 public MousePositionAbsoluteInputFromTouch(TouchStateChangeEvent touchEvent)
 {
     TouchEvent = touchEvent;
 }