跳转至

gamepads

Gamepad input helpers for LAV2.

模块:

名称 描述
common

Shared data structures for gamepad inputs.

sdl2

SDL2 gamepad backend for LAV2.

类:

名称 描述
Key

Gamepad input abstraction shared across backends.

ControllerEventLoop

Minimal SDL2 controller event loop for LAV2.

函数:

名称 描述
controller_key_from_event

Convert an SDL2 event to a Key.

Key dataclass

Key(keytype: str, index: int, name: str | None = None, value: float | None = None)

Gamepad input abstraction shared across backends.

ControllerEventLoop

ControllerEventLoop(handle_key: Callable[[Key], None], alive: Event | None = None, timeout: int = 2000)

Minimal SDL2 controller event loop for LAV2.

Initialize the controller event loop.

参数:

名称 类型 描述 默认

handle_key

Callable[[Key], None]

Callback for parsed keys.

必需

alive

Event | None

Control event loop lifetime.

None

timeout

int

SDL wait timeout in milliseconds.

2000

方法:

名称 描述
stop

Stop the event loop.

run

Run the SDL2 event loop until stopped.

stop

stop() -> None

Stop the event loop.

run

run() -> None

Run the SDL2 event loop until stopped.

controller_key_from_event

controller_key_from_event(event: SDL_Event, deadzone: float = 0.05) -> Key | None

Convert an SDL2 event to a Key.

参数:

名称 类型 描述 默认

event

SDL_Event

Raw SDL2 event.

必需

deadzone

float

Deadzone for analog axes.

0.05

返回:

类型 描述
Key | None

Key | None: Parsed key input, if any.