sdl2
SDL2 gamepad backend for LAV2.
Classes:
| Name | Description |
|---|---|
ControllerEventLoop |
Minimal SDL2 controller event loop for LAV2. |
Functions:
| Name | Description |
|---|---|
controller_key_from_event |
Convert an SDL2 event to a Key. |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Callable[[Key], None]
|
Callback for parsed keys. |
required |
|
Event | None
|
Control event loop lifetime. |
None
|
|
int
|
SDL wait timeout in milliseconds. |
2000
|
Methods:
| Name | Description |
|---|---|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
SDL_Event
|
Raw SDL2 event. |
required |
|
float
|
Deadzone for analog axes. |
0.05
|
Returns:
| Type | Description |
|---|---|
Key | None
|
Key | None: Parsed key input, if any. |