title: How to detect game controller button presses (ABXY) in UWP apps
body: <p>I've developed a UWP app that could potentially run on XBOX.</p>
  
  <p>I want to detect whether the buttons on the gamepad controller have been pressed (either A B X or Y).</p>
  
  <p>I think I need to be using the click event? If it is on the click event, what do I need to check in the click event?</p>
  
  <p>Looking at this post which determines whether a trigger has been pressed..</p>
  
  <p><a href="https://stackoverflow.com/questions/31977767/controller-support-for-xbox-one-in-windows-uwp">Controller support for Xbox one in Windows UWP</a></p>
  
  <pre><code>/*
   * Note: I have not tested this code.
   * If it is incorrect, please do edit with the fix.
   */
  using Windows.Gaming.Input;
  
  // bla bla bla boring stuff...
  
  // Get the first controller
  var controller = Gamepad.Gamepads.First();
  
  // Get the current state
  var reading = controller.GetCurrentReading();
  
  // Check to see if the left trigger was depressed about half way down
  if (reading.LeftTrigger == 0.5;)
  {
      // Do whatever
  }
  </code></pre>
  
  <p>I presume there is an equivalent way of checking whether one of the ABXY buttons have been pressed?. I shall check next time I get chance.</p>
  
  <p>On another note, this blog post looks really useful for people starting out with developing UWP for Xbox One <a href="http://grogansoft.com/blog/?p=1278" rel="nofollow noreferrer">http://grogansoft.com/blog/?p=1278</a></p>
  
  <p><strong>Update :</strong> 
  Looks like I can call GetCurrentReading() to get a <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.gaming.input.gamepadreading.aspx?cs-save-lang=1&amp;cs-lang=csharp#code-snippet-1" rel="nofollow noreferrer">GamepadReading</a> structure. and from that get the state of the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.gaming.input.gamepadbuttons.aspx" rel="nofollow noreferrer">GamepadButtons</a>.</p>