pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || display || draw || event || || font || image || joystick || key || mixer || mixer_music || || mouse || movie || sndarray || surfarray || time || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Rect || Sound || Surface || || color || cursors || sprite ||

## pygame.joystick

The joystick module provides a few functions to initialize the joystick subsystem and to manage the Joystick objects. These objects are created with the pygame.joystick.Joystick() function. This function needs a joystick device number to work on. All joystick devices on the system are enumerated for use as a Joystick object. To access most of the Joystick functions, you'll need to init() the Joystick. (note that the joystick module will already be initialized). When multiple Joysticks objects are created for the same joystick device, the state and values for those Joystick objects will be shared.
You can call the Joystick.get_name() and Joystick.get_id() functions without initializing the Joystick object.
Joystick control values are only updated during the calls to the event queue. Call pygame.event.pump() if you are not using the event queue for any input handling. Once a joystick object has been initialized, it will start to send joystick events to the input queue.
Be sure to understand there is a difference between the joystick module and the Joystick objects.

Joystick | - create new joystick object
get_count | - query number of joysticks on system
get_init | - query initialization of joystick module
init | - initialize joystick module
quit | - uninitialize joystick module

Joystick
`pygame.joystick.Joystick(id) -> Joystick`

Creates a new joystick object for the given device id. The given id must be less than the value from pygame.joystick.get_count().

get_count
`pygame.joystick.get_count() -> int`

Returns the number of joysticks devices available on the system.

get_init
`pygame.joystick.get_init() -> bool`

Returns true when the joystick module is initialized.

init
`pygame.joystick.init() -> None`

Initialize the joystick module manually

quit
`pygame.joystick.quit() -> None`

Uninitialize the joystick module manually