gamepads
Gamepad input helpers for LAV2.
Modules:
| Name | Description |
|---|---|
common |
Shared data structures for gamepad inputs. |
mapping |
Shared gamepad bindings for flight and ground manual control. |
sdl2 |
SDL2 gamepad backend for LAV2. |
Classes:
| Name | Description |
|---|---|
Key |
Gamepad input abstraction shared across backends. |
AxisBinding |
Map one normalized gamepad axis to a controller target channel. |
ControllerEventLoop |
Minimal SDL2 controller event loop for LAV2. |
Functions:
| Name | Description |
|---|---|
apply_axis_binding |
Apply a normalized axis sample to a mutable batched target dict. |
clear_motion_targets |
Clear rate-like targets when switching between flight and ground. |
flight_axis_bindings |
Return PX4-style gamepad bindings for a flight control mode. |
ground_axis_bindings |
Return shared differential-drive gamepad bindings. |
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.
AxisBinding
dataclass
AxisBinding(target_key: str, axis: int | None, scale: float, incremental: bool = False, wrap_angle: bool = False)
Map one normalized gamepad axis to a controller target channel.
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.
apply_axis_binding
apply_axis_binding(target: ControllerTarget, binding: AxisBinding, value: float) -> None
Apply a normalized axis sample to a mutable batched target dict.
clear_motion_targets
clear_motion_targets(target: ControllerTarget) -> None
Clear rate-like targets when switching between flight and ground.
flight_axis_bindings
flight_axis_bindings(control_mode: str, params: VehicleParams, position_step: tuple[float, float, float] = (1.0, 1.0, 0.5)) -> dict[str, AxisBinding]
Return PX4-style gamepad bindings for a flight control mode.
ground_axis_bindings
ground_axis_bindings(params: VehicleParams) -> dict[str, AxisBinding]
Return shared differential-drive gamepad bindings.
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. |