You can add it like this:
@tool
extends EditorScript
func _run() -> void:
# Create the input events
var event_key = InputEventKey.new()
event_key.physical_keycode = KEY_R
var event_joypad = InputEventJoypadButton.new()
event_joypad.button_index = JOY_BUTTON_X
# Create the input dictionary
var input = {
"deadzone": 0.5,
"events": [
event_key,
event_joypad
]
}
# Set the input/<name_of_your_input_action> in the project settings
ProjectSettings.set_setting('input/reload', input)
# Save them
ProjectSettings.save()
# I've not found a way to update the project settings input map editor
# but to restart the whole editor.
#EditorInterface.restart_editor(true)
I’m using an EditorScript
but the same can be done with a plugin.