Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Generic Force Feedback

Discussion in 'Input System' started by devandart, Jun 14, 2017.

  1. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    Hi guys,

    I'm trying to get generic Force Feedback working for a few days now.
    I found many "half baked" or not working solutions and also tried to extend/fix them but it doesn't work.

    I tried SharpDX and some c++ DirectInput wrappers.

    What I need is
    • Support Generic Steering Wheels
    • 64 Bit
    • Damping (this is the only one working in my solution)
    • Bumpy Surface
    • Slippery Surface
    • Frontal Collision
    • Side Collision
    I also found the Force Feedback Controller Toolkit in this forum but I don't get an answer and the dev wrote in it's Thread, that it's 32 Bit only.
    Do you know if there is any production ready solution like the Logitech SDK but also for generic steering wheels?

    Regards
     
  2. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    I do believe the Logitech dll supports all "Windows" recognized wheels. I have been using it with a Thrustmaster T500 for a couple years now....... But I am also seeking a new solution for ALL Generic Axis "rotating" Steering wheels. Windows and Linux. I mean how hard can it be right? (6 years later....lol).

    Currently, Im using the Logitech dll for an Steam game and its still a little "touch and go". Not connecting sometimes, Crashing when setting any global settings, Losing focus makes the wheel lose connection..... etc etc etc.. Im still not happy. I mean I have customers that are Thrustmaster users that have to install Logitech software (A competitor) on their system to just get the dang thing to work. :/

    I saw you posted in the other thread about the Logitech. I'll look at the Zip you posted and report back anything I find here.

    I also saw that the Unity team is finally starting the new "Input system". Maybe this FFB issue is something more people can ask them about. I think I all about wore out my welcome on complaining about the old tired Unity Input system for the last 6 years.

    Kevin
     
  3. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551

    Are you using the Logitech dll from Logitech's Unity asset store package or from the Logitech SDK from the Logitech website? What version are you using?

    Does it work with all ThrustMaster wheels that you know about or just the T500?

    @guavaman
     
  4. Wim-Wouters

    Wim-Wouters

    Joined:
    Sep 26, 2012
    Posts:
    36
    Any progress with FFB here?
     
  5. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    He never answered I wonder if Devotid was telling the truth about it working with all wheels. I find it hard to believe that Logitech would write software that can be used by purchasers of their competitors products. I say this because the SDK is not recognizing my Driving Force Pro which is the wheel released right before the G-Series. Also it states on the asset store that is for G-Series products only. I hope I am wrong though, otherwise I will be forced to learn and write my own DirectInput wrapper.
     
  6. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    Why would I lie about that? haha Come on bud.

    There is videos of me Driving my old DSeries game from 7-8 years ago with a G500 Thrustmaster.

    Just email me at devotid@gmail_DOT_com. Ill give you any code I have to help you out. I dont read these forums much at all anymore.
     
  7. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Thanks but I'm beginning to think that Logitech SDK is just not universal, maybe its only for 32 bit Windows I have 64 etc. Also don't they have to keep updating the SDK for current versions of DirectX? I'm not really sure but thanks.
     
  8. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @devotid is a long time racing wheel issue chaser. The benefit on having games on steam to chase customer issues with a variety of racing wheels. It is even more exiting on racing wheels you do not have personal access to. I would definitely trust his judgement based on real world experience with trying to find solutions in that space.

    The Logitech SDK at least the C++ versions were usually very specific on what products they supported. Many of those issues are also tied to a specific Microsoft Visual Studio version. So if the that version of visual studio is not supported anymore that is also a factor to think about.

    I expect that it would best to write your own DirectOutput/FFB wrapper so you can handle more of the use cases you need to support.
     
    Last edited: Jul 19, 2020
  9. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    Yeah... I simply gave up with DirectX, Direct Input, Logitech SDK's, Force Feedback and steering wheels. It was just too many variables and crazy custom setups to support. I made two games over 6 years before I learned to just make a game for mouse and keyboard. The problem is the only people that know how to make all the FFB stuff work are already making their own games and not interested in sharing too much info.

    So you are essentially on your own using old outdated SDK's and such.

    I wish you luck! Sincerely.
     
  10. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I know what you mean. I like the driver/firmware combination updates that always changed how the Racing Wheel worked underneath you. :(

    Thankfully flight controllers are much nicer for the most part.

    Thanks again for your sharing your knowledge on this subject.
     
  11. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    There are currently few ways to use Logitech Steering Wheel SDK on generic directinput wheel regardless of the brand:

    1) Use latest Logitech Steering Wheel SDK from their own site and make your customers install Logitech G Hub as it unlocks other brand wheel support on the current Logitech SDK (it's a silly setup but it works). Their SDK ships with C# wrapper and dll's

    2) Get the same SDK as above but grab SDK dlls from older Logitech installer like LGS_9.02.65_x64_Logitech.exe which is available on Logitech's support page for Logitech G920. DLLs are in folder C:\Program Files\Logitech Gaming Software\SDK\SteeringWheel. Use with c# wrapper from latest official SDK on their site. There's a small naming difference on the SDK DLL's so you need to either rename DLLs or modify the C# wrappers DLL naming. This approach works without your customers needing to install Logitech G Hub on their system.

    3) Install LGS 5.10 for Logitech G27 / G25 and navigate to C:\Program Files\Logitech\Gaming Software and grab Logitech_SDK_For_PC_1.00.002.zip. This has Logitech Steering Wheel SDK with full c++ sources. This SDK works with all brand wheels as is but there's no c# wrapper for it. You either need to replicate the newer SDK API and build this to DLL or do some other wrapper yourself.

    With all three cases, you can still use the Asset Store's Logitech SDK wheel test script for testing, just modify the few lines that change with the newer C# wrapper. You also don't need to own any Logitech wheels to be able to install the mentioned Logitech software.

    Alternatively, if you only need constant FFB forces (no road effects etc), you can look up FFConst.cpp from Microsofts DirectX Samples and wrap it to Unity (or tweak this one that already did it: https://forum.unity.com/threads/force-feedback-for-windows.78268/)

    Edit: I also stress that last two cases don't require your customers to install any kind of logitech software on their system (unless they actually have Logitech wheels), only newest Logitech SDK dll's add the G Hub requirement for other brand wheel support.
     
    Last edited: Aug 14, 2020
    Meceka and devotid like this.
  12. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    What other brand racing wheels have you tested using the Logitech SDK? Did you test ThrustMaster 500, 300, 150 and TX racing wheels?

    What about visual studio differences? The SDK is written against Visual Studio 2010 and I expect most people are using Visual Studio 2015 or later.
     
  13. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I have tested this on a windows 10 computer where I've never installed any logitech software whatsoever and with Thrustmaster TX. I also have Logitech G25 and Momo here but they both are supported by SDK anyway. If you look at the SDK source code from G27 SDK package (alternative 3 above), it's pretty clear it's just stock directinput FFB implementation, there's NOTHING device specific on the actual FFB and input code so it should work as is on all wheels that support directinput (actual test app from the SDK does some additional things to detect the wheel types and sets some FFB multiplier based on them which caused issues on my TX wheel but this was test app specific, nothing that prevented the actual library from working and I could also easily fix the FFB for the test app there too).

    There are few Logitech specific functions on the Wheel SDK, like logitech model getter which is hardcoded to detect specific logitech wheels but the API also lets you just get the device path so you can build the same info from PID and VID info yourself on c# side. This is purely informational thing and doesn't affect input or FFB itself. Of course if you go with the G920 DLL's, we don't have full source code for them but my testing shows that Logitech hasn't gimped the SDK at that point yet. Latest official SDK from their site has. Also worth noting that newer SDKs (both G920 and latest on their site) also has functions for steering ratio that is Logitech specific implementation. But this apparently also isn't done via DirectInput either as there's no DI API for even implementing this (so it probably has to be manufacturer/driver specific implementation anyway).

    This doesn't really matter. At most the DLLs could require specific VC++ redist for the final installation for the native plugin to work. I haven't tested if these prebuilt DLLs require it but they are notably bigger in size than the DLL shipped with say, Unity Asset Store SDK's DLL so this could mean they embedded the required files already. When I tested on other windows 10 machine, I didn't have to install any additional redists but it's possible I already had some installed there. If you build from sources yourself (alternative 3), that SDK also converts to VS2019 just fine on my testing + you can link these yourself without redist dependency (so it just embeds the needed files into DLL) if you want to write the wrapper yourself.
     
    Last edited: Aug 17, 2020
    devotid likes this.
  14. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    Thank you @rz_0lento for this great information.

    We have been using the 1st case, some users could use other steering wheels like Thrustmaster perfectly fine while some had only damper force in an incorrect way, I think it makes sense that some of them may have G-Hub installed so those work perfectly fine.

    From your post on Thursday, case 2 looks like a more sensible choice, but is there a disadvantage of that setup compared to case 3?

    I mean, why do you prefer case 3 over 2? It looks more time-consuming from your post.

    Thanks.
     
  15. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    #2 seems to work fine on my testing and is easiest alternative, it's drop in replacement so should be easy to test. #3 does give you full c++ source code so you could expose more functionality to it + you know exactly what happens underneath as there's no black box.

    Additionally, out of the box option #3 lacks these three functions: GetDevicePath, SetOperatingRange and GetOperatingRange

    You should be able to rebuild these if needed to (afaik range is part of controller properties and device path data exists elsewhere: sdk uses it to detect specific logitech models).
     
    Last edited: Aug 19, 2020
    devotid and Meceka like this.
  16. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    Thanks again @rz_0lento

    I am currently testing case 2 and seems like it's working well, but there are two problems.

    1) Sometimes the game is crashing when calling LogiIsConnected(). I couldn't understand when the crash occurs, seems totally random. It also happened on a computer that doesn't have a steering wheel.
    On the only crash log I have, LogiSteeringInitialize is called before that function and returned false, but didn't cause a crash.

    This is visible in the stack trace.

    0x00007FF83BA2ACC9 (LogitechSteeringWheel) LogiIsConnected
    0x00007FF80E54AA90 (GameAssembly) WriteZStream
    0x00007FF80E54F5F4 (GameAssembly) WriteZStream
    ERROR: SymGetSymFromAddr64, GetLastError: 'Es wurde versucht, auf eine unzulässige Adresse zuzugreifen.' (Address: 00007FF80E27FABC)
    0x00007FF80E27FABC (GameAssembly) (function-name not available)
    ...

    I have a crash dump but can't debug it because there isn't a .pdb file. But this crash didn't happen before downgrading to the older dll in case 2.

    2) This issue was also happening with the newer SDK. With very old steering wheels like G25, in Logitech's website it recommends very old Logitech software.
    And for some reason, when those software are used, in our game steering range gets limited to 90 degrees. And force feedback applies torque to stop it from rotating more.

    Enabling "Allow Game To Adjust Settings" toggle in the software fixes the issue for some people.

    I've tried using "LogiSetOperatingRange" function to manually set it but it always fails with my G29. Does anyone know a way to fix this? (I didn't yet test this function with new SDK)
     
  17. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    One downside of the Logitech Steering Wheel SDK is that it doesn't do failsafe checks on it's own. Meaning if you try to access the wheel SDK without it being properly initialized, it will hard crash.

    This is easily fixed on your part though, ALWAYS make sure the lib is successfully initialized before polling any values from it. How I've done this myself is that I've stored a initialization boolean I got from running the LogiSteeringInitialize. Then always check on Update if the boolean I have for this has been set before trying to read anything else from the SDK - if not then just bypass the further SDK operations. Finally when/if you call LogiSteeringShutdown, always in addition mark the initialization boolean to false manually. This fixes all crashes in case the SDK couldn't been initialized and also on app shutdown.
     
    Last edited: Sep 5, 2020
  18. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I'm not sure if that is actually properly implemented on the option #2 but you can definitely use LogiSetPreferredControllerProperties, it allows you to bypass all settings like default spring, combine pedals, ffb, range etc. That being said, the option #2's DLL didn't seem to return any real values with Controller Properties getter on my G25 (could be just incompatibility between the DLL and older LGS required for my G25) but the setter definitely works. I guess one could try to play with tad older SDK dll's if the getter is really needed to work for all devices (or just wrap the old c++ SDK manually as it can definitely read these).
     
    Last edited: Sep 5, 2020
  19. WalterAnthony

    WalterAnthony

    Joined:
    Apr 10, 2018
    Posts:
    8

    https://github.com/MrTimcakes/Unity-DirectInput
    There seems to be a universal way to connect the force feedback steering wheel now, and although the SDK of the logitch can be used, it is not stable.
     
  20. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    That was 7 years ago. haha. But thank you. I havent touched a FFB wheel in a LONG time. I cant believe Unity STILL hasnt made something like this standard practice yet. Sad. They promised it 10 years ago "right after we finish mobile gaming."