check for controllers godot

Solutions on MaxInterview for check for controllers godot by the best coders in the world

showing results for - "check for controllers godot"
Julián
10 Jul 2020
1func _ready():
2    Input.connect("joy_connection_changed", self, "_on_joy_connection_changed")
3    #Checks what status is right now
4    if Input.get_connected_joypads().size == 0:
5      print("Keyboard")
6   	else:
7      #Gets controller type
8      print(Input.get_joy_name(Input.get_connected_joypads()[0]))
9
10func _on_joy_connection_changed(device_id, connected):
11    if connected:
12        print(Input.get_joy_name(device_id))
13    else:
14        print("Keyboard")