Advise for a Controlling-Hint-System (keyboard or Controller Input) / How to get Controller Input?

Godot Version

4.3

Question

My game is in it’s finally phase. A classic 2D Platformer. It supports Controller and keyboard Inputs.

I already build a hint-system. It’s a folding in textbox.
(like i the picture below)

Also the Game has 2 languages, so my code to import the relevant-keys look like this

var jump_key:String = "Space"
var attack_key:String = "Q"
var sprint_key:String = "SHIFT"

func display_conlling_hint(display_time:float, update:Hint_Typs):
       funtion_to_translate_key_languages() #"space" -> "Leerzeichen"
	match update:
		Hint_Typs.SPRINT:
			hint_label.text = tr("HINT_SPRINT") % [sprint_key]
		Hint_Typs.ATTACK:
			hint_label.text = tr("HINT_ATTACK") % [attack_key]
		Hint_Typs.JUMP:
			hint_label.text = tr("HINT_JUMP") % [jump_key]


   tween starts with the correct hint

Now do you have advice, how to check if the player uses a Controller (and which one) to adjust, for example, the Jump-Key for “space” to “X” or “A”

The only way i can think off, ask the player in the boot-up screen if and which Controller he uses.
But maybe you know a more elegant way

Any Idea is welcome
and thank you

You may have to use get_joy_name for unique prompts on each controller type. I.E. “A” for xbox style “B” for nintendo style and “X” for PS style controllers are all the same button.

I’d recommend using a font for these glyphs like this one: PromptFont

Note that I haven’t touched anything like that yet, so take anything I say below with a grain of salt.

What I would do is: use the last input (whether it comes for the keyboard or a controller) and change the hinting to that. Also, it shouldn’t matter if it’s a valid input or not. Get the type and set the messaging to that.

1 Like

What I’m missing here. it prints “nothing”

var joypad 

func _process(delta: float) -> void:
	get_name_off()
	print(joypad)

func get_name_off():
	joypad = Input.get_joy_name(1)

If you have one controller connected you can use Input.get_joy_name(0), indexs start at zero. You can get which joypad id created a InputEvent with event.device.

Putting the two together like so:

func _input(event: InputEvent) -> void:
    if event is InputEventJoypadButton:
        print(Input.get_joy_name(event.device))
1 Like