gamepad
pykraken.gamepad Gamepad input handling functions
At a glance
11 membersReference
PYTHON APIget_connected_slots
functionget_connected_slots() -> list[int]Get a list of connected gamepad slot indices.
Returns
list[int]: A list of slot IDs with active gamepads.
get_deadzone
functionget_deadzone(slot: int = 0) -> floatGet the current dead zone value for a gamepad's analog sticks.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- float — Deadzone threshold.
get_left_stick
functionget_left_stick(slot: int = 0) -> Vec2Get the left analog stick position.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- Vec2 — A vector of stick input normalized to [-1, 1], or (0, 0) if inside dead zone.
get_left_trigger
functionget_left_trigger(slot: int = 0) -> floatGet the left trigger's current pressure value.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- float — Trigger value in range [0.0, 1.0].
get_right_stick
functionget_right_stick(slot: int = 0) -> Vec2Get the right analog stick position.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- Vec2 — A vector of stick input normalized to [-1, 1], or (0, 0) if inside dead zone.
get_right_trigger
functionget_right_trigger(slot: int = 0) -> floatGet the right trigger's current pressure value.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- float — Trigger value in range [0.0, 1.0].
get_type
functionget_type(slot: int = 0) -> GamepadTypeGet the type of gamepad connected in a given slot.
Args
- slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- GamepadType — An enum value representing the gamepad type, or Unknown if no gamepad is connected.
is_just_pressed
functionis_just_pressed(button: GamepadButton, slot: int = 0) -> boolCheck if a gamepad button was pressed during this frame.
Args
- button (
GamepadButton) — The button code. - slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- bool — True if the button was just pressed.
is_just_released
functionis_just_released(button: GamepadButton, slot: int = 0) -> boolCheck if a gamepad button was released during this frame.
Args
- button (
GamepadButton) — The button code. - slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- bool — True if the button was just released.
is_pressed
functionis_pressed(button: GamepadButton, slot: int = 0) -> boolCheck if a gamepad button is currently being held down.
Args
- button (
GamepadButton) — The button code. - slot (
int, optional) — Gamepad slot ID (default is 0).
Returns
- bool — True if the button is pressed.
set_deadzone
functionset_deadzone(deadzone: float, slot: int = 0) -> NoneSet the dead zone threshold for a gamepad's analog sticks.
Args
- deadzone (
float) — Value from 0.0 to 1.0 where movement is ignored. - slot (
int, optional) — Gamepad slot ID (default is 0).