Manually override an InputBinding

In the new Input System (1.0.0. preview 7) I cannot find how to manually override a binding. I’ve got working an interactive override system that I want now to be saved and loaded with UserPrefs.

The current script is :

private void Rebind()
{
    rebindingOperation?.Cancel(); 

    void CleanUp()
    {
        rebindingOperation?.Dispose();
        rebindingOperation = null;
    }

    rebindingOperation = action.PerformInteractiveRebinding()
        .WithControlsExcluding("Mouse")
        .WithCancelingThrough("<Keyboard>/escape")
        .WithControlsHavingToMatchPath("<Keyboard>/*")
        .OnMatchWaitForAnother(0.1f)
        .OnCancel(operation => 
        {
            CleanUp();
        })
        .OnComplete(operation =>
        {
            SaveBinding();
            CleanUp();
        })
        .Start();
}

private void SaveBinding()
{
    string pathToSave = action.bindings[0].effectivePath;
    ... Perform save ....
}

My issue is I don’t know how to manually override the binding next time I’ll launch the game.

1 Like

Just found out the answer after writing the question. If it can help anyone:

        InputBinding inputBinding = action.bindings[0];
        inputBinding.overridePath = path;
        action.ApplyBindingOverride(0, inputBinding);

The key was in action.ApplyBindingOverride()