Skip to content
  • Author

    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 the Saved/Config/Windows/Input.ini and are copied over if changes are made in the editor UI

    By Sebastian Pape on 2020-04-06T14:46:25 (imported from GitLab)

    Edited by Jan Delember
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment