Connect joy_connection_changed signal in c#

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By petr0m

How can I connect the signal joy_connection_changed in c#?

Is there a way to get the Input singleton reference so that I can connect the signal?

Thanks in advance!

:bust_in_silhouette: Reply From: juppi

Hi petr0m,

here you go:

public override void _Ready()
{
    Input.Singleton.Connect("joy_connection_changed", this, nameof(OnJoyConnectionChanged));
}

private void OnJoyConnectionChanged(int device, bool connected)
{

}

This will give you the Id of the Gamepad and tells you if its connected or removed.

But yes, this was not obvious. I had to read the docs too:

Awesome, thanks this worked!

petr0m | 2022-09-24 11:07