问题
I am wondering how I am supposed to handle input for UWP apps targeting Xbox One. I have noticed DirectInput, but I see two issues with it for my use cases:
From MSDN, it only seems to support Xbox 360 controllers
XInput is an API that allows applications to receive input from the Xbox 360 Controller for Windows. Controller rumble effects and voice input and output are supported.
DirectX and all of its API's (Direct2d, Direct3D, Xinput, etc...) are only supported on C / C++. That means even if Xinput supported Xbox one controllers, I could not use C# or JavaScript to develop truly universal apps.
What options do I have (at least as far as C# is concerned) for supporting Xbox One controller support on a Windows UWP app?
回答1:
Take a look at the Windows.Gaming.Input namespace. Its GamePad class is in the Universal API contract and available on all device families and languages.
回答2:
To back @Rob Caplan - MSFT with a source, this blog from the Microsoft Developer Network states:
Windows 10: There is a new WinRT API in the Windows.Gaming.Input namespace for universal Windows apps. This API supports both the Xbox 360 Common Controller and the Xbox One controller, including access to the left/right trigger motors. The latest version of GamePad is implemented using this new API when built for Windows 10. Note that existing XInput-based Windows Store applications can link against xinputuap.lib which is an adapter for the new API for universal Windows apps--this adapter does not exist headset audio either.
回答3:
DirectX and all of its API's (Direct2d, Direct3D, Xinput, etc...) are only supported on C / C++
Only natively supported, yes, but implementing DirectInput from C# is trivial using SharpDX
However, DirectInput is not much use for reading XB controllers as the trigger axes are merged into one, and it's impossible to differentiate between no triggers held and both triggers held.
来源:https://stackoverflow.com/questions/31977767/controller-support-for-xbox-one-in-windows-uwp