-
Also interesting might be to only add Axis/Actions if they are not defined yet.
void AddAxisIfNotDefined(UInputSettings* Settings, TArray<FInputAxisKeyMapping> DefinedAxis, FInputAxisKeyMapping NewAxis) { for(FInputAxisKeyMapping Action : DefinedAxis) { if(Action.AxisName == NewAxis.AxisName) return; //Dont Add } Settings->AddAxisMapping(NewAxis); } // E.g. in StartupModule UInputSettings* Settings = UInputSettings::GetInputSettings(); const TArray<FInputAxisKeyMapping> DefinedAxis(Settings->AxisMappings); AddAxisIfNotDefined(Settings, DefinedAxis, FInputAxisKeyMapping(TEXT("VRSimulatorRight"), EKeys::D, 1)); AddAxisIfNotDefined(Settings, DefinedAxis, FInputAxisKeyMapping(TEXT("VRSimulatorRight"), EKeys::A, -1));
If the user now changes the bindings, they are not forcefully added back on restart
Note: The settings are not directly stored into the
DefaultInput.ini
, but in theSaved/Config/Windows/Input.ini
and are copied over if changes are made in the editor UIBy Sebastian Pape on 2020-04-06T14:46:25 (imported from GitLab)
Edited by Jan Delember
Please register or sign in to comment