Tutorial: Player Mappable Keys using Enhanced Input

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

1 Like

This was very helpful. Thank you!

1 Like

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?

Did you ever figure out of it?

@Patterson @LeoTMad1

Add

[ConsoleVariables]

EnhancedInput.bEnableNameValidation=0

To your DefaultEngine.ini, or just set the var in your console in-editor.

Disclaimer - don’t hold me responsible if anything breaks lol. This allowed me to use the same Name across multiple IMC’s, and in addition, the behavior was as anticipated - changes to ā€œForwardā€ in one IMC propagated to another IMC where ā€œForwardā€ Name was also used