controllers godot code example
Example: check for controllers godot
func _ready():
Input.connect("joy_connection_changed", self, "_on_joy_connection_changed")
#Checks what status is right now
if Input.get_connected_joypads().size == 0:
print("Keyboard")
else:
#Gets controller type
print(Input.get_joy_name(Input.get_connected_joypads()[0]))
func _on_joy_connection_changed(device_id, connected):
if connected:
print(Input.get_joy_name(device_id))
else:
print("Keyboard")