Detecting if a gamepad is connected in code

Hello, how would i detect if a gamepad is connected in code? this is using the newer input system and im calling this check every second to set a gamepad bool to true if it is connected, but im not sure how to actually check that. thank you for any help.

Here is the relevant part in the manual : How do Iā€¦? | Input System | 1.0.2

thanks for the reply, ive looked through that before and im not sure how to put the part you referenced into an if statement or use that to change a bool.

nevermind, found a solution;

if (Gamepad.all.Count > 0)
        {
            gamepad = true;
        }
2 Likes