The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

So... The more research I do on how joysticks work in Godot by default, the more convinced I am that if I want my flight-sim inspired project to work out and work with as many joystick configurations as possible, I need to write my own joystick handler to handle special cases where players have elaborate joystick setups. (I can still use the built-in handling for simpler joysticks and gamepads.)

I've done this before back on Windows 98 and since DirectInput hasn't changed much over the years I imagine the process will be similar. Heck, my old code may even still work! But, the real trick is integrating this into a Godot project, so my question is: What would be the best approach for doing this? Can this be done entirely with GDScript? Will I need to write a separate C/C++ module? C# even? Could it be done using plugins? Or heck, is doing this even possible given how anything integrates with Godot?

I'm just looking for advice on the best approach to integrate such a thing into a Godot project so that I know where to focus my efforts.

in Engine by (27 points)

1 Answer

+1 vote

Generally it is possible to integrate your own C/C++ code into a Godot game. Start here:
It takes some serious work though.

I wonder what special setups you have in mind that cannot be handled by the Godot engine's joystick handling code. I found it to be quite flexible.

Also if possible, I recommend to first create your game with Godot's input handling mechanisms and then at some point look into this topic again (think version 1.1 of your game).

by (49 points)

Well, the initial trouble I ran into is that Godot uses SDL-style mapping for joysticks, which is fine for the majority of joysticks out there, but for advanced flightsticks or setups with proper rudder pedals and everything, it simply can't handle it all since it has to map everything to common gamepad mappings.

For instance, I'm using a Thrustmaster T.Flight HOTAS X joystick which has FIVE axes, a hat, and 12 buttons. Godot recognizes only four of the axes by default and if I attempt to manually map in the fifth one as analog triggers I end up unable to map two of the buttons. In short, I cannot use the entire joystick with Godot's built-in handling. :(

The game I'm developing will work with keyboard+mouse or a gamepad, but because it's steeped with flight-sim aspects, I absolutely do not want to leave out people who want to play the game with advanced joystick setups so that they can have total control of their craft without having to rely on things working automatically or at a simpler level.

The plus side is I do still have my old DirectInput joystick code which I wrote years ago. With a little luck, all I'll have to do is go through the Godot integration process and then just copy-paste the whole thing!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.