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

34 lines
791 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)
remap_button.display_key()
remap_button = null
set_process_unhandled_key_input(false)
pass