Function bindGamepad

  • Associate a gamepad event to a keycode

    Parameters

    • index: number

      Gamepad index

    • button: {
          code: number;
          threshold: undefined | number;
          type: string;
      }

      Button/Axis definition

      • code: number

        button or axis code id (See input.GAMEPAD)

      • threshold: undefined | number

        value indicating when the axis should trigger the keycode (e.g. -0.5 or 0.5)

      • type: string

        "buttons" or "axes"

    • keyCode: number

      (See input.KEY)

    Returns void

    // enable the keyboard
    me.input.bindKey(me.input.KEY.X, "shoot");
    ...
    // map the lower face button on the first gamepad to the X key
    me.input.bindGamepad(0, {type:"buttons", code: me.input.GAMEPAD.BUTTONS.FACE_1}, me.input.KEY.X);
    // map the left axis value on the first gamepad to the LEFT key
    me.input.bindGamepad(0, {type:"axes", code: me.input.GAMEPAD.AXES.LX, threshold: -0.5}, me.input.KEY.LEFT);