Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for force feedback in steering wheels #8309

Open
x-channel opened this issue Oct 30, 2023 · 6 comments
Open

Add support for force feedback in steering wheels #8309

x-channel opened this issue Oct 30, 2023 · 6 comments

Comments

@x-channel
Copy link

x-channel commented Oct 30, 2023

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.

Dechode
/
Godot-FFB-SDL

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.

@Calinou Calinou changed the title Force Feedback - FFB Add support for force feedback in steering wheels Oct 31, 2023
@godotengine godotengine deleted a comment Oct 31, 2023
@Calinou
Copy link
Member

Calinou commented Oct 31, 2023

I support this in principle, but I have similar concerns as #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 #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.

@x-channel
Copy link
Author

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

@berarma
Copy link

berarma commented May 18, 2024

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

@Calinou
Copy link
Member

Calinou commented May 19, 2024

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: godotengine/godot#87925

@Silom
Copy link

Silom commented Sep 18, 2024

@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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants