Where does the "id" parameter in the lime.ui.Gamepad constructor come from?

I’m trying to use the Gamepad class to determine the kind of controller being used. I can’t seem to find any documentations or examples that explain where the id parameter in the constructor comes from. I thought it might be the corresponding GameInputDevice's id, but that’s a string and an integer is required.

Any ideas?

Try using Gamepad.onConnect to receive a signal when a new device is connected:


You can also poll Gamepad.devices to check a Map of already connected Gamepad instances.

I would pretend Gamepad has a private constructor

Also, bear in mind that Gamepad needs mappings available (through Gamepad.addMappings) in order to recognize hardware and how its inputs map to named buttons and axes in the Gamepad API. Lime includes a set of default SDL2 gamepad mappings, though you can extend it with your own or open a pull request to update the default mappings with a newer version.

All recognized game input devices should work through the Joystick API, then if mappings are available, they will also work as a Gamepad

Thanks! I’ve been using GameInput for controls—I didn’t understand that GamePad was a complete (and better, it seems) alternative for the whole hierarchy.

I created Gamepad and Joystick to provide functionality from SDL and mirror how I may want to use them in a perfect world.

GameInput was created to function on top of Gamepad in order to support compatibility with Flash projects that use it. I suspect I would not use GameInput directly given a choice :laughing:

1 Like

Hey Joshua, just to follow up—I’ve noticed the following (mis)behavior of GamePad on the SteamDeck:

  • The method assigned to Gamepad.onConnect is NOT fired when external gamepads are connected, nor at startup to reflect already-connected devices.

  • GamePad.devices isn’t updated, either (so I can’t just keep re-polling).

  • The gamepad.onDisconnect method (added per instance) IS called when a recognized device is disconnected.

  • Also, the correct list of GamePad.devices is available at startup—it contains the SteamDeck console gamepad + any external controllers already connected.

  • FWIW, GameInput seems to be similarly affected—new devices aren’t recognized, etc.

I verified that the same code works as it should on Mac/Windows cpp targets. So I assume this has to do with the Proton layer. Do you have any idea offhand where the problem might be occurring?