Gamepad

Gamepad input handling functions


Get Connected Slots

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

get_deadzone(slot: SupportsInt = 0) float

Get the current dead zone value for a gamepad's analog sticks.

Args

  • slot : Gamepad slot ID (default is 0).

Returns

float : Deadzone threshold.

Get Left Stick

get_left_stick(slot: SupportsInt = 0) Vec2

Get the left analog stick position.

Args

  • slot : 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

get_left_trigger(slot: SupportsInt = 0) float

Get the left trigger's current pressure value.

Args

  • slot : Gamepad slot ID (default is 0).

Returns

float : Trigger value in range [0.0, 1.0].

Get Right Stick

get_right_stick(slot: SupportsInt = 0) Vec2

Get the right analog stick position.

Args

  • slot : 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

get_right_trigger(slot: SupportsInt = 0) float

Get the right trigger's current pressure value.

Args

  • slot : Gamepad slot ID (default is 0).

Returns

float : Trigger value in range [0.0, 1.0].

Is Just Pressed

is_just_pressed(
    button: GamepadButton,
    slot: SupportsInt = 0
) bool

Check if a gamepad button was pressed during this frame.

Args

  • button : The button code.
  • slot : Gamepad slot ID (default is 0).

Returns

bool : True if the button was just pressed.

Is Just Released

is_just_released(
    button: GamepadButton,
    slot: SupportsInt = 0
) bool

Check if a gamepad button was released during this frame.

Args

  • button : The button code.
  • slot : Gamepad slot ID (default is 0).

Returns

bool : True if the button was just released.

Is Pressed

is_pressed(
    button: GamepadButton,
    slot: SupportsInt = 0
) bool

Check if a gamepad button is currently being held down.

Args

  • button : The button code.
  • slot : Gamepad slot ID (default is 0).

Returns

bool : True if the button is pressed.

Set Deadzone

set_deadzone(
    deadzone: SupportsFloat,
    slot: SupportsInt = 0
) None

Set the dead zone threshold for a gamepad's analog sticks.

Args

  • deadzone : Value from 0.0 to 1.0 where movement is ignored.
  • slot : Gamepad slot ID (default is 0).