love.gamepadpressed

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

Called when a Joystick's virtual gamepad button is pressed.

Function

Synopsis

love.gamepadpressed( joystick, button )

Arguments

Joystick joystick
The joystick object.
GamepadButton button
The virtual gamepad button.

Returns

Nothing.

Example: print the MRU gamepad name

Track the most recently used gamepad and print its name when it changes. See also love.joystick.getGamepadMappingString for more detailed names; especially when using love.joystick.loadGamepadMappings.

local active_joystick
function love.gamepadpressed(joystick, button)
    if joystick == active_joystick then
        return
    end
    active_joystick = joystick
    local name = joystick:getName()
    local index = joystick:getConnectedIndex()
    print(string.format("Changing active gamepad to #%d '%s'.", index, name))
end


See Also



Other Languages