#How do I find if an InputDevice is a gamepad?

1 messages · Page 1 of 1 (latest)

queen raptor
#

Here's my pseudocode

Gamepad GetGamepad()
{
   foreach (InputDevice device in plrInput.devices)
   {
      if (device /*is a gamepad*/)
      {
         return /* the gamepad */
      }
   }

   return null;
}```
sweet glacier
#

What you have almost is working code: cs foreach(var device in plrInput.devices) { if(device is Gamepad gp) { return gp; } } return null;