speps / XInputDotNet

C# wrapper around XInput, works with any Mono or .NET application (eg. Unity3D)
464 stars 96 forks source link
c-sharp unity3d xbox-controller xinput

XInputDotNet

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 :

Examples

Some examples are available in this repository :

Using with Unity

Unity

Building errors

error CS1704: An assembly with the same name `XInputDotNetPure' has already been imported.

If you get this error, or a similar one, make sure the settings for each file matches the settings below.

For Plugins\x86\XInputInterface.dll

Plugin settings for x86 DLLs

For Plugins\x86_64\XInputInterface.dll

Plugin settings for x86_64 DLLs

For Plugins\XInputDotNetPure.dll

Plugin settings for AnyCPU DLLs

Special instructions for Free version of Unity

NOTE: this is needed only for Unity 4, Unity 5 seems to have the right behaviour

NOTE : you may see this error message but it should still work as expected, the message won't appear in a Build

License Error Message

Notes