-
Notifications
You must be signed in to change notification settings - Fork 171
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
Update to use AddKeyEvent, supporting the full key range from v1.87 #197
Conversation
Hello. I'll take a look at it soon as I'm currently very busy with real life stuff... (from what I've seen, it looks correct, just needs some manual testing). Which OSes did you test this on? As for the "Joytick" - feel free to rename it to "Joystick". I have no idea how no one noticed that one before. API/ABI break is okay in our case (since Dear ImGui and SFML don't have make any ABI promises)
Two functions are better than one, imo. |
Only on Arch Linux (KDE, Xorg, NVIDIA)
I definitely noticed, but didn't say anything |
Okay, I see. I'll test it on Ubuntu and Windows 10 a bit later! Please rebase your branch onto the latest master, I'll approve the Gitlab Actions runs (CI was broken) |
Please sync with master again - there are some merge conflicts now. :) |
Tested on Ubuntu 20.04 and Windows 10 - works fine. |
Dear ImGui v1.87 has expanded its support for keyboard and gamepad buttons, and replaced the interface for backends to report the keys. The old way keeps working OK but is deprecated and has big limitations, thus already making "imgui-demo" run with some missing functionality when it's run through "imgui-sfml".
This change implements the new approach. So, (almost) all the keyboard keys and possible gamepad events will be properly reported to ImGui and possible to query.
Fixes #196.
Fixes #174.
I implemented this by following what changes the SDL backend has undergone and trying to make equivalent changes here.
Here you can observe the missing events:
One can just run the default "imgui-demo" and in the current state of imgui-sfml it is missing a lot of information in the "Keyboard, Gamepad & Navigation State".
After this change it matches the SDL backend's behavior.
This is backwards-compatible in the sense that I'm pretty sure all user code will continue working as is.
In particular, both of these keep working the same:
In the table below, "before" means without this change and "after" means with this change.
ImGui::IsKeyDown(sf::Keyboard::Z)
ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Z))
ImGui::IsKeyDown(ImGuiKey_Z)
But Z was one of the keys that was possible to make ImGui aware of.
Q was not one of such keys, hence:
ImGui::IsKeyDown(sf::Keyboard::Q)
ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Q))
ImGui::IsKeyDown(ImGuiKey_Q)
From a different point of view, this is not backwards-compatible because it requires ImGui 1.87 to compile.
If the tables above had a column "ImGui 1.86 after", that would all be "imgui-sfml can't compile".
I also change the deadzone for sticks from 5% to 15%, because that seems much closer to what the SDL backend does.
Additions to the API are also up for discussion.
In particular:
Should we keep the typo "Joytick" consistent?
Should we perhaps merge the L + R pairs of these functions into one function?