Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(4 edits)

Common Mappings

How common mappings work

Common mappingsare located at Sinput/Resources/CommonMappings in your project, and for the most part, you can ignore them.

Common mappings are assets that describe button/axis mapping for various gamepads on various operating systems. Sinput will try to check all of these for matches with connected gamepads to maximise the possibility of a gamepad working without a player having to set up custom binding. This is going to fail sometimes, but so long as you give players the opportunity to rebind their controls they will still be able to use any gamepad that unity can detect to play your game.

You can make new common mappings for gamepads that sinput does not yet support so that those gamepads will work out-of-the-box with your game.

If you do make new common mappings, please consider sending them to me so I can include them in future versions of Sinput :)


Pad matching process

Pad matching is determined by operating system, gamepad name, partial name, and whether the common mapping is a default.

A common mapping is used for a gamepad if they match, the priority for matching is determined by;

  1. An exact name match from the names list.
  2. The gamepad name contains a match from the partial names list.
  3. The common mapping is marked as default.

It will never match if the operating system running the game doesn't match the common mapping.


Button setup

In this tab, you match up common gamepad inputs to the button indices that unity detects, and provide a display name. 


Axis setup

In this tab you match each of the gamepads axis to common gamepad inputs, and specify how the gamepad axis behaves (clamping, inverting, how far the axis value needs to go to count as a 'press' when treated like a button).

Generally, for most axis you are going to want a setting that will give a value of 0 when resting, and goes to 1 when fully pressed/moved. And for inputs like LSTICK_LEFT where the value for the full left stick's X range is -1 to 1, you will want to clamp it.


Gamepad Debug scene

Included in the project at Sinput/Utilities is a scene to help debug gamepads, it uses displays the full state of all connected gamepads, I use this when building the common mapping for a gamepad - you can identify which buttons/axis are which, and the value ranges of different axis.

Honestly it's pretty confusing to set up mappings from this, but you'll know if you get it right if your gamepad works to play the game without having to set any custom binding in-game.