Bindings Legend
HUD overlay showing contextual input bindings with modifier support, vehicle-specific actions, and auto-fade.
HUD overlay showing contextual input bindings with modifier support, vehicle-specific actions, and auto-fade.
Overview
ui_bindingsLegend manages the on-screen bindings/controls legend. It dynamically shows relevant keybindings based on active modifiers, vehicle-specific actions, and gameplay context, with priority-based layering and auto-fade.
Extension path: lua/ge/extensions/ui/bindingsLegend.lua
Dependencies: core_input_actions, core_input_bindings
Exports (M)
| Function | Signature | Description |
|---|---|---|
addActions | (label, actions[], additionalData) | Adds a named set of actions to display. Priority-based. |
sendDataToUI | () | Pushes current action data to the UI via setActionsForLegend guihook. |
toggleShowVehicleSpecificActions | () | Toggles vehicle-specific action visibility. |
enableShowVehicleSpecificActions | (enable) | Explicitly show/hide vehicle-specific actions. |
triggerInputAction | (action, value) | Executes an input action programmatically. |
resetFade | () | Resets the fade timer (unfades the legend). |
toggleShowApp | () | Toggles the legend app visibility in settings. |
setDebug | (enabled) | Enables debug ImGui window. |
onUpdate | (dtReal, dtSim, dtRaw) | Per-frame update - runs fade timer, TTL countdown, and debug window. |
onClientStartMission | () | Hook - no-op placeholder for mission start. |
onExtensionLoaded | () | Hook - loads action definitions from ui/bindingAppActions.json. |
onDeserialized | (data) | Hook - clears modifier cache on deserialization. |
Data Fields
| Field | Description |
|---|---|
M.dependencies | {"core_input_actions", "core_input_bindings"} - required input subsystems. |
Internals
Action Sets & Priority
Actions are stored as labeled sets with priority. Higher priority sets take precedence:
addActions("vehicleSpecific", vehicleSpecificActions, {
priority = 10,
removeIfOverwrittenWithHigherPriority = true,
ttl = 10 -- auto-remove after 10 seconds
})When multiple sets exist, only the highest-priority set's actions are shown (others are hidden).
Modifier System
The module tracks 6 custom modifiers + shift/ctrl/alt via bitmask:
-- Modifier constants
local MODIFIER1 = 64 -- custom modifier 1
local MODIFIER2 = 128 -- custom modifier 2
-- ...up to MODIFIER6 = 2048onModifierChanged(newModifiers) scans all bindings to find actions matching the exact modifier combination, then displays them as a "modified" action set at priority 9.
Vehicle-Specific Actions
On vehicle switch (onVehicleSwitched):
- Fetches actions with
cat == "vehicle_specific"fromcore_input_actions - Shows them temporarily (10s TTL) in "fleeting" mode
- Displays a message: "Press [action] to show/hide vehicle specific actions"
Fade Behavior
The legend auto-fades after fadeDelaySeconds (default 7s) of inactivity. New data resets the timer. Currently shouldFade() always returns false (fade disabled).
UI Data Structure
guihooks.trigger("setActionsForLegend", {
actions = {...}, -- sorted action list
constantActions = {...}, -- always-shown actions
additionalData = {
vehicleSpecificStatus = "enabled"|"disabled"|"fleeting"|"inactive",
resetFade = true,
},
modifierActionInfos = { -- modifier button states
customModifier1 = { active = true },
shift = { active = false },
},
showApp = true
})Event Hooks
| Hook | Behavior |
|---|---|
onModifierChanged | Updates modifier-dependent bindings display |
onVehicleSwitched | Shows vehicle-specific actions temporarily |
onActionFilterUpdated | Recalculates visible bindings |
onInputBindingsChanged | Clears modifier cache, refreshes UI |
onDeviceChanged | Refreshes for new input device |
onClientEndMission | Clears all action data |
How It Works
- Gameplay systems call
addActions()to push context-sensitive bindings - Modifier keys trigger
onModifierChanged()to show modified bindings - Vehicle switches temporarily show vehicle-specific actions
- All action sets are merged by priority and sent to UI
- Legend auto-fades after inactivity (currently disabled)
Additional Exports
The following exports are available but not yet documented in detail:
M.addActionsM.enableShowVehicleSpecificActionsM.onActionFilterUpdatedM.onClientEndMissionM.onClientStartMissionM.onDeserializedM.onDeviceChangedM.onExtensionLoadedM.onModifierChangedM.onUpdateM.onVehicleSwitchedM.resetFadeM.sendDataToUIM.setDebugM.toggleShowAppM.toggleShowVehicleSpecificActionsM.triggerInputAction