InputEventAction remains pressed
Tested versions
- Reproducible in v4.3.stable.official [77dcf97d8], not in v4.2.2.stable.official [15073afe3]
System information
Godot v4.3.stable - Arch Linux
Issue description
InputEventAction with pressed set to true when sent through Input.parse_input_event() continues emitting as pressed until that event_index real key/button is released (or pressed then released if it was not pressed) or until window focus is lost.
This was not the case in 4.2.2, is it intended for action to remain pressed when sending fake InputEventAction?
If it is intentional, is sending another event such as the code below then the intended solution? By the documentation for InputEventAction.event_index, it reads as if it is not:
"The real event index in action this event corresponds to (from events defined for this action in the InputMap). If -1, a unique ID will be used and actions pressed with this ID will need to be released with another InputEventAction."
if event.is_action_pressed(&"ui_up"):
var ev: = InputEventAction.new()
ev.action = &"ui_down"
ev.pressed = true
ev.event_index = 0
Input.parse_input_event(ev)
var ev2: = InputEventAction.new()
ev2.action = &"ui_down"
ev2.pressed = false
ev2.event_index = 0
Input.parse_input_event(ev2)
Steps to reproduce
- download MRP/open project/run project, for 4.3
- press and release
ui_upkey (up arrow) - one
InputEventActionshould be printed to console as well as continuous stream oftrueuntil focus is lost orui_downis pressed and released
If testing in 4.2.2, the ev.event_index = 0 line will need to be commented.
Minimal reproduction project (MRP)
Actions are now tracked per event id (after #84685 and #84943) to improve their reliability. This means that to release an action you need to release all its assigned events.
The following appears to solve the issue for my use case.
static func press_action(action: StringName) -> void:
var event_press: = InputEventAction.new()
event_press.action = action
event_press.pressed = true
event_press.event_index = -1
Input.parse_input_event(event_press)
var event_release: = InputEventAction.new()
event_release.action = action
event_release.pressed = false
event_release.event_index = -1
Input.parse_input_event(event_release)