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

Joystick

The Joystick object represents a joystick device and allows you to access the controls on that joystick. All functions (except get_name() and get_id()) require the Joystick object to be initialized. This is done with the Joystick.init() function.
 
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.
get_axis - get the position of a joystick axis
get_ball - get the movement of a joystick trackball
get_button - get the position of a joystick button
get_hat - get the position of a joystick hat
get_id - get device id number for joystick
get_init - check if joystick is initialized
get_name - query name of joystick drive
get_numaxes - get number of axes on a joystick
get_numballs - get number of trackballs on a joystick
get_numbuttons - get number of buttons on a joystick
get_numhats - get number of hats on a joystick
init - initialize a joystick device for use
quit - uninitialize a joystick device for use

get_axis
Joystick.get_axis(axis) -> float
 
get_ball
Joystick.get_ball(button) -> x, y
 
get_button
Joystick.get_button(button) -> bool
 
get_hat
Joystick.get_hat(button) -> x, y
 
get_id
Joystick.get_id() -> idnum

 
get_init
Joystick.get_init() -> bool
 
get_name
Joystick.get_name() -> string
 
get_numaxes
Joystick.get_numaxes() -> int
 
get_numballs
Joystick.get_numballs() -> int
 
get_numbuttons
Joystick.get_numbuttons() -> int
 
get_numhats
Joystick.get_numhats() -> int
 
init
Joystick.init() -> None
 
quit
Joystick.quit() -> None