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/RemapButton.gd
2023-04-09 17:30:52 +05:30

30 lines
655 B
GDScript

extends Button
@export var input_action_name : String
# Called when the node enters the scene tree for the first timde.d
func _ready():
set_process_unhandled_key_input(false)
pass
func _unhandled_key_input(event):
remap_key(event)
pass
func display_key ():
text = "%s" % InputMap.action_get_events(input_action_name)[0].as_text()
pass
func remap_key(event):
InputMap.action_erase_events(input_action_name)
InputMap.action_add_event(input_action_name, event)
text = "%s" % event.as_text()
pass
func _on_toggled(button_pressed):
set_process_unhandled_key_input(button_pressed)
if button_pressed: text = "..."
else: display_key()
pass