SDL Joystick Support tcod.sdl.joystick
#
SDL Joystick Support.
New in version 13.8.
- class tcod.sdl.joystick.ControllerAxis(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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.
- 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.
- tcod.sdl.joystick.get_joysticks() list[Joystick] [source]#
Return a list of all connected joystick devices.
- tcod.sdl.joystick.joystick_event_state(new_state: bool | None = None) bool [source]#
Check or set joystick event polling.
- class tcod.sdl.joystick.Power(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
The possible power states of a controller.
See also
- UNKNOWN = -1#
Power state is unknown.
- EMPTY = 0#
<= 5% power.
- LOW = 1#
<= 20% power.
- MEDIUM = 2#
<= 70% power.
- FULL = 3#
<= 100% power.
- WIRED = 4#
- MAX = 5#