Hi everyone,
I’m currently trying to implement mappable keys with the Enhanced Input System but, when I try to change a mappable key by using the function AddPlayerMappedKey of the EnhancedInputLocalPlayerSubsystem I get the following warning.
IEnhancedInputSubsystemInterface::AddPlayerMappedKeyInSlot Failed! Reasoning: (GameplayTags=((TagName="InputUserSettings.FailureReasons.NoMappingRowFound")))
Here’s what I did.
I’ve created an InputAction to move my player, and I’ve added it my InputMappingContext. Then in my Mapping Context, I’ve set all my keys to be mappable and I gave them a unique Name and a Display Name.
I know that this part is correct because when I open my menu, I can get and display all my mappable keys by calling GetAllPlayerMappableActionKeyMappings on the EnhancedInputLocalPlayerSubsystem. Here’s my code on my widget to display the mappable keys.
UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());
if (EnhancedInputSubsystem)
{
// For each key, create a key widget and add it to the Keybinding vertical box
TArray<FEnhancedActionKeyMapping> BindableKeys = EnhancedInputSubsystem->GetAllPlayerMappableActionKeyMappings();
for (FEnhancedActionKeyMapping& Key : BindableKeys)
{
FText KeyName = Key.GetDisplayName();
UKeyMappingWidget* NewKeyWidget = Cast<UKeyMappingWidget>(CreateWidget<UKeyMappingWidget>(this, KeybindingsWidget));
if (NewKeyWidget)
{
KeybindingsVerticalBox->AddChild(NewKeyWidget);
NewKeyWidget->SetInputName(KeyName);
NewKeyWidget->SetInputSelector(Key);
}
}
}
I’m using a Widget to display those keys, and I’ve got an Input Selector in it so I can plug myself on the OnKeySelected event.
void UKeyMappingWidget::NativeConstruct()
{
Super::NativeConstruct();
InputSelector->OnKeySelected.AddUniqueDynamic(this, &UKeyMappingWidget::OnKeySelected);
}
When the event is called, I’m sending the new Key selected with the Mapping Name to the EnhancedInputLocalPlayerSubsystem with the function AddPlayerMappedKey but all I get is the warning that I’ve print on the beginning of this topic.
Her’s my code of the call.
UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer());
if (!EnhancedInputSubsystem)
{
return;
}
EnhancedInputSubsystem->AddPlayerMappedKey(MappingName,NewKey);
I’m probaly missing something in the procress and I can’t find what it is.
I’ve tried to follow step by step the process of AddPlayerMappedKey and I saw that at some point, we end up in the UEnhancedInputUserSettings::MapPlayerKey.
Here we’ll be calling 2 functions that will try to see if in the TMap PlayerMappedKeys of the EnhancedPlayerMappableKeyProfile, our key exist. (those functions are UEnhancedPlayerMappableKeyProfile::FindKeyMapping and FindKeyMappingRowMutable).
The thing is that this TMap is always empty for me, it can’t be set manually and it has the UPROPERTY Transient.
I don’t really understand how it’s supposed to get its data.
Can you please help me with that ? I might have forgot something in the process but I can’t really see what it is.
Thanks in advance.