Exemplo n.º 1
0
        public void Poll(IGameEngineTime time)
        {
            // Poll MonoGame mouse state.
            var state   = Mouse.GetState();
            var buttons = MouseButton.None;

            // Determine button states.
            if (state.LeftButton == ButtonState.Pressed)
            {
                buttons |= MouseButton.Left;
            }
            if (state.MiddleButton == ButtonState.Pressed)
            {
                buttons |= MouseButton.Middle;
            }
            if (state.RightButton == ButtonState.Pressed)
            {
                buttons |= MouseButton.Right;
            }
            if (state.XButton1 == ButtonState.Pressed)
            {
                buttons |= MouseButton.X1;
            }
            if (state.XButton2 == ButtonState.Pressed)
            {
                buttons |= MouseButton.X2;
            }

            // Create new state.
            mouseStateBuffer.Push(new MouseState(new Point(state.X, state.Y), buttons, state.ScrollWheelValue));

            buttonWatcher.Update(time, GetButtonsUp(), GetButtonsDown());
        }
Exemplo n.º 2
0
        public void Poll(IGameEngineTime time)
        {
            keyboardStateBuffer.Push(Keyboard.GetState());

            if (keyboardCharacterFrameBuffer.Length != 0)
            {
                keyboardCharacterBuffer.Push(keyboardCharacterFrameBuffer.ToString());

                keyboardCharacterFrameBuffer.Clear();
            }
            else
            {
                keyboardCharacterBuffer.Push(string.Empty);
            }

            keyWatcher.Update(time, GetKeysUp(), GetKeysDown());
        }