gamepad_test_mapping

This function can be used to set the gamepad mapping on those targets that permit it. You supply the "slot" index for the gamepad to set, and then the map string, which should have been created using the SDL format with the following fields:

<guid>,<description>,platform:<platform-name>,<bindings>

The details that should be included in each of these fields are:

The comma separated list of entries follows a specific format for each entry:

<abstract-gp-name>:<value-binding>

Here <value-binding> (ie: the direct gamepad input) can be any one of the following:

Each input value should be bound to an SDL name, which is expressed as <>abstract-gp-name>, which in turn is bound to a GML constant. The table below shows the equivalence between the SDL name and the GameMaker constant:

SDL NameGML Name
agp_face1
bgp_face2
xgp_face3
ygp_face4
leftshouldergp_shoulderl
lefttriggergp_shoulderlb
rightshouldergp_shoulderr
righttriggergp_shoulderrb
guidegp_select
startgp_start
leftstickgp_stickl
rightstickgp_stickr
dpupgp_padu
dpdowngp_padl
dpleftgp_padr
dprightgp_padd
leftxgp_axislh
leftygp_axislv
rightxgp_axisrh
rightygp_axisrv


When you have constructed your mapping string it should look something like this:

"050000005e040000fd020000ffff3f00,Xbox Wireless Controller,a:b0,b:b1,start:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:android"

 

Syntax:

gamepad_test_mapping(index, mapping_string);

ArgumentTypeDescription
indexRealWhich gamepad index "slot" to set.
mapping_stringStringThe map string to use (see the description for more information).

 

Returns:

N/A

 

Example:

var mapping = gamepad_get_guid(global.padIndex) + "," + gamepad_get_description(global.padIndex);
var len = array_length(global.PadInstances);
for (i = 0; i < len; i += 2)
{
    var left = global.PadInstances[i];
    var right = global.PadInstances[i+1];
    mapping += "," + left.sdlLabel + ":" + right.binding;
}
gamepad_test_mapping(global.padIndex, mapping);

The above code will loop through a number of instances and use the values of different variables that they contain to create a mapping string, which is then set for use on the gamepad in the given slot index.