Skip to content

Alt+PrintScreen with GLFW backend triggers assert with new input queue #4905

@PathogenDavid

Description

@PathogenDavid

Version/Branch of Dear ImGui:

Version: 1.87 WIP
Branch: docking acfc779 (Latest as of today)

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC 19.31.30919 (Visual Studio 2022 17.1.0p2)
Operating System: Windows 10 21H2

My Issue/Question:

Pressing Alt+PrintScreen causes this assert to fail:

imgui/imgui.cpp

Line 1305 in acfc779

IM_ASSERT(ImGui::IsNamedKey(key)); // >= 512

This is happening because this key combination results in ImGui_ImplGlfw_KeyCallback being called with keycode = -1, scancode = 84, action = 1, mods = 4.

The -1 keycode causes ImGui_ImplGlfw_KeyToImGuiKey to return ImGuiKey_None which is then passed to SetKeyEventNativeData:

ImGuiKey imgui_key = ImGui_ImplGlfw_KeyToImGuiKey(keycode);
io.AddKeyEvent(imgui_key, (action == GLFW_PRESS));
io.SetKeyEventNativeData(imgui_key, keycode, scancode); // To support legacy indexing (<1.87 user code)

I haven't had time to dig into the new input queue stuff so it's not totally clear to me whether SetKeyEventNativeData should be tolerant of ImGuiKey_None or if the GLFW backend shouldn't be calling it in the first place in this situation.

Screenshots/Video

Not applicable.

Standalone, minimal, complete and verifiable example:

This bug reproduces in example_glfw_opengl3 without modification.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions