{{newin|[[0.9.0]]|090|type=function}}
Gets the direction of a virtual gamepad axis. If the Joystick isn't recognized as a [[Joystick:isGamepad|gamepad]] or isn't connected, this function will always return 0.
== Function ==
=== Synopsis ===
<source lang="lua">
direction = Joystick:getGamepadAxis( axis )
</source>
=== Arguments ===
{{param|GamepadAxis|axis|The virtual axis to be checked.}}
=== Returns ===
{{param|number|direction|Current value of the axis.}}
== Examples ==
=== Move x and y values based on a gamepad thumbstick ===
<source lang="lua">
function love.load()
    x = 0
    y = 0
    p1joystick = nil
end

function love.joystickadded(joystick)
    p1joystick = joystick
end

function love.update(dt)
    -- Check if joystick connected
    if p1joystick ~= nil then
        -- getGamepadAxis returns a value between -1 and 1.
        -- It returns 0 when it is at rest

        x = x + p1joystick:getGamepadAxis("leftx")
        y = y + p1joystick:getGamepadAxis("lefty")
    end
end
</source>
== See Also ==
* [[parent::Joystick]]
* [[Joystick:isGamepad]]
* [[Joystick:isGamepadDown]]
* [[Joystick:isConnected]]

* [[love.gamepadaxis]]
[[Category:Functions]]
{{#set:Description=Gets the direction of a virtual gamepad axis.}}
== Other Languages ==
{{i18n|Joystick:getGamepadAxis}}