I've developed a UWP app that could potentially run on XBOX.
I want to detect whether the buttons on the gamepad controller have been pressed (either A B X or Y).
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?
Looking at this post which determines whether a trigger has been pressed..
Controller support for Xbox one in Windows UWP
/*
* 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
}
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.
On another note, this blog post looks really useful for people starting out with developing UWP for Xbox One http://grogansoft.com/blog/?p=1278
Update : Looks like I can call GetCurrentReading() to get a GamepadReading structure. and from that get the state of the GamepadButtons.