public void ProcessUpdate()
        {
            KeyboardState state          = Keyboard.GetState();
            List <Keys>   newPressedKeys = state.GetPressedKeys().ToList();

            List <Keys> lifted  = new List <Keys>();
            List <Keys> pressed = new List <Keys>();

            DKGameUtilities.ListDifference(newPressedKeys, lastPressedKeys, lifted, pressed);

            if (lifted.Count != 0)
            {
                foreach (Keys liftedKey in lifted)
                {
                    lastPressedKeys.Remove(liftedKey);
                }
                if (GetFirstToMap(lastPressedKeys) != Keys.None)
                {
                    controllerKeyMapping[GetFirstToMap(lastPressedKeys)]();
                }
            }

            if (pressed.Count != 0)
            {
                foreach (Keys pressedKey in pressed)
                {
                    lastPressedKeys.Add(pressedKey);
                }
            }

            if (GetFirstToMap(pressed) != Keys.None)
            {
                controllerKeyMapping[GetFirstToMap(pressed)]();
            }
        }
Example #2
0
        public void ProcessUpdate()
        {
            KeyboardState state          = Keyboard.GetState();
            List <Keys>   newPressedKeys = state.GetPressedKeys().ToList();

            List <Keys> lifted  = new List <Keys>();
            List <Keys> pressed = new List <Keys>();

            DKGameUtilities.ListDifference(newPressedKeys, lastPressedKeys, lifted, pressed);

            if (lifted.Count != 0)
            {
                Boolean horizontalStop = !(pressed.Contains(Keys.Right) || pressed.Contains(Keys.Left));
                foreach (Keys liftedKey in lifted)
                {
                    lastPressedKeys.Remove(liftedKey);
                    Boolean verticalStop = liftedKey.Equals(Keys.Z) || liftedKey.Equals(Keys.Down);

                    if (verticalStop)
                    {
                        centralReceiver.MoveVerticalIdle();
                    }
                }
                if (horizontalStop)
                {
                    centralReceiver.MoveHorizontalIdle();
                }
                controllerKeyMapping[GetFirstToMap(lastPressedKeys)]();
            }

            if (pressed.Count != 0)
            {
                foreach (Keys pressedKey in pressed)
                {
                    lastPressedKeys.Add(pressedKey);
                }
            }

            if (GetFirstToMap(pressed) != Keys.None)
            {
                controllerKeyMapping[GetFirstToMap(pressed)]();
            }
        }