# V2 Global Input Remapping

This runbook covers `TODOS.phase-72.72.13.2.1`: remapping any game action to any
input on any device and persisting those remaps per player.

## Runtime Surface

Global input remapping extends the existing V2Input rebind slot table model:

- profile: `FV2GlobalInputRemapProfile`
- override: `FV2InputRemapOverride`
- resolved binding: `FV2ResolvedInputRemapBinding`
- default slot table: `FV2InputRebindSlotTable`
- source library: `UV2InputBlueprintLibrary`
- persistence snapshot: `FV2PlayerSettingsSnapshot`
- save game: `UV2SaveGame`
- persistence subsystem: `UV2PersistenceSubsystem`
- contract:
  `V2/ue/Content/V2/Input/Remapping/GlobalInputRemapping_V2_Contract.json`
- focused checker: `V2/ue/Tools/check-v2-global-input-remapping.py`

## Behavior

`FV2GlobalInputRemapProfile` stores player-authored overrides by platform,
control scheme, and mapping slot. Each override can replace the primary binding,
secondary binding, or both. Binding tokens are stable `FName` values so the save
payload remains device-agnostic and does not need hard object references.

The system intentionally supports cross-device remaps. A player can bind a game
action from a PS5, Xbox, PC gamepad, keyboard/mouse, Switch, touch, fight stick,
or adaptive controller profile to any stable device token. The slot table still
owns the action catalog and validates that the target game action exists.

## Conflict Handling

Remaps are applied to a candidate profile first. The candidate is rejected if
its effective binding set conflicts with any primary or secondary token in the
target slot table. Rejected overrides do not replace the last valid profile.

## Persistence

`FV2PlayerSettingsSnapshot` stores `InputRemapProfile` with startup flags.
`UV2SaveGame::SaveInputRemapProfile` persists a validated profile per player,
`GetStartupInputRemapProfile` resolves it on startup, and
`MarkInputRemapsAppliedOnStartup` records the before-gameplay apply time.
`ValidateSave` rejects remap profiles whose account id does not match the save
header.

## Verification

Run these checks after changing global input remapping:

```bash
python3 V2/ue/Tools/check-v2-global-input-remapping.py
python3 V2/ue/Tools/check-v2-input-mapping-contexts.py
python3 V2/ue/Tools/check-v2-profile-save-game.py
python3 V2/ue/Tools/check-v2-persistence-module.py
python3 V2/ue/Tools/check-v2-ci-workflow.py
python3 V2/tools/validate-v2-docs.py
python3 -m py_compile V2/ue/Tools/check-v2-global-input-remapping.py V2/ue/Tools/check-v2-ci-workflow.py
python3 -m json.tool V2/ue/Content/V2/Input/Remapping/GlobalInputRemapping_V2_Contract.json
```

Automation coverage:

- `V2.Input.Module`
- `V2.Persistence.Module`
- `V2.Persistence.ProfileSave.AssetContract`

## Horde Gates

- `global-input-remapping-source`
- `global-input-remapping-any-action-any-device`
- `global-input-remapping-conflict-rejection`
- `global-input-remapping-per-player-persistence`
- `global-input-remapping-startup-apply`
- `global-input-remapping-ci-wired`
