This repository has been archived on 2024-07-02. You can view files and clone it, but cannot push or open issues or pull requests.
HoppyEaster/Scripts/UI/Remaping/RemapController.gd

36 lines
891 B
GDScript

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
pass
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)
pass
func remap_key(event):
print(event)
# Do Actual Rebinding
for key in InputMap.action_get_events(remap_action):
InputMap.action_erase_event(remap_action, key)
InputMap.action_add_event(remap_action, event)
print(event.as_text_keycode())
#Save.game_data["%s" % [remap_action]] = event.get_text_keycode()
remap_button.display_key()
remap_button = null
set_process_unhandled_key_input(false)
pass