How-To: Let Players Rebind Chords
Goal: let each player set their own modifier on an action from a settings screen, persisted across sessions, with conflict detection and a display glyph.
Add Mapping Context With Chord Triggers.1. Mark the action rebindable
On the UInputAction, set Player Mappable Key Settings -> Class to CrimsonPlayerMappableKeySettings and give it a Name. That Name is the key per-player chord overrides are stored under.
Add Mapping Context With Chord Triggers injects a UInputTriggerCrimsonDynamicChord (with an empty DefaultChord, i.e. overrides-only) onto any mapping whose action uses UCrimsonPlayerMappableKeySettings with Apply Dynamic Chord Trigger ticked (the default) and does not already have one. To also give it a designer default, add the trigger yourself and set both MappingName and DefaultChord.Shift+RMB lives in a combo asset, or a modifier action itself - untick Apply Dynamic Chord Trigger on its CrimsonPlayerMappableKeySettings. Otherwise the input-level gate swallows the chorded press before that system ever sees it. Rebinding via Name still works with the flag off.2. Read and write overrides
Get the UCrimsonInputUserSettings (see How-To: Get the Building Blocks step 3). Write with SetChordRequirement; read the effective value (override, else the inline default) with GetChordRequirementWithDefaults.
Starting from the cast in How-To: Get the Building Blocks step 3: Get Enhanced Input User Settings -> Cast To CrimsonInputUserSettings -> Set Chord Requirement (Mapping Name = Ability1, Slot = First, Chord Requirement = a Make CrimsonChordRequirement with Input.Modifier.Shift added to its Required Modifiers). Read the effective value back off the same cast with Get Chord Requirement With Defaults (Mapping Name, Slot), which returns the player's override when there is one and the trigger's inline Default Chord otherwise.
3. Validate before committing
Before writing a chord, call FindChordConflict (BlueprintPure) so two actions cannot end up on the same key with the same chord. It returns the first conflicting mapping + slot.
FName ConflictMapping; EPlayerMappableKeySlot ConflictSlot;if (UserSettings->FindChordConflict(Subsystem, TEXT("Ability1"),EPlayerMappableKeySlot::First, NewChord, ConflictMapping, ConflictSlot)){ShowConflictWarning(ConflictMapping, ConflictSlot);return; // do not commit}UserSettings->SetChordRequirement(TEXT("Ability1"), EPlayerMappableKeySlot::First, NewChord);
ClearChordRequirement removes one override; ClearAllChordRequirements resets them all; HasChordRequirement (BlueprintPure) tests for one.
4. Show the chord glyph
UCrimsonInputDisplayStatics::GetActionDisplayText (BlueprintPure, Input/CrimsonInputDisplayStatics.h) collapses the whole lookup - the player's applied mappings -> the bound key for the device in their hands -> the chord on that mapping (override, else the inline default) -> formatted text - into one call. Use it for key hints and action bars.
Get Action Display Text (Local Player = Get Owning Local Player, Action = the UInputAction - resolve it from your config with Find Ability Input Action For Tag - b Long Display Name = unticked for a short label) -> Set Text (Text) on your key-hint TextBlock. The Return Value reads Shift+E, or just E when the chord is empty, and comes back empty when the action has no applied mapping. Search the node under Crimson | Input.
ChordMappings is SaveGame).See also
- How-To: Get the Building Blocks - getting the user settings (and the two Project Settings toggles).
- How-To: Add Modifier-Key Chords - the inline, non-rebindable path.
- Concept: The Chord System - how overrides win over defaults and how injection works.