-
Notifications
You must be signed in to change notification settings - Fork 186
Description
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".
Code such as ImGui::IsKeyDown(ImGuiKey_Q) is supposed to work for backends that are up to date with ImGui v1.87, but imgui-sfml never reports to ImGui that that key was pressed, because in the past the set of available keys was limited:
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".
How I was running this:
diff --git a/examples/minimal/main.cpp b/examples/minimal/main.cpp
index 2c19abd08..e0561a94b 100644
--- a/examples/minimal/main.cpp
+++ b/examples/minimal/main.cpp
@@ -12,6 +12,10 @@ int main() {
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
+ ImGuiIO& io = ImGui::GetIO();
+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
+
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
c++ -I. -I./imgui examples/minimal/main.cpp imgui-SFML.cpp ./imgui/{imgui_demo.cpp,imgui_widgets.cpp,imgui.cpp,imgui_draw.cpp,imgui_tables.cpp} -lsfml-graphics -lsfml-window -lsfml-system -lGL && ./a.out
And here's how I was running with ImGui's own SDL backend, to be able to compare:
c++ -I. -Ibackends -I/usr/include/SDL2 -lSDL2 -lGL examples/example_sdl_opengl3/main.cpp backends/imgui_impl_opengl3.cpp backends/imgui_impl_sdl.cpp imgui_demo.cpp imgui_widgets.cpp imgui.cpp imgui_draw.cpp imgui_tables.cpp && ./a.out