Exemplo n.º 1
0
        protected virtual void Update()
        {
            // Remove previously up fingers, or mark them as up in case the up event isn't read correctly
            for (var i = fingers.Count - 1; i >= 0; i--)
            {
                var finger = fingers[i];

                if (finger.Up == true)
                {
                    fingers.RemoveAt(i); pool.Push(finger);
                }
                else
                {
                    finger.Up = true;
                }
            }

            // Update real fingers
            if (TouchCount > 0)
            {
                for (var i = 0; i < TouchCount; i++)
                {
                    int id; Vector2 position; float pressure; bool up;

                    GetTouch(i, out id, out position, out pressure, out up);

                    AddFinger(id, position, pressure, up);
                }
            }
            // If there are no real touches, simulate some from the mouse?
            else
            {
                var set = false;
                var up  = false;

                GetMouse(ref set, ref up);

                if (set == true || up == true)
                {
                    AddFinger(-1, MousePosition, 1.0f, up);
                }
            }

            // Events
            foreach (var finger in fingers)
            {
                if (finger.Down == true && OnFingerDown != null)
                {
                    OnFingerDown.Invoke(finger);
                }
                if (OnFingerUpdate != null)
                {
                    OnFingerUpdate.Invoke(finger);
                }
                if (finger.Up == true && OnFingerUp != null)
                {
                    OnFingerUp.Invoke(finger);
                }
            }
        }
Exemplo n.º 2
0
 /**
  * Simulate Input for LeanFinger, used to test Input operations on the screen
  *
  * @param finger LeanFinger Object
  */
 public static void SimulateFingerDown(LeanFinger finger)
 {
     OnFingerDown?.Invoke(finger);
 }