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

Imgui Demo Delayed key presses #72215

Closed
Brambor opened this issue Mar 6, 2024 · 2 comments · Fixed by #72318
Closed

Imgui Demo Delayed key presses #72215

Brambor opened this issue Mar 6, 2024 · 2 comments · Fixed by #72318
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds Info / User Interface Game - player communication, menus, etc. (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@Brambor
Copy link
Contributor

Brambor commented Mar 6, 2024

Describe the bug

When pressing W multiple times, the "key-down" switches between W and : W W W and is one more behind with each key press. If you don't press enough keys, the rest is in the queue. You can go through the queue by wiggling the cursor for a short while.
This is interesting, because if different keys are pressed (like dbs), then they are shown without being late D B S
image

All in all, going through the demo menu is a bit painful, as the cursor has to be wiggled after each mouse click so that the mouse click is registered.

Attach save file

N/A

Steps to reproduce

  1. Launch Game
  2. Main Menu
  3. Options
  4. Imgui Demo Screen
  5. Inputs & Focus
  6. Write WWWAAABCDEFGHI (It ends at E) wiggle mouse (cleared).
  7. Write ASDFGHJ. See the difference (the second writes as expected, the first)

Expected behavior

Actions aren't delayed.

Screenshots

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.4046 (22H2)
  • Game Version: 0.G-7829-g4e5599a7c0-dirty [64-bit] (build on 58cef75 )
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

Additional context

You can see the same issues when writing text.
It has been fixed for writing text when searching in Keybindings.

You can see in
4. Imgui Demo Screen
5. Widgets
6. Plotting
That some graphs don't redraw at all, as Imgui isn't redrawn. That is not an issue. But not processing input right away is.

(still picture of plots that aren't animated........)
image

@Brambor Brambor added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Mar 6, 2024
@Brambor Brambor changed the title Imgui Demo progressbar etc. wait for mouse movement Imgui Demo Delayed key presses Mar 6, 2024
@ZeroInternalReflection
Copy link
Contributor

I noticed some of this behaviour on curses, but not on tiles. After a bit of testing, I'm thinking that's probably because my mouse is twitchy enough that I was regularly triggering MOUSE_MOVE on the tiles build.

It looks like the main difference in the input loop between the ImGui Popup/Keybinding screens and the demo screen is that I did not set a timeout for the input context on the demo screen. That means that the screen is only refreshed when there's "valid" input, even if ImGui is doing it's own changes behind the scenes.

Before video (including the delayed text input/mouse clicks and animation issues):
https://github.com/CleverRaven/Cataclysm-DDA/assets/89038572/aef1f1d1-26c1-433c-b281-32b9547fdca3

After this modification:

diff --git a/src/main_menu.cpp b/src/main_menu.cpp
index 7645cd5be1b..cf9d12fc805 100644
--- a/src/main_menu.cpp
+++ b/src/main_menu.cpp
@@ -104,6 +104,8 @@ void demo_ui::run()
     ctxt.register_action( "HELP_KEYBINDINGS" );
     std::string action;
 
+    ctxt.set_timeout( 50 );
+
     ui_manager::redraw();
 
     while( is_open ) {
ImGui_Demo_After_with_set_timeout.mp4

Note that text input appears immediately but briefly and keyboard controls seem to work as expected.
The animation is still a bit wonky, but that's because you can increase the frame rate by wiggling the mouse (watch the average ms/frame when the cursor moves vs. when it's still)

Currently, the ImGui popup and keybinding screens only have an input timeout on Tiles/Windows builds, but I think it would actually solve some of the problems I'm having on curses. A bit more testing is required, but as long as nothing else goes wrong it should be a simple fix

@RenechCDDA RenechCDDA added Info / User Interface Game - player communication, menus, etc. (S2 - Confirmed) Bug that's been confirmed to exist ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Mar 7, 2024
@RenechCDDA
Copy link
Member

Late to the party but this came up yesterday in the development discord (starting at https://discord.com/channels/598523535169945603/598529174302490644/1214941012049535036 ). I've only seen it happening in the imgui demo menu, but per Katemonster:

"Yeah this is a symptom of ImGui not being redrawn enough. Setting a timeout on your input_context will alleviate it for a screen you're working on"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds Info / User Interface Game - player communication, menus, etc. (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants