Skip to content

Unity Native Plugin to expose DirectX DirectInput ForceFeedback

License

Notifications You must be signed in to change notification settings

ATG-Simulator/Unity-DirectInput

 
 

Repository files navigation

Unity DirectInput Force Feedback

Made with Unity GitHub issues open GitHub issues close GitHub package.json version GitHub

Unity-DirectInput Banner

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 capabilites 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.

Quick Start

image

Installation

This package requires use of Unity's new Input System, ensure com.unity.inputsystem is installed in the project. Install it via the package manager via:

Window -> Package Manager => Input System

Next, install (copy and paste) the Plugin folder of this repo into the Assets folder of your Unity project. You can copy and paste the whole content, and Unity will automatically exclude the unrelated contents as their folder names have "~" characters. Those unrelated folders have the source code of the native Direct Input FFB DLL that Unity uses. Open the Sample Scene there and play the scene to start working with this asset.

Supported ForceFeedback Effects

Effect Supported
ConstantForce
CustomForce ℹ️
Damper
Friction
Inertia
RampForce
SawtoothDown
SawtoothUp
Sine
Spring
Square
Triangle

Note that everything is adjustable in the native DLL, And the Custom Force effect exists but has not been fully done.

Compatible Devices

Note that all the devices that use Direct Input (from the old Logitech G wheels to the advanced Simcube ones) should work

The community has tested and verified these devices do indeed work. Albeit not all devices support all the FFB effects!

Peripheral Test Status
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.

Environment

This plugin only works on Windows 8+ 64-bit.

Latest verified Unity version: 2022.2.1f1

Notice

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 the cause this issue, try disconnecting and reconnecting offending USB devices. For more information see this StackOverflow post about the issue from 2012. See issue #1 for more info.

Support

If you have problems, please raise an issue on GitHub.

License

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.

About

Unity Native Plugin to expose DirectX DirectInput ForceFeedback

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 72.7%
  • C++ 27.0%
  • C 0.3%