melonJS
    Preparing search index...

    Function bindGamepad

    • Associate a gamepad event to a keycode

      Parameters

      • index: number

        Gamepad index

      • button: { code: number; threshold?: number; type: "buttons" | "axes" }

        Button/Axis definition

        • code: number

          button or axis code id

        • Optionalthreshold?: number

          value indicating when the axis should trigger the keycode

        • type: "buttons" | "axes"

          "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);