C# wrapper around XInput, works with any Mono or .NET application (eg. Unity3D).
What is XInput?
XInput is a DirectX API to manage the controllers connected to a PC (the same API is also used on Xbox 360). It allows an Xbox 360 controller to be used on a Windows PC.
What is XInput.NET?
XInput.NET is a .NET library which wraps the functions of XInput. It is different from what you can find inside SlimDX for example because it is designed to be pure CIL. That means you can use it in Unity3D Free (as well as Pro of course). The API was designed to be very similar (if not identical) to the GamePad class from XNA.
Ready to go !
Pre-built binaries are available from the releases tab :
- XInputDotNetPure.dll, .NET assembly containing the GamePad class
- You need to add a reference to this one in your C# project for example
- XInputInterface.dll, utility DLL which makes the calls to XInput
- You have to copy this one next to your .exe
Some examples are available in this repository :
- XInputDemo.exe, small console application for the most simple use of the API
- XInputReporter.exe, visual debugging aid for seeing the values from the controller
- XInputUnity, Unity 4 project rotating a cube with the pad and changing colors
Using with Unity
- Download the latest
XInputDotNet.unityPackagefrom the releases tab
- Open the menu Assets > Import Package > Custom Package and select the package you just downloaded
- See XInputTestCS.cs for a basic usage example
- Import the .unityPackage as described above
- Making a Build does NOT require to copy
XInputInterface.dllin the same folder the your game .exe file
NOTE : you may see this error message but it should still work as expected, the message won't appear in a Build
- Under Windows XP, you'll need special drivers for your Xbox 360 Controller. You can find them at this address : XBox 360 Controller for Windows Software
- You'll need the latest DirectX SDK to compile it, the binaries were built with the June 2010 version.