W3cubDocs

/LÖVE

love.joystick.setGamepadMapping

Available since LÖVE 0.9.2
This function is not supported in earlier versions.

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 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

success = love.joystick.setGamepadMapping( guid, button, inputtype, inputindex, hatdir )

Arguments

string guid
The OS-dependent GUID for the type of Joystick the binding will affect.
GamepadButton button
The virtual gamepad button to bind.
JoystickInputType inputtype
The type of input to bind the virtual gamepad button to.
number inputindex
The index of the axis, button, or hat to bind the virtual gamepad button to.
JoystickHat hatdir (nil)
The direction of the hat, if the virtual gamepad button will be bound to a hat. nil otherwise.

Returns

boolean success
Whether the virtual gamepad button was successfully bound.

Function

Synopsis

success = love.joystick.setGamepadMapping( guid, axis, inputtype, inputindex, hatdir )

Arguments

string guid
The OS-dependent GUID for the type of Joystick the binding will affect.
GamepadAxis axis
The virtual gamepad axis to bind.
JoystickInputType inputtype
The type of input to bind the virtual gamepad axis to.
number inputindex
The index of the axis, button, or hat to bind the virtual gamepad axis to.
JoystickHat hatdir (nil)
The direction of the hat, if the virtual gamepad axis will be bound to a hat. nil otherwise.

Returns

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.

360 controller.png

See Also

© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.joystick.setGamepadMapping