managed to make a solution thanks to the @Locher from post:
How do I rebind keybinds from a string
#region binding
var change_input_map := ""
var binding_node_string
enum keys{
forward = 1,
back = 2,
left = 3,
right = 4,
jump = 5
}
## from g_man
func load_keys():
for i in keys:
load_key(i)
func load_key(key_string):
var table = DataBase.Table.new("bindings")
table.create_column(false, g_man.dbms, DataBase.DataType.INT, 1, key_string)
var keycode = DataBase.select(false, g_man.dbms, "bindings", key_string, 1)
if keycode > 5:
var event_key:InputEventKey = InputEventKey.new()
event_key.keycode = keycode
InputMap.action_erase_events(key_string)
InputMap.action_add_event(key_string, event_key)
else:
var event_key:InputEventMouseButton = InputEventMouseButton.new()
event_key.button_index = keycode
InputMap.action_erase_events(key_string)
InputMap.action_add_event(key_string, event_key)
func _change_binding(index:int):
binding_node_string = str(index)
finished = _finish_binding
change_input_map = keys.find_key(index)
pass
func _finish_binding(event):
var node = get_node("bindings/HBoxContainer/MarginContainer/VBoxContainer/binding container" + binding_node_string + "/change binding")
node.text = str(event.as_text())
if event is InputEventKey:
DataBase.insert(false, g_man.dbms, "bindings", change_input_map, 1, event.keycode)
elif event is InputEventMouseButton:
DataBase.insert(false, g_man.dbms, "bindings", change_input_map, 1, event.button_index)
var finished:Callable
func _input(event):
if change_input_map:
if event is InputEventKey or event is InputEventMouseButton:
if event.is_released():
InputMap.action_erase_events(change_input_map)
InputMap.action_add_event(change_input_map, event)
finished.call(event)
change_input_map = ""
#endregion binding
thanks Locher for mentioning me it notified me.
now I know how to do it for others.