GamePads.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GamePads.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using Microsoft.Xna.Framework;
  12. #endregion
  13. namespace Marblets
  14. {
  15. /// <summary>
  16. /// Easy access to a collection of gamepads
  17. /// </summary>
  18. public class GamePads
  19. {
  20. private GamePadHelper[] gamePads = new GamePadHelper[]
  21. {
  22. new GamePadHelper(PlayerIndex.One),
  23. new GamePadHelper(PlayerIndex.Two),
  24. new GamePadHelper(PlayerIndex.Three),
  25. new GamePadHelper(PlayerIndex.Four)
  26. };
  27. /// <summary>
  28. /// Returns the correct gamepad for a player
  29. /// </summary>
  30. /// <param name="player">Which player. Note this helper class does not handle
  31. /// PlayerIndex.Any</param>
  32. /// <returns></returns>
  33. public GamePadHelper this[PlayerIndex player]
  34. {
  35. get
  36. {
  37. return gamePads[(int)player];
  38. }
  39. }
  40. /// <summary>
  41. /// Updates the state of all gamepads so the XXXpressed functions will work.
  42. /// This method should be called once per frame
  43. /// </summary>
  44. public void Update(Game game)
  45. {
  46. foreach(GamePadHelper gamepad in gamePads)
  47. {
  48. gamepad.Update(game);
  49. }
  50. }
  51. }
  52. }