Ejemplo n.º 1
0
 private void AddNewPointer(PointerID id, Entity pressed, Entity hover)
 {
     Debugging.Assert.IsTrue(GetPointer(id) == null);
     pointers.Add(new PointerControlInteraction {
         id = id, pressed = pressed, hover = hover
     });
 }
Ejemplo n.º 2
0
        private static void GetTouchState(InputSystem input, ref NativeList <PointerState> pointers)
        {
            int touchCount = input.TouchCount();

            for (int i = 0; i < touchCount; i++)
            {
                if (pointers.Length == MaxPointers)
                {
                    break;
                }

                var  touch          = input.GetTouch(i);
                var  worldPoint     = input.TranslateScreenToWorld(new float2(touch.x, touch.y));
                bool touchDown      = touch.phase == TouchState.Began;
                bool touchUp        = touch.phase == TouchState.Ended;
                bool touchCancelled = touch.phase == TouchState.Canceled;

                var          touchPointerId = new PointerID(PointerType.Touch, touch.fingerId);
                bool         willGone       = touchUp;
                PointerState touchPointer   = new PointerState()
                {
                    id        = touchPointerId,
                    pos       = worldPoint.xy,
                    down      = touchDown,
                    up        = touchUp,
                    willGone  = willGone,
                    cancelled = touchCancelled
                };

                pointers.Add(touchPointer);
            }
        }
Ejemplo n.º 3
0
        public Entity GetHoverControl(PointerID id)
        {
            var pointer = GetPointer(id);

            if (pointer == null)
            {
                return(Entity.Null);
            }

            return(pointer.hover);
        }
Ejemplo n.º 4
0
        public Entity GetPressedControl(PointerID id)
        {
            var pointer = GetPointer(id);

            if (pointer == null)
            {
                return(Entity.Null);
            }

            return(pointer.pressed);
        }
Ejemplo n.º 5
0
        private PointerControlInteraction GetPointer(PointerID id)
        {
            foreach (var item in pointers)
            {
                if (item.id.Equals(id))
                {
                    return(item);
                }
            }

            return(null);
        }
Ejemplo n.º 6
0
        public void SetHover(PointerID id, Entity control)
        {
            var pointer = GetPointer(id);

            if (pointer != null)
            {
                pointer.hover = control;
            }
            else if (control != Entity.Null)
            {
                AddNewPointer(id, Entity.Null, control);
            }
        }
Ejemplo n.º 7
0
        public void SetPressed(PointerID id, Entity control)
        {
            var pointer = GetPointer(id);

            if (pointer != null)
            {
                pointer.pressed = control;
            }
            else if (control != Entity.Null)
            {
                AddNewPointer(id, control, Entity.Null);
            }
        }
Ejemplo n.º 8
0
 public void ClearHover(PointerID id)
 {
     SetHover(id, Entity.Null);
 }
Ejemplo n.º 9
0
 public void ClearPressed(PointerID id)
 {
     SetPressed(id, Entity.Null);
 }