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
ImGuiIntegration: fix indexing into KeysDown #89
Conversation
Beginning with imgui 1.87 ImGuiKey_* values start at 512, which means we can't use them directly to index io.KeysDown (which has size 512, not coincidentally). This is a quick fix to make the legacy code work. Long-term we need to add support for the new key system introduced in 1.87 which lets us queue a full range of backend-agnostic ImGuiKey with AddKeyEvent().
This fix works fine for my code. |
Codecov Report
@@ Coverage Diff @@
## master #89 +/- ##
==========================================
- Coverage 77.25% 76.88% -0.37%
==========================================
Files 21 21
Lines 941 926 -15
==========================================
- Hits 727 712 -15
Misses 214 214
Continue to review full report at Codecov.
|
I'm particularly interested in this as our change ocornut/imgui#4858 was designed to completely backward compatible, if any code change is required by a backend we have an issue on our side. Seeing the PR I realize how this specific use would indeed cause a problem:
I will add an assert on dear imgui side if a legacy KeyMap[] entry is >=512 and document this specific use a breaking change on our side. |
I tested this and there was already a triggering assert (good), still going to update documentation to mark this use as breaking. |
…ility (#4886) + IO docs update (#4858) mosra/magnum-integration#89
Hmm, so if I understand correctly, this is obsoleted by #93 (which is still a draft), right? Thus nothing to do for me with this one. |
Correct, I'll close this to avoid any confusion 🙇♂️ |
Somewhat bandaid-y fix for #87. The tl;dr is that with imgui >1.86
ImGuiKey_*
don't start at 0, so we need to subtract the first value to indexio.KeysDown
correctly.This isn't a long-term fix since the whole
KeyMap
+KeysDown
thing is deprecated and will be removed in the future.