Godot-Input-Remap icon indicating copy to clipboard operation
Godot-Input-Remap copied to clipboard

Input action event does not get properly updated after setting keycode

Open Pheubel opened this issue 1 year ago • 1 comments

context

I am making a menu where the player can rebind certain controls.

godot version: v4.3.stable.official [77dcf97d8] additional plugins: dialogic 2.0-Alpha-15, ActionIcon 1.5

The problem

whenever set_action_key(action, event) is called. The plugin goes through all events on the action until it finds the first key event and then changes the keycode on that event. However, in subsequent calls to get_action_key(action, event), the value of the keycode is reverted to it's default value and the remapped keycode is ignored.

Relevant code snippit

func _on_input(event: InputEvent) -> void:
	if event.is_pressed():
		
		if event is InputEventKey:
			AppConfig.button_remap.set_action_key(action_name, event)
			_handle_action_recieved()
		elif event is InputEventJoypadButton:
			AppConfig.button_remap.set_action_button(action_name, event)
			_handle_action_received()

func _handle_action_received() -> void:
	_button.button_pressed = false
	
	AppConfig.button_remap.create_remap()
	AppConfig.button_remap.apply_remap()

In this case i am keeping the instance of my ControlsRemap resource inside of the AppConfig autoload singleton.

It could be that i am missing a step or am doing something straight up wrong, but i can't figure out what exactly.

Pheubel avatar Oct 17 '24 23:10 Pheubel

I'll need a complete project to investigate, I tried the script and see no problems. Note that you don't need to apply remap after modifying it.

KoBeWi avatar Oct 18 '24 10:10 KoBeWi