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

Input.is_action_just_pressed is not returning true after corresponding InputSender.action_down calls. #654

Closed
encrest opened this issue Aug 4, 2024 · 4 comments

Comments

@encrest
Copy link

encrest commented Aug 4, 2024

Versions

(list all versions where you have replicated the bug)
Godot: v4.2.2.stable.official [15073afe3]
GUT: 9.2.1
OS: Windows 10

The Bug

Input.is_action_just_pressed returns false after calling InputSender.action_down on the corresponding action type.

Steps To Reproduce

I was able to reproduce this with the following example code from the documentation:
https://gut.readthedocs.io/en/latest/Input-Sender.html#id1

I copied that example code into a test file, ran the script in vscode (GUT: Run Current Script), and all the tests passed except for the last one "test_when_uai_enabled_flushing_buffer_just_pressed_is_processed_immediately".

Here's the output:

res://scripts/tests/unit/test_gut.gd

  • test_when_uai_enabled_input_not_processed_immediately
    [Passed]
  • test_when_uai_enabled_just_pressed_is_not_processed_immediately
    [Passed]
  • test_when_uai_enabled_waiting_makes_button_pressed
    [Passed]
    [Passed]
  • test_when_uai_enabled_flushig_buffer_sends_input_immediatly
    [Passed]
  • test_disabling_uai_sends_input_immediately
    [Passed]
  • test_when_uai_enabled_flushing_buffer_just_pressed_is_processed_immediately
    [Failed]
    at line 43
    5/6 passed.

==============================================
= Run Summary

res://scripts/tests/unit/test_gut.gd

  • test_when_uai_enabled_flushing_buffer_just_pressed_is_processed_immediately
    [Failed]:
    at line 43

---- Totals ----
Scripts 1
Tests 6
Passing 5
Failing 1
Asserts 7
Time 0.266s

Ran Scripts matching "test_gut.gd"
---- 1 failing tests ----

@bitwes
Copy link
Owner

bitwes commented Aug 4, 2024

This has been fixed in 9.3.0.

@encrest
Copy link
Author

encrest commented Aug 4, 2024

Thanks! It looks like upgrading to GUT 9.3.0 fixed that test (and in my game's test as well), however I noticed when running the example test script again that a different test was failing "test_when_uai_enabled_just_pressed_is_not_processed_immediately", which I'm assuming is expected or possibly related to #642:

PS D:\godot_airplane_game> &"d:\mystuff\SteamLibrary\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" -s res://addons/gut/gut_cmdln.gd -d -gselect="test_gut.gd"
PS D:\godot_airplane_game> Godot Engine v4.2.2.stable.official.15073afe3 - https://godotengine.org
Vulkan API 1.3.260 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 1060 6GB

--- GUT ---
[INFO]: using [C:/Users/Jake/AppData/Roaming/Godot/app_userdata/Godot Airplane Game] for temporary output.
Godot version: 4.2.2
GUT version: 9.3.0

res://scripts/tests/unit/test_gut.gd

  • test_when_uai_enabled_input_not_processed_immediately
    [Passed]
  • test_when_uai_enabled_just_pressed_is_not_processed_immediately
    [Failed]
    at line 18
  • test_when_uai_enabled_waiting_makes_button_pressed
    [Passed]
    [Passed]
  • test_when_uai_enabled_flushig_buffer_sends_input_immediatly
    [Passed]
  • test_disabling_uai_sends_input_immediately
    [Passed]
  • test_when_uai_enabled_flushing_buffer_just_pressed_is_processed_immediately
    [Passed]
    5/6 passed.

==============================================
= Run Summary

res://scripts/tests/unit/test_gut.gd

  • test_when_uai_enabled_just_pressed_is_not_processed_immediately
    [Failed]:
    at line 18

---- Totals ----
Scripts 1
Tests 6
Passing 5
Failing 1
Asserts 7
Time 0.322s

Ran Scripts matching "test_gut.gd"
---- 1 failing tests ----

@encrest encrest closed this as completed Aug 4, 2024
@bitwes
Copy link
Owner

bitwes commented Aug 6, 2024

I think test_when_uai_enabled_just_pressed_is_not_processed_immediately is now an outdated test, or only applies to 3.x and not 4.x.

At first I thought it might be related to setting the use_accumulated_input flag not being set, but that doesn't appear to be the case. I also added an await in after_each and it didn't make the. test pass.

In any case, the code in the docs should have been explicitly setting use_accumulated_input instead of assuming it was set as the text before it states (though this didn't change anything).

extends GutTest

var _sender = InputSender.new(Input)
var _orig_accum_input = Input.use_accumulated_input

func before_all():
    InputMap.add_action("jump")
    Input.use_accumulated_input = true

func after_all():
    Input.use_accumulated_input = _orig_accum_input
    InputMap.erase_action("jump") # I added this too, probably the right thing to do.

@bitwes
Copy link
Owner

bitwes commented Aug 6, 2024

Partially confirmed that this test doesn't apply to 4.x anymore. The tests still pass in 3.x. At some point in Godot 4 the action handling split off a bit from other input handling.

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

No branches or pull requests

2 participants