Helper for reading input from keyboard and gamepad. This public class tracks the current and previous state of both input devices, and implements query properties for high level input actions such as "move up through the menu" or "pause the game".
This public class is similar to one in the GameStateManagement sample.
Example #1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.MenuUp)
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;

                //AudioManager.PlaySoundEffect("menu_scroll");
            }

            // Move to the next menu entry?
            if (input.MenuDown)
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;

                //AudioManager.PlaySoundEffect("menu_scroll");
            }

            // Accept or cancel the menu?
            if (input.MenuSelect)
            {
                //AudioManager.PlaySoundEffect("menu_select");
                OnSelectEntry(selectedEntry);
            }
            else if (input.MenuCancel)
            {
                OnCancel();
            }
        }
Example #2
0
 public override void HandleInput(InputState input)
 {
     if (input.IsNewKeyPress(Keys.Enter) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl))
     {
         var gdm = ((ScummGame)game).GraphicsDeviceManager;
         gdm.ToggleFullScreen();
         gdm.ApplyChanges();
     }
     else if (input.IsNewKeyPress(Keys.Space))
     {
         engine.IsPaused = !engine.IsPaused;
     }
     else
     {
         inputManager.UpdateInput(input.CurrentKeyboardState);
         cursorPos = inputManager.RealPosition;
         base.HandleInput(input);
     }
 }
Example #3
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }