internal void ForceReleaseButtons() { foreach (var button in DownButtons.ToArray()) { MouseState.HandleButtonUp(button); } }
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); } }
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(); } }
public bool IsButtonUp(MouseButton button) { return(UpButtons.Contains(button) || !DownButtons.Contains(button)); }
public bool IsButtonDown(MouseButton button) { return(DownButtons.Contains(button)); }