Beispiel #1
0
        public void Update(KeyboardState state, GameTime time)
        {
            KeyboardState state1 = Keyboard.GetState();

            this.activeKeys.Clear();
            lock (this)
                this.activeKeys.AddRange((IEnumerable <Keys>) this.registeredKeys);
            foreach (Keys key in this.activeKeys)
            {
                bool           pressed = state1.IsKeyDown(key);
                FezButtonState state2;
                if (this.keyStates.TryGetValue(key, out state2))
                {
                    if ((pressed || state2 != FezButtonState.Up) && FezButtonStateExtensions.NextState(state2, pressed) != state2)
                    {
                        this.keyStates.Remove(key);
                        this.keyStates.Add(key, FezButtonStateExtensions.NextState(state2, pressed));
                    }
                }
                else
                {
                    this.keyStates.Add(key, FezButtonStateExtensions.NextState(state2, pressed));
                }
            }
        }
Beispiel #2
0
        public void Update(GameTime time)
        {
            MouseState state = Mouse.GetState();

            this.wheelTurns      = state.ScrollWheelValue - this.lastState.ScrollWheelValue;
            this.wheelTurnedUp   = FezButtonStateExtensions.NextState(this.wheelTurnedUp, this.wheelTurns > 0);
            this.wheelTurnedDown = FezButtonStateExtensions.NextState(this.wheelTurnedDown, this.wheelTurns < 0);
            if (this.renderPanelHandle != this.parentFormHandle)
            {
                state = Mouse.GetState();
            }
            this.movement = new Point(state.X - this.position.X, state.Y - this.position.Y);
            this.position = new Point(state.X, state.Y);
            if (state != this.lastState)
            {
                bool hasMoved = this.movement.X != 0 || this.movement.Y != 0;
                this.leftButton   = this.DeduceMouseButtonState(this.leftButton, this.lastState.LeftButton, state.LeftButton, hasMoved);
                this.middleButton = this.DeduceMouseButtonState(this.middleButton, this.lastState.MiddleButton, state.MiddleButton, hasMoved);
                this.rightButton  = this.DeduceMouseButtonState(this.rightButton, this.lastState.RightButton, state.RightButton, hasMoved);
                this.lastState    = state;
            }
            else
            {
                this.ResetButton(ref this.leftButton);
                this.ResetButton(ref this.middleButton);
                this.ResetButton(ref this.rightButton);
            }
        }