I coded a controls menu that allows users to press a button, which triggers the following code
func _unhandled_input(event):
if !event.is_action_pressed("ui_cancel"):
match keyInput:
(...)
3:
if event is InputEventKey and event.pressed:
var interact = InputMap.get_action_list("interact")
InputMap.action_erase_event("interact",interact[0])
InputMap.action_add_event("interact", event)
get_node("Node2D/Node2D/Button3").text = InputMap.get_action_list("interact")[0].as_text()
keyInput = 0
This works great. I press, say, the move up button, press a key, and that key is my new move up input command.
The issue is for assigning mouse button inputs. The below code, which executes when match keyInput == 1 or 2, only picks up scroll wheel movement, and even that not always:
if event is InputEventMouseButton and event.pressed:
var fire = InputMap.get_action_list("fire")
InputMap.action_erase_event("fire",fire[0])
InputMap.action_add_event("fire", event)
get_node("Node2D/Node2D/Button").text = buttonNames[event.button_index]
keyInput = 0
I tried moving the mouse input section to _input(event), but then it doesn't even pick up scroll wheel movement, which makes me think the issue resides in this executing in the event loop. What am I missing here?