Exemplo n.º 1
0
        public static IEnumerable <MouseButton> GetPressedButtons(this MouseState state)
        {
            if (!state.AnyButtonPressed())
            {
                return(new MouseButton[0]);
            }

            var result = new List <MouseButton>();

            if (state.LeftButton == ButtonState.Pressed)
            {
                result.Add(MouseButton.Left);
            }
            if (state.RightButton == ButtonState.Pressed)
            {
                result.Add(MouseButton.Right);
            }
            if (state.MiddleButton == ButtonState.Pressed)
            {
                result.Add(MouseButton.Middle);
            }
            if (state.XButton1 == ButtonState.Pressed)
            {
                result.Add(MouseButton.X1);
            }
            if (state.XButton2 == ButtonState.Pressed)
            {
                result.Add(MouseButton.X2);
            }

            return(result);
        }