{{newin|[[0.9.2]]|092|type=function}}
{{notice|Due to a bug, any mapping that is a suffix of another (for example "x" is a suffix to "leftx") needs to be mapped first}}
Binds a virtual gamepad input to a button, axis or hat for all Joysticks of a certain type. For example, if this function is used with a [[Joystick:getGUID|GUID]] returned by a Dualshock 3 controller in OS X, the binding will affect [[Joystick:getGamepadAxis]] and [[Joystick:isGamepadDown]] for ''all'' Dualshock 3 controllers used with the game when run in OS X.

LÖVE includes built-in gamepad bindings for many common controllers. This function lets you change the bindings or add new ones for types of Joysticks which aren't recognized as gamepads by default.

The virtual gamepad buttons and axes are designed around the Xbox 360 controller layout.
== Function ==
=== Synopsis ===
<source lang="lua">
success = love.joystick.setGamepadMapping( guid, button, inputtype, inputindex, hatdir )
</source>
=== Arguments ===
{{param|string|guid|The OS-dependent [[Joystick:getGUID|GUID]] for the type of Joystick the binding will affect.}}
{{param|GamepadButton|button|The virtual gamepad button to bind.}}
{{param|JoystickInputType|inputtype|The type of input to bind the virtual gamepad button to.}}
{{param|number|inputindex|The index of the axis, button, or hat to bind the virtual gamepad button to.}}
{{param|JoystickHat|hatdir (nil)|The direction of the hat, if the virtual gamepad button will be bound to a hat. nil otherwise.}}
=== Returns ===
{{param|boolean|success|Whether the virtual gamepad button was successfully bound.}}

== Function ==
=== Synopsis ===
<source lang="lua">
success = love.joystick.setGamepadMapping( guid, axis, inputtype, inputindex, hatdir )
</source>
=== Arguments ===
{{param|string|guid|The OS-dependent [[Joystick:getGUID|GUID]] for the type of Joystick the binding will affect.}}
{{param|GamepadAxis|axis|The virtual gamepad axis to bind.}}
{{param|JoystickInputType|inputtype|The type of input to bind the virtual gamepad axis to.}}
{{param|number|inputindex|The index of the axis, button, or hat to bind the virtual gamepad axis to.}}
{{param|JoystickHat|hatdir (nil)|The direction of the hat, if the virtual gamepad axis will be bound to a hat. nil otherwise.}}
=== Returns ===
{{param|boolean|success|Whether the virtual gamepad axis was successfully bound.}}

== Notes ==
The physical locations for the bound gamepad axes and buttons should correspond as closely as possible to the layout of a standard Xbox 360 controller.

[[File:360_controller.png]]
== See Also ==
* [[parent::love.joystick]]
* [[Joystick:getGUID]]
* [[Joystick:isGamepad]]
* [[Joystick:getGamepadMapping]]
[[Category:Functions]]
{{#set:Description=Binds a virtual gamepad input to a button, axis or hat.}}
== Other Languages ==
{{i18n|love.joystick.setGamepadMapping}}