+1 vote

I'm wondering if it is at all possible for the engine to tell the difference between different kinds of controllers the user is using and change some UI information based on the kind of game pad plugged in. For example, if an Xbox controller is in, I'd want the game to display "Press A to Jump" and if a PS4 controller is in, I'd want the game to display "Press X to Jump."

I realize I could just make this a setting for the player to change however they please, but I'm wondering if I could in some way automate this. I've already figured out how to get the game to tell the difference between a mouse/keyboard command and a gamepad command on the fly, so I'm hopeful that something like this is possible too.

Thanks!

in Engine by (42 points)

1 Answer

+2 votes

Godot has a function called Input.get_joy_name(). I got no gamepads to test but I guess it would return whether it's a PS4 or an Xbox controller.

If that's true then use it together with the signal Input.joy_connection_changed as described in this answer would do.

by (3,959 points)

I'd also say that getjoyname() is the way to go.
Here's a list of controller names (& data) in case tyo needs some data to test the name checks:
http://hg.libsdl.org/SDL/file/tip/src/joystick/SDL_gamecontrollerdb.h

( I'd only check for parts of the string, maybe using a RegExp )

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 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 webmaster@godotengine.org with your username.

Categories