The joystick module manages the joystick devices on a computer (there can be more than one). Joystick devices include trackballs and video-game-style gamepads, and the module allows the use of multiple buttons and “hats”.
Gets the physical device name of a Joystick.
Gets the physical device name of a Joystick. The index specifies the device to get the name for and must be in the range [0, num_joysticks() - 1].
Gets, whether the specified joystick is opened for access or not.
Gets, whether the specified joystick is opened for access or not. The index specifies the joystick device to get the state for and must be in the range [0, num_joysticks() - 1].
Shuts down the joystick subsystem of the SDL library.
Shuts down the joystick subsystem of the SDL library and closes all existing Joystick objects (leaving them intact).
After calling this function, you should not invoke any class, method or function related to the joystick subsystem as they are likely to fail or might give unpredictable results.
Enables or disable joystick event polling.
Enables or disables joystick event processing. If the joystick event processing is disabled, you will have to update the joystick states manually using update() and read the information manually using the specific attributes and methods. Otherwise, joystick events are consumed and process by the pygame2.sdl.event module.
The state argument can be ENABLE or IGNORE for enabling or disabling the event processing or QUERY to receive the current state. The return value also will be one of those three constants.
Creates a new Joystick object for the specified physical device.
The Joystick object allows you to access information about the underlying physical device, such as the axes, hats and button states.
The index must be in the range [0, pygame2.sdl.joystick.num_joysticks() - 1]. This will also open the Joystick initially.
Closes the access to the underlying joystick device.
Calling or accessing any other method or attribute of the Joystick after closing it will cause an exception to be thrown. To reaccess the Joystick, you have to open() it again.
Gets the current position of the specified axis.
Gets the current position of the specified axis. The axis index must be a valid value within the range [0, num_axes - 1].
Gets the relative movement of a trackball.
Gets the relative movement of a trackball since the last call to get_ball(). The ball index must be a valid value within the range [0, num_balls - 1].
Gets the state of a button.
Gets the current pressed state of a button. The button index must be a valid value within the range [0, num_buttons - 1].
Gets the state of a hat.
Gets the current state of a hat. The return value will be a bitwise OR’d combination of the hat constants as specified in the pygame2.sdl.constants module. The hat index must be a valid value within the range [0, num_hats - 1].
Opens the (closed) Joystick.
Opens the (closed) Joystick. If the Joystick is already open, this method will have no effect.