Search code examples
c#xnawindows-10xbox360

How to connect an xbox360 controller to a desktop app (C#, Windows 10)


I am looking to write a simple app which accepts input from an Xbox 360 controller. I am developing in C# and my current dev environment is a windows 10 machine.

I've attempted to install XNA studio 4.0, and got a system notification saying that it isn't supported. When I clicked on the notification for more info, I was redirected to a webpage which started a Windows Live Gaming installer download.

This seems to rule out XInput.

I thought my alternative was to use the Windows.Gaming.Input namespace, but it seems to be limited to metro apps.

I don't know what are my other alternatives.

What is the correct library for me to be using, and where do I download it from?


Solution

  • XINPUT will read the Xbox One controller with the drivers currently on Windows Update, but you will be unable to access the 'impulse trigger motors' using that API. For C# usage, look at SharpDX or SlimDX.

    You can use Windows Runtime APIs from desktop apps including Windows.Gaming.Input. They key is you have to initialize WinRT with Windows::Foundation::Initialize.

    See DirectX Tool Kit: Now with GamePads. If you were writing in C++, I'd also recommend looking at the DirectX Tool Kit GamePad class.