skaughtx0r redid this, source is on git. Thanks to everyone helping fix this.
Hi, we’re working on a vehicle simulator, so one of the things we need is force feedback (eg steering wheels). The Unity input system doesn’t have it, so here it is
It’s a PRO only feature as it’s a C++ plugin which uses DirectInput.
This is a first successful test but it needs some work. The show stopper at the moment is a crash bug. It’s a weird one, where the FIRST time you run it in the Unity editor, it runs fine. You click stop, then if you click play again, Unity will crash. Odd. I presume it’s some cleanup issue but I can’t find it. Any help would be great.
It’s a modification of the DirectX June 2010 SDK DirectInput FF sample.
ps Unity, can we please get script access to the input system?
I fixed your issue with the plugin. You did not reset the number of axis to zero before enumerating them, so at the second launch, you tried to create the effect with double the axis which are available, leading to E_INVALIDARG. The subsequent call on the uninitialized effect pointer leads to the access violation that crashes Unity.
Edit: Btw, you can make a debug build of the plugin, copy that to the Assets folder and then attach the Visual Studio debugger to Unity. You can then set breakpoints in the plugin.
Beautiful! I wasn’t looking forward to tracking that down. I’ll test it and if it works I’ll stick it up on the Asset store for free, not worth charging for I think. Give me a PM with your real name and I’ll put a note in the header if you’d like
It really wasn’t a big deal, at least with the debugger. Stepping through the code, I noticed the wrong number of axis at the second initialization. I also changed the cooperative mode to background, which should still work for most joysticks and wheels, and the acquisition stays when the window focus is lost. Note in the header is not necessary, but thanks.
Hi !
Force feedback work well ! … the first time !
Vectrex, can you please update the zip with Graealex fix ? I don’t know anything about visual studio.
Got a 2nd question :
the wheel rotation is 180°, how to have the full 900° of G25/27 ?
To get the full 900° rotation with G25/G27 use the Logitech Gaming Software Profiler and use the properties of the steering wheel to set to full range.
If you have problems with the DLL, either download and install “Microsoft Visual C++ 2010 Redistributable Package”, or download this static build that doesn’t require the MSVCRT libraries.
Hi,
I put the library in my project using unitycar but the force feedback only works on the unity of the game window. When I create the build the force feedback does not work.
I’m using the InputManager unitycar.
Anyone know if I need to do some special configuration?
It’s working fine on both of my steering wheels in the latest version of Unity. The only times it has ever crashed for me is when I run it without the force feedback device plugged in.
However, I wish more parameters from the device could be exposed.