melonjs
    Preparing search index...

    Variable setGamepadMappingConst

    setGamepadMapping: {} = addMapping

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


    Type Declaration

      Gamepad id string

      A hash table

      Standard analog control stick axis locations

      Standard digital button locations

      Analog axis locations for buttons

      a function that returns a normalized value in range [-1.0..1.0] for the given value, axis and button

      // 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;
      }
      });