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


asked Jun 10, 2019 in Engine by tyo (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.

answered Jun 10, 2019 by Dlean Jeans (3,873 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:

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