InControl support XInput on Windows by wrapping XInput.NET. XInput provides a few distinct advantages for compatible controllers:
- It supports faster input polling than Unity's
Update()loop which may be desirable for using input in physics update.
- It bypasses Unity entirely, which can avoid certain bugginess Unity has with XInput controllers, although many of these issues have been fixed in versions 4.6.3 and 5.0.2
- It supports haptic feedback through two API calls on
public void Vibrate( float leftMotor, float rightMotor ); public void Vibrate( float intensity );
XInput support for InControl is disabled by default. To enable it check the option in the
InControlManager component inspector.
As of version 5, Unity has a new way of handling plugins, the Plugin Inspector. The latest version of InControl has both the 32 bit and 64 bit version included in the
InControl/Plugins folder. Unfortunately, the correct settings for the inspector do not seem to be included when packaged for the Asset Store, however it’s a simple process to set up each DLL correctly:
To use XInput with Unity 4, follow the instructions for using XInput.NET. Essentially, place
XInputInterface64.dll next to your .exe file and in the root of your Unity project (for running in the Unity Editor).
Make sure you are using the correct DLL build for your architecture. Some have had a problem with the version(s) included with InControl, although in recent releases both versions are included in the asset and renamed accordingly.
If you wish, you can grab the latest builds directly from the XInput.NET project releases page.
You will also need to ensure you have DirectX installed, and in particular
XInput1_3.dll is required. On some versions of Windows, the version of DirectX installed by default is too old, so make sure you upgrade DirectX if you’re having problems.
There are two advanced settings when XInput is enabled:
Update Rate and
Buffer Size. In almost all cases you’ll want to leave both as
0 which lets InControl determine sensible defaults.
For performance efficiency, InControl polls XInput state on a background thread. The
Update Rate determines how often this polling occurs. It defaults to using the fixed update rate.
Buffer Size determines how many state snapshots the background thread hangs onto in a ring buffer. In some cases when using input in physics steps it may be desirable to use a small buffer as Unity calls several fixed updates bunched up at the end of a standard update instead of spreading them out smoothly over each frame. The buffer set to the approximate size of these bunches allows for smoother input values over these fixed updates at the expense of a tiny amount of latency. This is mostly an experimental setting and is best left disabled (which is the default) unless you truly understand and care about it what it does.