Godot Version
4.3
Question
I am getting weird input handling. I have an action called “pause” which have Escape and Joypad Button 6 (Start, Xbox Menu, Nintendo +).
this piece of code where i handle showing the pause menu or hide it
func _unhandled_input(event: InputEvent):
if event.is_action_pressed("pause"):
if is_paused == false:
ShowPauseMenu()
else:
HidePauseMenu()
get_viewport().set_input_as_handled()
pass
At first i noticed that when the game window is in active state and i press the escape key on my keyboard the game is paused correctly but when i pause using my controller the game didn’t pause.
And vice-versa, when the game window is not in active state (such as running the game then having the godot editor window focused) and i pause the game with my controller the game pauses fine.
I did some debugging and found out that when the game window is active (in focus) and press escape, the _unhandled_input
run once for escape key press, but when I pause the game with my controller, the _unhandled_input
run twice, first registering my controller input (key number 6) the second time registers escape key press (key number 4194305)
any idea why this is happening and how to resolve it.