godot-proposals
godot-proposals copied to clipboard
Add support for force feedback in steering wheels
Describe the project you are working on
I'm start to project game where you travel in Pernambuco's countryside.
I already write godot flavor with force feedback. It work on windows and linux, with respective direct input 8 and ioctl for linux. I published branch and example on itch.io. 6 people downloaded it.
https://cairerocha.itch.io/godot-force-feedback-example-ffb
Describe the problem or limitation you are having in your project
The game engine can't apply force in logitech G29 device.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add input methods to apply force, like rumble in xbox controller.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
func _on_ConstantForce_pressed():
Input.constant_force_feedback(deviceID, force * direction, duration)
# cw is clock-wise coefficient, ccw is counter clock-wise
func _on_Spring_pressed():
Input.spring_force_feedback(deviceID, cw, ccw, offset, duration)
func _on_Friction_pressed():
Input.friction_force_feedback(deviceID, cw, ccw, duration)
func _on_Damper_pressed():
Input.damper_force_feedback(deviceID, cw, ccw, offset, duration)
func _on_Inertia_pressed():
Input.inertia_force_feedback(deviceID, cw, ccw, offset, duration)
func _on_Stop_pressed():
Input.stop_force_feedback(deviceID)
If this enhancement will not be used often, can it be worked around with a few lines of script?
Dechode already tried it, but there several issues in this approach.
Is there a reason why this should be core and not an add-on in the asset library?
There will be nice if someone can run it as add-on, but gdscript can't acess this.
I support this in principle, but I have similar concerns as https://github.com/godotengine/godot-proposals/issues/2829. Is it possible to reasonably support the majority of steering wheels out there without needing lots of maintenance work on our end, considering there are no plans to use SDL in its entirety? This requires OS-specific code after all, as evidenced by your use of DirectInput and ioctl.
It has been discussed that we could copy SDL's input code where relevant and using it in Godot to support things like https://github.com/godotengine/godot-proposals/issues/2829, but this is still challenging to do (and keep up-to-date with newer SDL versions).
Edit: Using SDL only for input could also be an option.
@Calinou thanks to answer. Both ioctl and DirectInput is out of date, with bad documentation, that bring some technical deficit. I will study more about SDL2 to copy code and continue feeding my branch. Who need this feature could just download it.
@x-channel What do you mean by "ioctl is out of date"?
On Linux, ioctl is the generic interface every supported wheel uses. No need to use SDL. SDL acts just as a wrapper for ioctl. I see we're already using ioctl for the rumble effect in gamepads, so it would only need to be extended for more effects.
I don't know about Windows. DirectInput provides generic FFB support but I don't know if it's really out of date. Many games still use it so I'm not sure if it's out of date or it's just not the newest API. I quick look at UWP and it seems that generic FFB it's included.
I don't think SDL is needed for this, the same way it wasn't needed for vibration in gamepads.
I don't think SDL is needed for this, the same way it wasn't needed for vibration in gamepads.
It looks like we may be switching to SDL for input in the long run anyway, since it fixes a lot of issues with gamepads: https://github.com/godotengine/godot/pull/87925
@x-channel is there any update on the topic, I'm currently trying to implement force feedback as well in my demo. Perhaps your code could be put into a module to make the feature available?
@x-channel is there any update on the topic, I'm currently trying to implement force feedback as well in my demo. Perhaps your code could be put into a module to make the feature available?
Hello Simon, there not way to turn It in separated module. My proposal is Just update in input module for produce less junk and keep ALL haptics in same module. Them both vibration and Constant force belong tô same namespace.
Now i don't remember each module that i rewrite. But you could find It If you compare filé sizes from my version with same file from official version.
SDL3 is now used in the engine for input, making cross-platform force feedback a lot simpler. Could it now be possible to bring the haptic subsystem to the engine?
Basically implement wrapper functions in the Input class to the SDL haptic functions listed in the SDL3 wiki page i linked.
SDL3 should make this a lot easier indeed, but I don't know to which extent it can replace the need for specific SDKs.
When I look around in simracing games, it's very common that they plug into vendor-specific SDKs (e.g. Fanatec) to provide FFB presets and stuff like that. (There are also a few extras, e.g. displaying the current speed/gear/RPM on a display that's on the steering wheel, but these are not critical.)
In short, how usable is a generic SDL3 implementation in practice? I don't expect this will resolve the OS issue, as most simracing gear these days seems to be largely Windows-only if you want a good experience (while much of Godot's community is on Linux). Still, I wonder if SDL is good enough to not require vendor-specific SDKs (which are all proprietary to my knowledge).
I have a simracing setup to test (Fanatec CSL DD). I also have a Thrustmaster T248 lying around but only the wheelbase + steering wheel; I no longer have its pedals.
cc @Nintorch
Interesting, I didn't know steering wheel controllers had vibration/force feedback :D I haven't used SDL's haptic subsystem before, but the example code looks simple enough, I think it shouldn't be hard to implement it, I'll see what I can do later!
SDL3 should make this a lot easier indeed, but I don't know to which extent it can replace the need for specific SDKs.
When I look around in simracing games, it's very common that they plug into vendor-specific SDKs (e.g. Fanatec) to provide FFB presets and stuff like that. (There are also a few extras, e.g. displaying the current speed/gear/RPM on a display that's on the steering wheel, but these are not critical.)
In short, how usable is a generic SDL3 implementation in practice? I don't expect this will resolve the OS issue, as most simracing gear these days seems to be largely Windows-only if you want a good experience (while much of Godot's community is on Linux). Still, I wonder if SDL is good enough to not require vendor-specific SDKs (which are all proprietary to my knowledge).
I have a simracing setup to test (Fanatec CSL DD). I also have a Thrustmaster T248 lying around but only the wheelbase + steering wheel; I no longer have its pedals.
cc @Nintorch
I have a Logitech g29 and SDL2 haptics works with it nicely on both Windows and Linux. Or atleast the constant effect does, i have not tested other effects. SDL3 should be at least on par with SDL2. With all the effects SDL supports, i think it would be good enough for atleast a basic simracing game, if not even a bit more advanced as well.
Interesting, I didn't know steering wheel controllers had vibration/force feedback :D I haven't used SDL's haptic subsystem before, but the example code looks simple enough, I think it shouldn't be hard to implement it, I'll see what I can do later!
Awesome to hear! If and when you need testers, i can try the code with g29 and linux combination.
I have a Logitech G29 too, and I could test it on Linux. Logitech wheels are supported on Linux but the mainline module for most models only supports a constant force. I've worked on an improved module that supports more effects in new-lg4ff, mostly used to play Windows games on Proton that wouldn't have FFB otherwise because of the missing effects.
JacKeTUs linux-steering-wheels page has info on wheel support for Linux. There are three groups of devices, the ones using custom modules, the ones using HID++, and the ones using PIDFF. There's a custom module for Logitech devices included in the kernel that only supports a constant force, and other custom modules can be installed for Logitech, Thrustmaster and Fanatec that add FFB. There's a HID++ driver used for the G920, that should work for the G923 XBox and Logitech G Pro too. The PIDFF module implements a standard for FFB that works with many wheels but needs to be patched to work for some models.
So while many wheels can work on Linux, it's not plug-and-play in most cases. On Windows I guess there's no such problem and every wheel should work. I'm talking about the inputs and FFB, other features will require proprietary SDKs as Calinou said. I don't know about Mac.
I have used the aforementioned Dechode's plugin successfully in Windows (10) and Linux (Mint) with an ancient Logitech Driving Force GT and could also test the "native" FFB-support with it.
This wheel seems to need Oversteer ( https://github.com/berarma/oversteer ) in Linux to get over +-90 deg input range and "Logitech Profiler" (or, according to wikipedia "Logitech Gaming Software") in Windows to get FFB working, though.
BTW: Driving Force GTs can be found dirt cheap nowadays (cheapest ones seem to be 25€ on a local (Finnish) online flea market). So if someone just needs something to test FFB on, this wheel might be an option.