I don’t understand why we do have the same information at two places.
And therefore, do we have to change the action and axis mapping to the UInputSettings OR to the PlayerInput from the Controller.
If you want to add or remove key mappings at runtime you need to get the UInputSettings and pass a FInputActionKeyMapping or FInputAxisMapping to the relevant function. You can find your key mappings stored in Inttermediate->Config->CoalescedSourceConfigs->Input.
UInputSettings *Settings = const_cast<UInputSettings*>(GetDefault<UInputSettings>());
if (Settings)
{
FInputAxisKeyMapping axisMap;
axisMap.AxisName = "TestInput";//Name of the axis map
axisMap.Key = FKey(FName("V"));//The actual input you have to use for that axis or action
axisMap.Scale = 1.0f;
Settings->RemoveAxisMapping(axisMap);
Settings->SaveKeyMappings();
UE_LOG(LogTemp, Warning, TEXT("Setttings altered"));
FInputActionKeyMapping tempMapping;
tempMapping.ActionName = "NewActionMapping";
tempMapping.Key = FKey(FName("U"));
tempMapping.bAlt = false;
tempMapping.bCmd = false;
tempMapping.bCtrl = false;
tempMapping.bShift = false;
Settings->AddActionMapping(tempMapping, true);
Settings->SaveKeyMappings();
//IC = Input Component
IC->BindAction("NewActionMapping", IE_Pressed, this, &AMyPawn::PrintName);
}
Thank you. It works with the UInputSettings.
As I can finally see, when the UInputSettings is changed, the InputSettings from the PlayerController is updated.