This package allows you to easily integrate both the input and ForceFeedback features of DirectX DirectInput from within Unity. This allows you to interface with HID peripherals with ForceFeedback capabilities. This can be used to build vivid simulated experiences.
The package will create a virtual device inside Unity's Input System. This device can then be used like any other device inside the Input System, allowing for easy rebinding. ForceFeedback capabilities can be accessed via the DIManager class. The DirectInputExplorer is a Windows Forms application built in parallel with the C++ library to enable quick development by avoiding the need to reload Unity after every change. It also functions as an easy way to examine DirectInput devices.
Prerequisite: This package requires the use of Unity's new Input System to ensure com.unity.inputsystem is installed in the project. Install it via the package manager:
Window -> Package Manager => Input System
, Recommended only to activate and use this Input System.
Step-by-step UPM installation:
- Prerequisites: Ensure you have Git client installed (minimum version 2.14.0)
- On Windows, add Git to your PATH environment variable
- Open Unity: Launch your Unity project where you want to install the plugin
- Access Package Manager: Go to Window > Package Manager in the Unity menu bar
- Add package: Click the + (plus) button in the top-left corner of the Package Manager window
- Select installation method: Choose "Install package from git URL" from the dropdown menu
- Enter Git URL: In the text box that appears, enter:
https://github.com/imDanoush/Unity-DirectInput.git
- Install: Click the Install button and Unity will download and install the package
Benefits of UPM Git installation:
- ✅ Direct installation from GitHub repository
- ✅ Automatic updates when you push new versions
- ✅ Clean project structure with proper dependency management
- ✅ Easy to share across team members
- ✅ Version control integration
If you prefer manual installation or don't have Git installed:
- Download the plugin package from the Releases section
- Copy the
Plugin
folder from this repository directly into your Unity project'sAssets
folder - Import the example UnityPackage included with the plugin
Regardless of installation method, restart Unity to ensure proper DLL loading and access to the new runtime UI features.
Note: Folders ending with
~
are excluded by Unity during import and contain the Windows ForceFeedback Explorer application located at./DirectInputExplorer~\DirectInputExplorer\bin\
for advanced device testing and configuration.
Effect | Stat |
---|---|
ConstantForce | ✅ |
Damper | ✅ |
Friction | ✅ |
Inertia | ✅ |
RampForce | ✅ |
SawtoothDown | ✅ |
SawtoothUp | ✅ |
Sine | ✅ |
Spring | ✅ |
Square | ✅ |
Triangle | ✅ |
CustomForce | ℹ️ |
Front Collision | ✅ |
Rear Collision | ✅ |
Left Collision | ✅ |
RightCollision | ✅ |
Note that everything is adjustable in the native DLL. The Custom Force effect exists but has not been fully implemented, and the collision effects are only in the Unity project. This is optimized to be used in the Unity Game Engine only.
Note that all the devices that use Direct Input (from the old Logitech G wheels to the advanced Simucube ones) should work
The community has tested and verified that these devices do indeed work. Albeit not all devices support all the FFB effects!
Peripheral | Test Status |
---|---|
Simucube Ultimate 2 | ✅ Verified |
Fanatec CSL DD (Both PC & Comp mode + 8NM Kit) | ✅ Verified |
Fanatec CSL Elite | ✅ Verified |
Fanatec CSW V2.0 | ✅ Verified |
Fanatec WRC Wheel Rim | ✅ Verified |
Fanatec Formula V2 Wheel Rim & APM | ✅ Verified |
Fanatec CSL LC Pedals | ✅ Verified |
Fanatec ClubSport Pedals V1 | ✅ Verified |
Fanatec ClubSport Pedals V3 | ✅ Verified |
Fanatec ClubSport Shifter SQ V 1.5 | ✅ Verified |
Logitech G29 / G920 | ✅ Verified |
Moza R9 | ✅ Verified |
PRO Racing Wheel | ✅ Verified |
Simagic Alpha-Mini | ✅ Verified |
Thrustmaster TX | ✅ Verified |
Note for pedals, only input readings were guaranteed to likely work fine.
- Any Unity version that is using the .NET C# v5 should work
The DirectInputManager should run on Windows 10 22H2 and newer (e.g., Windows 11) out of the box. The DirectInput API is available on these modern Windows versions without additional packages.
For developers working on the project:
- Visual Studio 2019 or newer
- .NET 5 SDK
- Windows SDK (for DirectInput headers)
- Microsoft Visual C++ Redistributable
- C++ build tools if modifying the native DLL You may need to enable "allow unsafe code" in the Player Settings of your Unity project to build your game, or not - not tested.
For end users running the built application:
- Microsoft Visual C++ Redistributable
- .NET 5 Runtime
- Windows 10 22H2 or newer (Can be used in Windows 7+ theoretically, but not tested)
- The DirectInputForceFeedback.dll must be properly deployed alongside the application
- No special DirectX installation is required on modern Windows, as DirectInput is part of the OS The project provides force feedback support for DirectInput-compatible devices like joysticks, wheels, and game controllers. It's designed to work both as a standalone .NET application and within Unity projects.
For Unitypackage, if you do not have some SDKs installed, you may get an error stating that the DLL is not found. To solve that issue, do the following:
- Clone the DirectInput repository,
- Then go to the
/DirectInputForcefeedback~
folder, where there is a.sln
Visual Studio project file,- Open it and press F5 in VS to build a new DLL, where you'll be asked to install the missing SDKs
- The newly built DLL will be available in the directory specified by the
output
setting in Visual Studio, then copy it from where it was created, and paste it over the DLL in Unity'sAsset/Plugin
folder for Direct Input. However, this step should be done by Visual Studio after a build by itself.
Important Note: This plugin was designed primarily for standard direct input wheelbases as well as steering wheels. Thus, it supports force feedback on the first/primary axis of FFB-capable devices.
While the code enumerates all available FFB axes and includes them in effect definitions, the current API functions do not provide individual control over secondary axes.
To properly support multiple FFB axes, the API would need to be extended with functions that:
- Allow setting different direction values per axis in the
rglDirection
array - For condition effects, provide access to all elements in the condition array (not just
cond[0]
) - Include axis index parameters in the update functions
These enhancements would enable support for devices with multiple force feedback axes, such as dual-motor joysticks or specialty controllers.
Occasionally, calls to EnumerateDevices will take orders of magnitude longer than usual to execute (up to 60 seconds). This is caused by a Windows bug attempting to load an absent hardware device. USB Audio DACs & Corsair keyboards are known to cause this issue. Try disconnecting and reconnecting the offending USB devices. For more information, see this StackOverflow post about the issue from 2012. See issue #1 for more info.
The original fundamentals coded by Mr.TimCakes, though, got significantly changed.
This project is free Open-Source software released under the LGPL-3.0 License. Further information can be found under the terms specified in the license.