示例#1
0
 internal void ForceReleaseButtons()
 {
     foreach (var button in DownButtons.ToArray())
     {
         MouseState.HandleButtonUp(button);
     }
 }
示例#2
0
        private void OnLostMouseCapture(object sender, EventArgs args)
        {
            var buttonsToRelease = DownButtons.ToArray();

            foreach (var button in buttonsToRelease)
            {
                MouseState.HandleButtonUp(button);
            }
        }
 protected void UpdateButtonState(GamepadButtons button, bool isDown)
 {
     if (isDown && !DownButtons.Contains(button))
     {
         PressedButtons.Add(button);
         DownButtons.Add(button);
     }
     else if (!isDown && DownButtons.Contains(button))
     {
         ReleasedButtons.Add(button);
         DownButtons.Remove(button);
     }
 }
示例#4
0
        static internal void Update()
        {
            keyboardPrev    = keyboard;
            mousePrev       = mouse;
            mousePosPrev    = mousePos;
            prevDownKeys    = DownKeys.ToArray();
            prevDownButtons = DownButtons.ToArray();

            keyboard = Keyboard.GetState();
            mouse    = Mouse.GetState();

            if (AcceptMouse)
            {
                mousePos = new Vector2(Cursor.Position.X - MMW.X, Cursor.Position.Y - MMW.Y);
            }

            DownKeys = GetDownKeys();
            {
                var list = new List <Key>();
                foreach (var k in DownKeys)
                {
                    if (!prevDownKeys.Contains(k))
                    {
                        list.Add(k);
                    }
                }
                PressedKeys = list.ToArray();
            }
            {
                var list = new List <Key>();
                foreach (var k in prevDownKeys)
                {
                    if (!DownKeys.Contains(k))
                    {
                        list.Add(k);
                    }
                }
                ReleasedKeys = list.ToArray();
            }

            DownButtons = GetDownButtons();
            {
                var list = new List <MouseButton>();
                foreach (var b in DownButtons)
                {
                    if (!prevDownButtons.Contains(b))
                    {
                        list.Add(b);
                    }
                }
                PressedButtons = list.ToArray();
            }
            {
                var list = new List <MouseButton>();
                foreach (var b in prevDownButtons)
                {
                    if (!DownButtons.Contains(b))
                    {
                        list.Add(b);
                    }
                }
                ReleasedButtons = list.ToArray();
            }
        }
示例#5
0
 public bool IsButtonUp(MouseButton button)
 {
     return(UpButtons.Contains(button) || !DownButtons.Contains(button));
 }
示例#6
0
 public bool IsButtonDown(MouseButton button)
 {
     return(DownButtons.Contains(button));
 }