SDL Joystick Support tcod.sdl.joystick¶
SDL Joystick Support.
Added in version 13.8.
- class tcod.sdl.joystick.ControllerAxis(value)[source]¶
The standard axes for a game controller.
- LEFTX = 0¶
- LEFTY = 1¶
- RIGHTX = 2¶
- RIGHTY = 3¶
- TRIGGERLEFT = 4¶
- TRIGGERRIGHT = 5¶
- class tcod.sdl.joystick.ControllerButton(value)[source]¶
The standard buttons for a game controller.
- A = 0¶
- B = 1¶
- BACK = 4¶
- DPAD_DOWN = 12¶
- DPAD_LEFT = 13¶
- DPAD_RIGHT = 14¶
- DPAD_UP = 11¶
- GUIDE = 5¶
- LEFTSHOULDER = 9¶
- LEFTSTICK = 7¶
- MISC1 = 15¶
- PADDLE1 = 16¶
- PADDLE2 = 17¶
- PADDLE3 = 18¶
- PADDLE4 = 19¶
- RIGHTSHOULDER = 10¶
- RIGHTSTICK = 8¶
- START = 6¶
- TOUCHPAD = 20¶
- X = 2¶
- Y = 3¶
- class tcod.sdl.joystick.GameController(sdl_controller_p: Any)[source]¶
A standard interface for an Xbox 360 style game controller.
- __eq__(other: object) bool[source]¶
Return True if self and other are both controllers referring to the same joystick.
- get_axis(axis: ControllerAxis) int[source]¶
Return the state of the given axis.
The state is usually a value from -32768 to 32767, with positive values towards the lower-right direction. Triggers have the range of 0 to 32767 instead.
- get_button(button: ControllerButton) bool[source]¶
Return True if button is currently held.
- class tcod.sdl.joystick.Joystick(sdl_joystick_p: Any)[source]¶
A low-level SDL joystick.
- get_ball(ball: int) tuple[int, int][source]¶
Return the values (delta_x, delta_y) of ball since the last poll.
- tcod.sdl.joystick.controller_event_state(new_state: bool | None = None) bool[source]¶
Check or set game controller event polling.
- tcod.sdl.joystick.get_controllers() list[GameController][source]¶
Return a list of all connected game controllers.
This ignores joysticks without a game controller mapping.