我开发了一个可能在 XBOX 上运行的 UWP 应用程序。
我想检测是否已按下游戏手柄控制器上的按钮(ABX 或 Y)。
我想我需要使用点击事件?如果是在点击事件上,我需要在点击事件中检查什么?
查看这篇确定是否已按下触发器的帖子。
Windows UWP 中对 Xbox One 的控制器支持
/*
* 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
}
我认为有一种等效的方法可以检查是否按下了 ABXY 按钮之一?下次有机会我会检查的。
另一方面,这篇博文看起来对刚开始为 Xbox One 开发 UWP 的人非常有用http://grogansoft.com/blog/?p=1278
更新: 看起来我可以调用 GetCurrentReading() 来获取GamepadReading结构。并从中获取GamepadButtons的状态。