Input Module Reference
Module defined in `lua/vehicle/input.lua`. This module processes raw user inputs from various sources (keyboard, gamepad, steering wheel, AI), applies temporal smoothing and driving assistants, and br
Module defined in lua/vehicle/input.lua. This module processes raw user inputs from various sources (keyboard, gamepad, steering wheel, AI), applies temporal smoothing and driving assistants, and broadcasts the final values to the rest of the vehicle systems.
See Also
- Electrics: Where final processed input values (e.g.,
electrics.values.throttle) are stored. - Hydros: For force feedback and steering geometry.
Core Module Properties
Direct normalized and smoothed values for primary driving controls.
| Variable | Type | Description |
|---|---|---|
steering | number | Final steering value (-1.0 to 1.0). |
throttle | number | Final throttle value (0.0 to 1.0). |
brake | number | Final brake value (0.0 to 1.0). |
clutch | number | Final clutch value (0.0 to 1.0). |
parkingbrake | number | Final parking brake value (0.0 or 1.0). |
State Fields
| Variable | Description |
|---|---|
state | Container for the detailed status of every input axis. Internal Structure (e.g., input.state.throttle): val: The current smoothed value. filter: The filter type used (0: Direct, 1: Keyboard, 2: Pad). minLimit / maxLimit: Clamping bounds. smootherKBD: Temporal smoother object for keyboard/digital input. smootherPAD: Temporal smoother object for gamepad/analog axis input. |
allowedInputSources | Table tracking which sources (local, ai, remote) are permitted to override specific inputs. |
lastFilterType | Stores the filter type of the most recently received input. |
lastInputs | Tracks the previous input values for change detection. |
Public API - Global
| Function | Signature | Description |
|---|---|---|
input.event | (itype, ivalue, filter, ...) | Main entry point for raw input. Maps the value to the internal state and updates smoothers. |
input.toggleEvent | (itype) | Toggles a digital input between 0.0 and 1.0. Typically used for hazards, parking brake, etc. |
input.kbdSteer | (isRight, val, filter) | Specialized handler for keyboard steering that manages left/right accumulation. |
input.padAccelerateBrake | (val, filter) | Handles gamepad triggers where a single axis is mapped to both throttle and brake. |
input.setAllowedInputSource | (itype, source, enabled) | Restricts or allows specific modules (like AI) from taking control of an input axis. |
input.init | () / initSecondStage() / reset() | Initialization and state clearing for smoothers and input logic. initSecondStage pre-calculates rates based on steering geometry. |
input.settingsChanged | () | Refreshes driving assistant configuration (e.g., steering sensitivity) from user settings. |
input.updateGFX | (dt) | Primary update loop. Processes smoothers, applies driving assistants (ABS, TCS, Steering helpers), and updates electrics.values. |
Usage Example
input.event("brake", 0.5, 2)Hydros Module Reference
Module defined in `lua/vehicle/hydros.lua`. This module simulates hydraulic actuators (hydros) and torsion hydros, primarily used for steering and complex animated parts. It also handles Force Feedbac
JBeam-Lua Integration Guide
A deep dive into how JBeam data structures and Lua logic communicate in BeamNG.drive.