Resetting Input.ini to DefaultInput.ini

In my game I have added remappable keys at runtime, and in C++ I use Settings->SaveKeyMapping() which saves the keymapping to Saved/Config/Windows. My question is how do I reset the input to the default, I want to copy all of the mappings form DefaultInput.ini to Input.ini.

Iā€™d love to know this too.

ForceRebuildKeymaps

I finally figured this out, sharing for future people searching around:

  auto AxisMappings = UInputSettings::GetInputSettings()->GetAxisMappings();
  for(auto mapping : AxisMappings) {
    UInputSettings::GetInputSettings()->RemoveAxisMapping(mapping);
  }
  auto ActionMappings = UInputSettings::GetInputSettings()->GetActionMappings();
  for(auto mapping : ActionMappings) {
    UInputSettings::GetInputSettings()->RemoveActionMapping(mapping);
  }
  UInputSettings::GetInputSettings()->SaveKeyMappings();

  FConfigCacheIni::LoadGlobalIniFile(GInputIni, TEXT("Input"), 0, true, true);
  auto InputSettings = const_cast<UInputSettings*>(GetDefault<UInputSettings>());
  InputSettings->ReloadConfig(InputSettings->GetClass(), *GInputIni, UE4::LCPF_PropagateToInstances);
  InputSettings->SaveKeyMappings();
2 Likes

For those looking for a blueprint solution, it would look something like this.

1 Like