extends Control
var remap_button : Button
var remap_action : String
func _unhandled_key_input(event):
if remap_button != null and event.pressed:
remap_key(event)
pass
func _ready():
set_process_unhandled_key_input(false)
remap_button = null
func start_remap(button : Button, action : String):
if(remap_button != null):
remap_button.display_key()
remap_button = button
remap_action = action
remap_button.text = "..."
set_process_unhandled_key_input(true)
button.release_focus()
func remap_key(event):
for key in InputMap.action_get_events(remap_action):
InputMap.action_erase_event(remap_action, key)
InputMap.action_add_event(remap_action, event)
Save.game_data["%s" % [remap_action]] = event.keycode
remap_button.grab_focus()