As @gertkeno said, it’s not common to rename input actions. Misspelling them shouldn’t be a problem either, as most functions that take them will provide auto-completion.
Still, if you don’t want to use strings then you could generate a script with the input event names as static variables. For example, you could use an EditorScript like:
@tool
extends EditorScript
func _run() -> void:
InputMap.load_from_project_settings()
var inputs = InputMap.get_actions().filter(func(input_name:StringName): return input_name.find(".") == -1)
var inputs_string = "\n".join(inputs.map(func(input): return 'static var {name}:StringName = &"{name}"'.format({"name": input})))
var script_content = \
"""
class_name InputActions extends RefCounted
{inputs}
""".format({"inputs": inputs_string})
print(script_content)
var script = GDScript.new()
script.source_code = script_content
ResourceSaver.save(script, 'res://input_actions.gd')
Will create a script input_actions.gd like:
class_name InputActions extends RefCounted
static var ui_accept:StringName = &"ui_accept"
static var ui_select:StringName = &"ui_select"
static var ui_cancel:StringName = &"ui_cancel"
static var ui_focus_next:StringName = &"ui_focus_next"
# ... more here
This wouldn’t update when you change them because EditorScripts are short-lived and will be deleted once they run. You would need to make a plugin so you can hook into the ProjectSettings.settings_changed and generate the script when they change.
Another option, if you still want to export them in nodes, is to generate the list of actions in Object._get_property_list() like:
@tool
extends Node
var left_action: String
var right_action: String
func _get_property_list() -> Array[Dictionary]:
var actions = []
for prop in ProjectSettings.get_property_list():
var prop_name:String = prop.get("name", "")
if prop_name.begins_with('input/'):
prop_name = prop_name.replace('input/', '')
prop_name = prop_name.substr(0, prop_name.find("."))
if not actions.has(prop_name):
actions.append(prop_name)
var hint_string = ",".join(actions)
var properties: Array[Dictionary] = []
properties.append({
"name": "left_action",
"type": TYPE_STRING_NAME,
"hint": PROPERTY_HINT_ENUM,
"hint_string": hint_string
})
properties.append({
"name": "right_action",
"type": TYPE_STRING_NAME,
"hint": PROPERTY_HINT_ENUM,
"hint_string": hint_string
})
return properties
(You could use PROPERTY_HINT_ENUM_SUGGESTION instead if you want to have the option to type them)
This won’t help you if you rename them later though.