Automatic Gamepad Mappings for Desktop

rob1221

  • *
  • Posts: 9473
Gamepad support has been in Stencyl for a long time, but one important feature missing that almost all modern games use is automatic gamepad detection.  At first I looked into OpenFL's gamepad API, but it was lacking in device support.  Then I found this preset list that could be used to apply gamepad mappings to a lot of different gamepads.  Check out the attached sample game to see how it works and check if your own gamepads are automatically detected.  Matching is done based on the gamepad ID first, then the gamepad name, then a partial name (such as "PS4").  If a match is found then pressing the gamepad buttons should trigger the expected results on the screen.

To use this in your own game, export the Gamepad Mappings behavior and import it into your project.  You'll also need to copy the contents of the extras folder which is part of the game's folder inside of your workspace.

Update 1: Updated mappings and removed an outdated section of the sample game.
Update 2: Updated mappings again.

« Last Edit: June 11, 2021, 12:11:37 pm by rob1221 »

Bombini

  • *
  • Posts: 1401
Hi Rob,

one question.
What would be the best approach to use it in a game.
Turn this into a behavior and attach it to every scene?

Thanks!

rob1221

  • *
  • Posts: 9473
Gamepad Mappings is the core behavior that can be exported from the example game and imported into yours.  The Test Scene event shows a mapping example but shouldn't be copied directly.