Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputEventAction remains pressed #95680

Closed
viraelin opened this issue Aug 17, 2024 · 2 comments
Closed

InputEventAction remains pressed #95680

viraelin opened this issue Aug 17, 2024 · 2 comments

Comments

@viraelin
Copy link

Tested versions

  • Reproducible in v4.3.stable.official [77dcf97], not in v4.2.2.stable.official [15073af]

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

  1. download MRP/open project/run project, for 4.3
  2. press and release ui_up key (up arrow)
  3. one InputEventAction should be printed to console as well as continuous stream of true until focus is lost or ui_down is pressed and released

If testing in 4.2.2, the ev.event_index = 0 line will need to be commented.

Minimal reproduction project (MRP)

43_input_event_action.zip

@KoBeWi
Copy link
Member

KoBeWi commented Aug 17, 2024

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.

@KoBeWi KoBeWi added discussion and removed bug labels Aug 17, 2024
@viraelin
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants