MODULE v1.8.0

gamepad

pykraken.gamepad

Gamepad input handling functions

Reference

PYTHON API
get_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

function
get_deadzone(slot: int = 0) -> float

Get 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(slot: int = 0) -> Vec2

Get 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(slot: int = 0) -> float

Get 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(slot: int = 0) -> Vec2

Get 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(slot: int = 0) -> float

Get 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

function
get_type(slot: int = 0) -> GamepadType

Get 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(button: GamepadButton, slot: int = 0) -> bool

Check 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(button: GamepadButton, slot: int = 0) -> bool

Check 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

function
is_pressed(button: GamepadButton, slot: int = 0) -> bool

Check 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

function
set_deadzone(deadzone: float, slot: int = 0) -> None

Set 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).

Find your next step

Start typing to search the manual.