InputReporterGame.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. //-----------------------------------------------------------------------------
  2. // InputReporterGame.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using Microsoft.Xna.Framework;
  9. using Microsoft.Xna.Framework.Content;
  10. using Microsoft.Xna.Framework.Graphics;
  11. using Microsoft.Xna.Framework.Input;
  12. namespace InputReporter
  13. {
  14. /// <summary>
  15. /// Displays live input values for all connected controllers.
  16. /// </summary>
  17. public partial class InputReporterGame : Game
  18. {
  19. private static readonly Vector2[] connectedControllerPositions = new Vector2[4]
  20. {
  21. new Vector2(606f, 60f),
  22. new Vector2(656f, 60f),
  23. new Vector2(606f, 110f),
  24. new Vector2(656f, 110f),
  25. };
  26. private static readonly Vector2[] selectedControllerPositions = new Vector2[4]
  27. {
  28. new Vector2(594f, 36f),
  29. new Vector2(686f, 36f),
  30. new Vector2(594f, 137f),
  31. new Vector2(686f, 137f),
  32. };
  33. private static readonly Vector2 titlePosition =
  34. new Vector2(180f, 73f);
  35. private static readonly Vector2 typeCenterPosition =
  36. new Vector2(660f, 270f);
  37. private static readonly Vector2 descriptionColumn1Position =
  38. new Vector2(65f, 135f);
  39. private static readonly Vector2 valueColumn1Position =
  40. new Vector2(220f, 135f);
  41. private static readonly Vector2 descriptionColumn2Position =
  42. new Vector2(310f, 135f);
  43. private static readonly Vector2 valueColumn2Position =
  44. new Vector2(472f, 135f);
  45. private static readonly Vector2 deadZoneInstructionsPosition =
  46. new Vector2(570f, 380f);
  47. private static readonly Vector2 exitInstructionsPosition =
  48. new Vector2(618f, 425f);
  49. private static readonly Color titleColor = new Color(60, 134, 11);
  50. private static readonly Color typeColor = new Color(38, 108, 87);
  51. private static readonly Color descriptionColor = new Color(33, 89, 15);
  52. private static readonly Color valueColor = new Color(38, 108, 87);
  53. private static readonly Color disabledColor = new Color(171, 171, 171);
  54. private static readonly Color instructionsColor = new Color(127, 130, 127);
  55. private const float deadZoneChargeSwitchDuration = 2f;
  56. private const float exitChargeSwitchDuration = 2f;
  57. private int selectedPlayer;
  58. private GamePadState[] gamePadStates = new GamePadState[4];
  59. private GamePadCapabilities[] gamePadCapabilities = new GamePadCapabilities[4];
  60. private KeyboardState lastKeyboardState;
  61. private GamePadDeadZone deadZone = GamePadDeadZone.IndependentAxes;
  62. public GamePadDeadZone DeadZone
  63. {
  64. get { return deadZone; }
  65. set
  66. {
  67. deadZone = value;
  68. deadZoneString = "(" + deadZone.ToString() + ")";
  69. if (dataFont != null)
  70. {
  71. Vector2 deadZoneStringSize =
  72. dataFont.MeasureString(deadZoneString);
  73. deadZoneStringPosition = new Vector2(
  74. (float)Math.Floor(deadZoneStringCenterPosition.X -
  75. deadZoneStringSize.X / 2f),
  76. (float)Math.Floor(deadZoneStringCenterPosition.Y -
  77. deadZoneStringSize.Y / 2f));
  78. }
  79. }
  80. }
  81. private string deadZoneString;
  82. private Vector2 deadZoneStringPosition;
  83. private Vector2 deadZoneStringCenterPosition;
  84. private ChargeSwitchExit exitSwitch =
  85. new ChargeSwitchExit(exitChargeSwitchDuration);
  86. private ChargeSwitchDeadZone deadZoneSwitch =
  87. new ChargeSwitchDeadZone(deadZoneChargeSwitchDuration);
  88. private GraphicsDeviceManager graphics;
  89. private SpriteBatch spriteBatch;
  90. private SpriteFont titleFont;
  91. private SpriteFont dataFont;
  92. private SpriteFont dataActiveFont;
  93. private SpriteFont typeFont;
  94. private SpriteFont instructionsFont;
  95. private SpriteFont instructionsActiveFont;
  96. private Texture2D backgroundTexture;
  97. private Texture2D[] connectedControllerTextures = new Texture2D[4];
  98. private Texture2D[] selectedControllerTextures = new Texture2D[4];
  99. private float dataSpacing;
  100. /// <summary>
  101. /// Primary constructor.
  102. /// </summary>
  103. public InputReporterGame()
  104. {
  105. graphics = new GraphicsDeviceManager(this);
  106. graphics.PreferredBackBufferWidth = 853;
  107. graphics.PreferredBackBufferHeight = 480;
  108. Content.RootDirectory = "Content";
  109. exitSwitch.Fire += new ChargeSwitch.FireDelegate(exitSwitch_Fire);
  110. deadZoneSwitch.Fire += new ChargeSwitch.FireDelegate(ToggleDeadZone);
  111. }
  112. /// <summary>
  113. /// Allows the game to perform any initialization it needs to before starting
  114. /// to run. This is where it can query for any required services and load any
  115. /// non-graphic related content. Calling base.Initialize will enumerate through
  116. /// any components and initialize them as well.
  117. /// </summary>
  118. protected override void Initialize()
  119. {
  120. selectedPlayer = 0;
  121. exitSwitch.Reset(exitChargeSwitchDuration);
  122. deadZoneSwitch.Reset(deadZoneChargeSwitchDuration);
  123. base.Initialize();
  124. DeadZone = GamePadDeadZone.IndependentAxes;
  125. }
  126. /// <summary>
  127. /// Load your graphics content.
  128. /// </summary>
  129. /// <param name="loadAllContent">Which type of content to load.</param>
  130. protected override void LoadContent()
  131. {
  132. spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
  133. titleFont = Content.Load<SpriteFont>("Fonts\\TitleFont");
  134. dataFont = Content.Load<SpriteFont>("Fonts\\DataFont");
  135. dataActiveFont = Content.Load<SpriteFont>("Fonts\\DataActiveFont");
  136. typeFont = Content.Load<SpriteFont>("Fonts\\TypeFont");
  137. instructionsFont = Content.Load<SpriteFont>("Fonts\\InstructionsFont");
  138. instructionsActiveFont =
  139. Content.Load<SpriteFont>("Fonts\\InstructionsActiveFont");
  140. dataSpacing = (float)Math.Floor(dataFont.LineSpacing * 1.3f);
  141. deadZoneStringCenterPosition = new Vector2(687f,
  142. (float)Math.Floor(deadZoneInstructionsPosition.Y +
  143. dataFont.LineSpacing * 1.7f));
  144. backgroundTexture = Content.Load<Texture2D>("Textures\\background");
  145. connectedControllerTextures[0] =
  146. Content.Load<Texture2D>("Textures\\connected_controller1");
  147. connectedControllerTextures[1] =
  148. Content.Load<Texture2D>("Textures\\connected_controller2");
  149. connectedControllerTextures[2] =
  150. Content.Load<Texture2D>("Textures\\connected_controller3");
  151. connectedControllerTextures[3] =
  152. Content.Load<Texture2D>("Textures\\connected_controller4");
  153. selectedControllerTextures[0] =
  154. Content.Load<Texture2D>("Textures\\select_controller1");
  155. selectedControllerTextures[1] =
  156. Content.Load<Texture2D>("Textures\\select_controller2");
  157. selectedControllerTextures[2] =
  158. Content.Load<Texture2D>("Textures\\select_controller3");
  159. selectedControllerTextures[3] =
  160. Content.Load<Texture2D>("Textures\\select_controller4");
  161. }
  162. /// <summary>
  163. /// Allows the game to run logic such as updating the world,
  164. /// checking for collisions, gathering input and playing audio.
  165. /// </summary>
  166. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  167. protected override void Update(GameTime gameTime)
  168. {
  169. KeyboardState keyboardState = Keyboard.GetState();
  170. if (keyboardState.IsKeyDown(Keys.Escape))
  171. {
  172. this.Exit();
  173. }
  174. if (keyboardState.IsKeyDown(Keys.Space) &&
  175. !lastKeyboardState.IsKeyDown(Keys.Space))
  176. {
  177. ToggleDeadZone();
  178. }
  179. bool setSelectedPlayer = false; // give preference to earlier controllers
  180. for (int i = 0; i < 4; i++)
  181. {
  182. gamePadStates[i] = GamePad.GetState((PlayerIndex)i, deadZone);
  183. gamePadCapabilities[i] = GamePad.GetCapabilities((PlayerIndex)i);
  184. if (!setSelectedPlayer && IsActiveGamePad(ref gamePadStates[i]))
  185. {
  186. selectedPlayer = i;
  187. setSelectedPlayer = true;
  188. }
  189. }
  190. deadZoneSwitch.Update(gameTime, ref gamePadStates[selectedPlayer]);
  191. exitSwitch.Update(gameTime, ref gamePadStates[selectedPlayer]);
  192. base.Update(gameTime);
  193. lastKeyboardState = keyboardState;
  194. }
  195. /// <summary>
  196. /// Determines if the provided GamePadState is "active".
  197. /// </summary>
  198. /// <param name="gamePadState">The GamePadState that is checked.</param>
  199. /// <remarks>
  200. /// "Active" currently means that at least one of the buttons is being pressed.
  201. /// </remarks>
  202. /// <returns>True if "active".</returns>
  203. private static bool IsActiveGamePad(ref GamePadState gamePadState)
  204. {
  205. return (gamePadState.IsConnected &&
  206. ((gamePadState.Buttons.A == ButtonState.Pressed) ||
  207. (gamePadState.Buttons.B == ButtonState.Pressed) ||
  208. (gamePadState.Buttons.X == ButtonState.Pressed) ||
  209. (gamePadState.Buttons.Y == ButtonState.Pressed) ||
  210. (gamePadState.Buttons.Start == ButtonState.Pressed) ||
  211. (gamePadState.Buttons.Back == ButtonState.Pressed) ||
  212. (gamePadState.Buttons.LeftShoulder == ButtonState.Pressed) ||
  213. (gamePadState.Buttons.RightShoulder == ButtonState.Pressed) ||
  214. (gamePadState.Buttons.LeftStick == ButtonState.Pressed) ||
  215. (gamePadState.Buttons.RightStick == ButtonState.Pressed) ||
  216. (gamePadState.DPad.Up == ButtonState.Pressed) ||
  217. (gamePadState.DPad.Left == ButtonState.Pressed) ||
  218. (gamePadState.DPad.Right == ButtonState.Pressed) ||
  219. (gamePadState.DPad.Down == ButtonState.Pressed)));
  220. }
  221. /// <summary>
  222. /// This is called when the game should draw itself.
  223. /// </summary>
  224. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  225. protected override void Draw(GameTime gameTime)
  226. {
  227. graphics.GraphicsDevice.Clear(Color.Black);
  228. base.Draw(gameTime);
  229. spriteBatch.Begin();
  230. // draw the background
  231. spriteBatch.Draw(backgroundTexture, Vector2.Zero, Color.White);
  232. // draw the connected-controller images
  233. for (int i = 0; i < 4; i++)
  234. {
  235. if (gamePadStates[i].IsConnected)
  236. {
  237. spriteBatch.Draw(connectedControllerTextures[i],
  238. connectedControllerPositions[i], Color.White);
  239. }
  240. }
  241. // draw the selected-player texture (numeral)
  242. spriteBatch.Draw(selectedControllerTextures[selectedPlayer],
  243. selectedControllerPositions[selectedPlayer], Color.White);
  244. // draw controller title
  245. string text = InputReporterResources.Title +
  246. ((PlayerIndex)selectedPlayer).ToString();
  247. spriteBatch.DrawString(titleFont, text, titlePosition,
  248. titleColor);
  249. // draw controller type
  250. text = gamePadCapabilities[selectedPlayer].GamePadType.ToString();
  251. Vector2 textSize = typeFont.MeasureString(text);
  252. spriteBatch.DrawString(typeFont, text, new Vector2(
  253. (float)Math.Floor(typeCenterPosition.X -
  254. textSize.X / 2f),
  255. (float)Math.Floor(typeCenterPosition.Y -
  256. textSize.Y / 2f)),
  257. typeColor);
  258. // draw the data
  259. DrawData(ref gamePadStates[selectedPlayer],
  260. ref gamePadCapabilities[selectedPlayer]);
  261. // draw the instructions
  262. spriteBatch.DrawString(deadZoneSwitch.Active ? instructionsActiveFont :
  263. instructionsFont, InputReporterResources.DeadZoneInstructions,
  264. deadZoneInstructionsPosition, instructionsColor);
  265. spriteBatch.DrawString(instructionsFont, deadZoneString,
  266. deadZoneStringPosition, instructionsColor);
  267. spriteBatch.DrawString(exitSwitch.Active ? instructionsActiveFont :
  268. instructionsFont, InputReporterResources.ExitInstructions,
  269. exitInstructionsPosition, instructionsColor);
  270. spriteBatch.End();
  271. }
  272. /// <summary>
  273. /// Draw all data for a set of GamePad data and capabilities.
  274. /// </summary>
  275. /// <param name="gamePadState">The GamePad data.</param>
  276. /// <param name="gamePadCapabilities">The GamePad capabilities.</param>
  277. /// <remarks>
  278. /// The GamePad structures are passed by reference for speed. They are not
  279. /// modified in this method.
  280. /// </remarks>
  281. private void DrawData(ref GamePadState gamePadState,
  282. ref GamePadCapabilities gamePadCapabilities)
  283. {
  284. //
  285. // Draw the first column of data
  286. //
  287. Vector2 descriptionPosition = descriptionColumn1Position;
  288. Vector2 valuePosition = valueColumn1Position;
  289. // draw left thumbstick data
  290. DrawValue(InputReporterResources.LeftThumbstickX, ref descriptionPosition,
  291. gamePadState.ThumbSticks.Left.X.ToString("0.000"), ref valuePosition,
  292. gamePadCapabilities.HasLeftXThumbStick,
  293. gamePadState.ThumbSticks.Left.X != 0f);
  294. DrawValue(InputReporterResources.LeftThumbstickY, ref descriptionPosition,
  295. gamePadState.ThumbSticks.Left.Y.ToString("0.000"), ref valuePosition,
  296. gamePadCapabilities.HasLeftYThumbStick,
  297. gamePadState.ThumbSticks.Left.Y != 0f);
  298. // draw the right thumbstick data
  299. DrawValue(InputReporterResources.RightThumbstickX, ref descriptionPosition,
  300. gamePadState.ThumbSticks.Right.X.ToString("0.000"), ref valuePosition,
  301. gamePadCapabilities.HasRightXThumbStick,
  302. gamePadState.ThumbSticks.Right.X != 0f);
  303. DrawValue(InputReporterResources.RightThumbstickY, ref descriptionPosition,
  304. gamePadState.ThumbSticks.Right.Y.ToString("0.000"), ref valuePosition,
  305. gamePadCapabilities.HasRightYThumbStick,
  306. gamePadState.ThumbSticks.Right.Y != 0f);
  307. descriptionPosition.Y += dataSpacing;
  308. valuePosition.Y += dataSpacing;
  309. // draw the trigger data
  310. DrawValue(InputReporterResources.LeftTrigger, ref descriptionPosition,
  311. gamePadState.Triggers.Left.ToString("0.000"), ref valuePosition,
  312. gamePadCapabilities.HasLeftTrigger,
  313. gamePadState.Triggers.Left != 0f);
  314. DrawValue(InputReporterResources.RightTrigger, ref descriptionPosition,
  315. gamePadState.Triggers.Right.ToString("0.000"), ref valuePosition,
  316. gamePadCapabilities.HasRightTrigger,
  317. gamePadState.Triggers.Right != 0f);
  318. descriptionPosition.Y += dataSpacing;
  319. valuePosition.Y += dataSpacing;
  320. // draw the directional pad data
  321. DrawValue(InputReporterResources.DPadUp, ref descriptionPosition,
  322. (gamePadState.DPad.Up == ButtonState.Pressed ?
  323. InputReporterResources.ButtonPressed :
  324. InputReporterResources.ButtonReleased), ref valuePosition,
  325. gamePadCapabilities.HasDPadUpButton,
  326. gamePadState.DPad.Up == ButtonState.Pressed);
  327. DrawValue(InputReporterResources.DPadDown, ref descriptionPosition,
  328. (gamePadState.DPad.Down == ButtonState.Pressed ?
  329. InputReporterResources.ButtonPressed :
  330. InputReporterResources.ButtonReleased), ref valuePosition,
  331. gamePadCapabilities.HasDPadDownButton,
  332. gamePadState.DPad.Down == ButtonState.Pressed);
  333. DrawValue(InputReporterResources.DPadLeft, ref descriptionPosition,
  334. (gamePadState.DPad.Left == ButtonState.Pressed ?
  335. InputReporterResources.ButtonPressed :
  336. InputReporterResources.ButtonReleased), ref valuePosition,
  337. gamePadCapabilities.HasDPadLeftButton,
  338. gamePadState.DPad.Left == ButtonState.Pressed);
  339. DrawValue(InputReporterResources.DPadRight, ref descriptionPosition,
  340. (gamePadState.DPad.Right == ButtonState.Pressed ?
  341. InputReporterResources.ButtonPressed :
  342. InputReporterResources.ButtonReleased), ref valuePosition,
  343. gamePadCapabilities.HasDPadRightButton,
  344. gamePadState.DPad.Right == ButtonState.Pressed);
  345. descriptionPosition.Y += dataSpacing;
  346. valuePosition.Y += dataSpacing;
  347. // draw the vibration data
  348. if (gamePadCapabilities.HasLeftVibrationMotor)
  349. {
  350. if (gamePadCapabilities.HasRightVibrationMotor)
  351. {
  352. spriteBatch.DrawString(dataFont,
  353. InputReporterResources.BothVibrationMotors, descriptionPosition,
  354. descriptionColor);
  355. }
  356. else
  357. {
  358. spriteBatch.DrawString(dataFont,
  359. InputReporterResources.LeftVibrationMotor, descriptionPosition,
  360. descriptionColor);
  361. }
  362. }
  363. else if (gamePadCapabilities.HasRightVibrationMotor)
  364. {
  365. spriteBatch.DrawString(dataFont,
  366. InputReporterResources.RightVibrationMotor, descriptionPosition,
  367. descriptionColor);
  368. }
  369. else
  370. {
  371. spriteBatch.DrawString(dataFont, InputReporterResources.NoVibration,
  372. descriptionPosition, descriptionColor);
  373. }
  374. //
  375. // Draw the second column of data
  376. //
  377. descriptionPosition = descriptionColumn2Position;
  378. valuePosition = valueColumn2Position;
  379. // draw the button data
  380. DrawValue(InputReporterResources.A, ref descriptionPosition,
  381. (gamePadState.Buttons.A == ButtonState.Pressed ?
  382. InputReporterResources.ButtonPressed :
  383. InputReporterResources.ButtonReleased), ref valuePosition,
  384. gamePadCapabilities.HasAButton,
  385. gamePadState.Buttons.A == ButtonState.Pressed);
  386. DrawValue(InputReporterResources.B, ref descriptionPosition,
  387. (gamePadState.Buttons.B == ButtonState.Pressed ?
  388. InputReporterResources.ButtonPressed :
  389. InputReporterResources.ButtonReleased), ref valuePosition,
  390. gamePadCapabilities.HasBButton,
  391. gamePadState.Buttons.B == ButtonState.Pressed);
  392. DrawValue(InputReporterResources.X, ref descriptionPosition,
  393. (gamePadState.Buttons.X == ButtonState.Pressed ?
  394. InputReporterResources.ButtonPressed :
  395. InputReporterResources.ButtonReleased), ref valuePosition,
  396. gamePadCapabilities.HasXButton,
  397. gamePadState.Buttons.X == ButtonState.Pressed);
  398. DrawValue(InputReporterResources.Y, ref descriptionPosition,
  399. (gamePadState.Buttons.Y == ButtonState.Pressed ?
  400. InputReporterResources.ButtonPressed :
  401. InputReporterResources.ButtonReleased), ref valuePosition,
  402. gamePadCapabilities.HasYButton,
  403. gamePadState.Buttons.Y == ButtonState.Pressed);
  404. DrawValue(InputReporterResources.LeftShoulder, ref descriptionPosition,
  405. (gamePadState.Buttons.LeftShoulder == ButtonState.Pressed ?
  406. InputReporterResources.ButtonPressed :
  407. InputReporterResources.ButtonReleased), ref valuePosition,
  408. gamePadCapabilities.HasLeftShoulderButton,
  409. gamePadState.Buttons.LeftShoulder == ButtonState.Pressed);
  410. DrawValue(InputReporterResources.RightShoulder, ref descriptionPosition,
  411. (gamePadState.Buttons.RightShoulder == ButtonState.Pressed ?
  412. InputReporterResources.ButtonPressed :
  413. InputReporterResources.ButtonReleased), ref valuePosition,
  414. gamePadCapabilities.HasRightShoulderButton,
  415. gamePadState.Buttons.RightShoulder == ButtonState.Pressed);
  416. DrawValue(InputReporterResources.LeftStick, ref descriptionPosition,
  417. (gamePadState.Buttons.LeftStick == ButtonState.Pressed ?
  418. InputReporterResources.ButtonPressed :
  419. InputReporterResources.ButtonReleased), ref valuePosition,
  420. gamePadCapabilities.HasLeftStickButton,
  421. gamePadState.Buttons.LeftStick == ButtonState.Pressed);
  422. DrawValue(InputReporterResources.RightStick, ref descriptionPosition,
  423. (gamePadState.Buttons.RightStick == ButtonState.Pressed ?
  424. InputReporterResources.ButtonPressed :
  425. InputReporterResources.ButtonReleased), ref valuePosition,
  426. gamePadCapabilities.HasRightStickButton,
  427. gamePadState.Buttons.RightStick == ButtonState.Pressed);
  428. DrawValue(InputReporterResources.Start, ref descriptionPosition,
  429. (gamePadState.Buttons.Start == ButtonState.Pressed ?
  430. InputReporterResources.ButtonPressed :
  431. InputReporterResources.ButtonReleased), ref valuePosition,
  432. gamePadCapabilities.HasStartButton,
  433. gamePadState.Buttons.Start == ButtonState.Pressed);
  434. DrawValue(InputReporterResources.Back, ref descriptionPosition,
  435. (gamePadState.Buttons.Back == ButtonState.Pressed ?
  436. InputReporterResources.ButtonPressed :
  437. InputReporterResources.ButtonReleased), ref valuePosition,
  438. gamePadCapabilities.HasBackButton,
  439. gamePadState.Buttons.Back == ButtonState.Pressed);
  440. descriptionPosition.Y += dataSpacing;
  441. valuePosition.Y += dataSpacing;
  442. // draw the packet number data
  443. DrawValue(InputReporterResources.PacketNumber, ref descriptionPosition,
  444. gamePadState.PacketNumber.ToString(), ref valuePosition,
  445. gamePadCapabilities.IsConnected, false);
  446. }
  447. /// <summary>
  448. /// Draw a single description/value pair.
  449. /// </summary>
  450. /// <param name="description">The description of the value.</param>
  451. /// <param name="descriptionPosition">The position of the description.</param>
  452. /// <param name="value">The value itself.</param>
  453. /// <param name="valuePosition">The position of the value.</param>
  454. /// <param name="enabled">If true, the value type is supported.</param>
  455. /// <param name="active">If true, the value type is active right now.</param>
  456. /// <remarks>
  457. /// The positions are modified by this function, moving down one line.
  458. /// </remarks>
  459. private void DrawValue(string description, ref Vector2 descriptionPosition,
  460. string value, ref Vector2 valuePosition, bool enabled, bool active)
  461. {
  462. spriteBatch.DrawString(dataFont, description, descriptionPosition,
  463. enabled ? descriptionColor : disabledColor);
  464. descriptionPosition.Y += dataSpacing;
  465. spriteBatch.DrawString(active ? dataActiveFont : dataFont,
  466. value, valuePosition, enabled ? valueColor : disabledColor);
  467. valuePosition.Y += dataSpacing;
  468. }
  469. /// <summary>
  470. /// Handles the dead-zone ChargeSwitch fire event. Toggles dead zone types.
  471. /// </summary>
  472. private void ToggleDeadZone()
  473. {
  474. switch (DeadZone)
  475. {
  476. case GamePadDeadZone.IndependentAxes:
  477. DeadZone = GamePadDeadZone.Circular;
  478. break;
  479. case GamePadDeadZone.Circular:
  480. DeadZone = GamePadDeadZone.None;
  481. break;
  482. case GamePadDeadZone.None:
  483. DeadZone = GamePadDeadZone.IndependentAxes;
  484. break;
  485. }
  486. }
  487. /// <summary>
  488. /// Handles the exit ChargeSwitch fire event. Exits the application.
  489. /// </summary>
  490. private void exitSwitch_Fire()
  491. {
  492. this.Exit();
  493. }
  494. // #region Entry Point
  495. // /// <summary>
  496. // /// The main entry point for the application.
  497. // /// </summary>
  498. // static void Main()
  499. // {
  500. // using (InputReporterGame game = new InputReporterGame())
  501. // {
  502. // game.Run();
  503. // }
  504. // }
  505. // #endregion
  506. }
  507. }