melonJS
    Preparing search index...

    Variable setGamepadMappingConst

    setGamepadMapping: (id: string, mapping: Partial<GamepadMapping>) => void = addMapping

    specify a custom mapping for a specific gamepad id
    see below for the default mapping :


    Type Declaration

      • (id: string, mapping: Partial<GamepadMapping>): void
      • Parameters

        • id: string

          Gamepad id string

        • mapping: Partial<GamepadMapping>

          A hash table

        Returns void

    // A weird controller that has its axis mappings reversed
    me.input.setGamepadMapping("Generic USB Controller", {
    "axes" : [ 3, 2, 1, 0 ],
    "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]
    });

    // Mapping extra axes to analog buttons
    me.input.setGamepadMapping("Generic Analog Controller", {
    "axes" : [ 0, 1, 2, 3 ],
    "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ],

    // Raw axis 4 is mapped to GAMEPAD.BUTTONS.FACE_1
    // Raw axis 5 is mapped to GAMEPAD.BUTTONS.FACE_2
    // etc...
    // Also maps left and right triggers
    "analog" : [ 4, 5, 6, 7, -1, -1, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 ],

    // Normalize the value of button L2: [-1.0..1.0] => [0.0..1.0]
    "normalize_fn" : function (value, axis, button) {
    return ((button === me.input.GAMEPAD.BUTTONS.L2) ? ((value + 1) / 2) : value) || 0;
    }
    });