An overview of how to set up player mappable keys for your game using Enhanced Input.
https://dev.epicgames.com/community/learning/tutorials/Vp69/unreal-engine-player-mappable-keys-using-enhanced-input
This was very helpful. Thank you!
Thank you for the tutorial @BenjaFriend22!
I’m trying to utilize the slot feature in my input settings menu and seem to have hit a barrier. I can’t set default keys for secondary movement mappings. In the first picture of the tutorial, it looks like Fortnight has the arrow keys as the default secondary mappings for movement. Are they set in an Input Mapping Context?
Lyra’s Melee binding in ShooterCore utilizes the Second slot for the secondary binding of “E”:
“E” is set as the default secondary key in IMC_ShooterGame by inheriting the Player Mappable Key Settings from IA_Melee:
DumpProfileToLog() shows the following:
Melee
Mapping Name: ‘Melee’ Slot: ‘First’ Default Key: ‘C’ Player Mapped Key: ‘C’ HardwareDevice: ‘None::None’ AssociatedInputAction: ‘IA_Melee’
Mapping Name: ‘Melee’ Slot: 'Second’ Default Key: ‘E’ Player Mapped Key: ‘E’ HardwareDevice: ‘None::None’ AssociatedInputAction: ‘IA_Melee’
Under the hood of IMC_ShooterGame, there are two instances of Player Mappable Key Settings with the same Name property, in this case it’s “Melee”.
At some point the first one gets set to Slot “First” and the second to Slot “Second”. Unfortunately, there is a validator which prevents the same Name property from being given to multiple Player Mappable Key Settings in a Input Mapping Context when overriding what’s in the Input Action:
The validator is FEnhancedInputPlayerMappableNameValidator::IsValid() and it prevents the user from inputting text too long to fit in an FName as well as a Name which is already in use. Should the check for already in use be removed? Instead it could ensure there are enough slots for all instances of the Name. EPlayerMappableKeySlot has a max of seven slots, but there is a code comment in the enum suggesting the max is defined in a project setting.
If I’m on the wrong track, is there another method to define default mappings for additional slots I haven’t figured out yet?