Gamepad State Controller
Gamepad state controller centralizes gamepad input handling for Banalytics. It consumes raw browser gamepad state snapshots, maintains per-device axis and button state, filters small noise, and emits clean axis and button change events for remote control workflows.
Normalize gamepad input into control events
The controller receives raw GamePadStateChangedEvent snapshots from browser/client sources compatible with the Web Gamepad API. It compares the latest state with the previous in-memory state and emits derivative GPAxisChangeEvent and GPButtonChangeEvent events only when changes pass configured thresholds.
Gamepad state
Tracks axes and buttons per gamepad identifier and remembers known controller IDs across sessions.
Noise filtering
Suppresses tiny analog changes that would otherwise create jitter in PTZ, vehicle, or hardware-control actions.
Derivative events
Emits axis and button change events that downstream Event Manager rules and actions can consume.
00000000-0000-0000-0000-000000000011, so other modules can reference the same gamepad registry and event source.
Preparing a gamepad control source
Start the controller
Keep the Gamepad State Controller running when downstream actions need joystick or button input.
Connect and move the controller
Open the controller UI and move each gamepad once so its identifier is observed and saved for dropdowns in downstream actions.
Set current as zero state
Use zero-state calibration when sticks or triggers do not rest exactly at zero. This helps downstream controls receive centered values while the operator is idle.
Tune thresholds
Adjust axis and button thresholds to balance smooth control, noise suppression, and event rate.
Remote control use cases
PTZ joystick control
Map axis-change events to pan, tilt, zoom, speed, or direction for camera control actions.
Rover and drone control
Use axes and buttons as an operator input source for motor PWM, flight controls, relays, or other real-time commands.
Industrial and Modbus control
Map controller inputs to Modbus registers, coils, or other gateway commands in supervised manual-control workflows.
Tuning thresholds for precision and stability
Thresholds control when small changes become events. Low thresholds preserve fine movement but can amplify noisy hardware. High thresholds reduce event volume and jitter but can make controls feel sluggish.
axisThreshold when idle sticks generate constant tiny axis changes.axisThreshold when slow, precise joystick movement should be preserved.buttonThreshold when pressure-sensitive buttons or triggers fluctuate around a value.Working with multiple controllers
Learn gamepad identifiers
Press a button or move a stick on each controller so the registry observes and persists its identifier.
Bind downstream actions
Use gamepad ID dropdowns in downstream actions to bind a rule or action to the intended controller.
Avoid cross-control
Configure PTZ, rover, drone, or Modbus actions to listen only to the expected gamepad ID so one operator does not control the wrong device.
Configuration parameters
| Parameter | Required | Description | Default |
|---|---|---|---|
Axis threshold | Yes | Minimum absolute axis value delta required to emit a GPAxisChangeEvent. Step is 0.0001. | 0.002 |
Button threshold | Yes | Minimum absolute button value delta required to emit a GPButtonChangeEvent for analog button value changes. Step is 0.0001. | 0.002 |
Events emitted or consumed by the controller
| Event | Direction | Key fields | Use |
|---|---|---|---|
GamePadStateChangedEvent | Consumed | gamepadId, axes, buttons | Raw browser snapshot |
GPAxisChangeEvent | Emitted | axisIndex, value | Joystick movement |
GPButtonChangeEvent | Emitted | gamepadId, buttonIndex, pressed, touched, value | Button and trigger changes |
GyroscopeEvent | Related | xAngular, yAngular, zAngular | Client angular velocity |
GravityEvent | Related | xAngular, yAngular, zAngular | Client gravity sensor |
Operational notes
State resets on restart
In-memory axis and button state is cleared on component start and stop. The first raw event after reconnect initializes the current state for that gamepad.
Known IDs are persisted
Known gamepad identifiers are stored in instances/gamepad-ids.json under the agent configuration folder.
Button transitions are always important
Button press and touch transitions generate button-change events even if the analog value changes only slightly.
Related remote control pages
Use these pages to connect gamepad events to cameras, rules, and operator workflows.