{{newin|[[0.9.0]]|090|type=type}}
Represents a physical joystick.
== Constructors ==
{{#ask: [[Category:Functions]] [[Constructs::Joystick]]
| headers=hide
| default=None.
| format=template
| template=ListingFields
| introtemplate=ListingIntro
| outrotemplate=ListingOutro
| ?Description
| ?PrettySince
| ?PrettyRemoved
}}
== Functions ==
{{#ask: [[Category:Functions]] [[parent::Joystick||Object]]
| headers=hide
| format=template
| template=ListingFields
| introtemplate=ListingIntro
| outrotemplate=ListingOutro
| ?Description
| ?PrettySince
| ?PrettyRemoved
}}
== Enums ==
{{#ask: [[Category:Enums]] [[parent::Joystick]]
| headers=hide
| format=template
| template=ListingFields
| introtemplate=ListingIntro
| outrotemplate=ListingOutro
| ?Description
| ?PrettySince
| ?PrettyRemoved
}}
== Supertypes ==
* [[parent::Object]]
== Examples ==
=== Display the last button pressed of a controller on-screen ===
<source lang="Lua">
local lastbutton = "none"

function love.gamepadpressed(joystick, button)
    lastbutton = button
end

function love.draw()
    love.graphics.print("Last gamepad button pressed: "..lastbutton, 10, 10)
end
</source>
=== Move a circle with the d-pad of a controller ===
<source lang="Lua">
function love.load()
    local joysticks = love.joystick.getJoysticks()
    joystick = joysticks[1]

    position = {x = 400, y = 300}
    speed = 300
end

function love.update(dt)
    if not joystick then return end

    if joystick:isGamepadDown("dpleft") then
        position.x = position.x - speed * dt
    elseif joystick:isGamepadDown("dpright") then
        position.x = position.x + speed * dt
    end

    if joystick:isGamepadDown("dpup") then
        position.y = position.y - speed * dt
    elseif joystick:isGamepadDown("dpdown") then
        position.y = position.y + speed * dt
    end
end

function love.draw()
    love.graphics.circle("fill", position.x, position.y, 50)
end
</source>
== See Also ==
* [[parent::love.joystick]]
* [[love.joystick.getJoystickCount]]

* [[love.joystickadded]]
* [[love.joystickremoved]]
* [[love.joystickpressed]]
* [[love.joystickreleased]]
* [[love.joystickaxis]]
* [[love.joystickhat]]

* [[love.gamepadpressed]]
* [[love.gamepadreleased]]
* [[love.gamepadaxis]]
[[Category:Types]]
{{#set:Description=Represents a physical joystick.}}
== Other Languages ==
{{i18n|Joystick}}