Skip to content

Simulating keypresses 4.1->4.2 regression #85984

Closed
@Dan2552

Description

@Dan2552

Tested versions

  • Reproducable in 4.2, 4.2.1-rc1
  • Not reproducable in 4.1.3

System information

macOS

Issue description

Input.parse_input_event and/or Input.flush_buffered_events not working as expected (or at least as previous)

Steps to reproduce

Create empty project, 2D scene, drag godot icon into scene to act as a Sprite2D node and add script:

extends Sprite2D

func _ready():
	setup_inputmap()
	press_left(true)

func _process(delta):
	var velocity = Vector2()

	if Input.is_action_pressed("left"):
		velocity.x -= 1

	velocity = velocity.normalized() * 200
	position += velocity * delta

func press_left(pressed: bool):
	var input_event = InputEventAction.new()
	input_event.action = "left"
	input_event.pressed = pressed
	Input.parse_input_event(input_event)
	Input.flush_buffered_events()

func setup_inputmap():
	var action_name = "left"
	InputMap.add_action(action_name)
	var event_key = InputEventKey.new()
	event_key.keycode = KEY_A
	InputMap.action_add_event(action_name, event_key)

In 4.1 the sprite will move left
In 4.2 the sprite will not move

Minimal reproduction project (MRP)

(attached is same as described in steps to reproduce)
playground2.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Very Bad

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions