1
我开发了一个可能在XBOX上运行的UWP应用程序。如何在UWP应用程序中检测游戏控制器按钮(ABXY)
我想检测游戏手柄控制器上的按钮是否被按下(A B X或Y)。
我想我需要使用点击事件?如果它在点击事件上,我需要在点击事件中检查什么?
综观此篇其确定触发是否已经按下..
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
}
我假定有检查ABXY按钮中的一个是否被按下的等效方式?我将在下次有机会时检查。
在另一方面,这篇博客文章看起来真的有用的人与发展中国家UWP为Xbox一个http://grogansoft.com/blog/?p=1278
更新开始了: 看起来我可以调用GetCurrentReading()得到一个GamepadReading结构。并从中获得GamepadButtons的状态。
嗯好的。我也会尝试。我或你的方法中哪一个是普遍接受的方法? (我还没有测试过我的方法)。 –
我认为你的方法太复杂了,无法获取按钮是否被点击的信息。它会在游戏和我认为的这样的事情中更有用。 –