Input handling on Linux

#1

Hi all,

I’ve setup ImGui for Linux (on the Pi), together with OpenGL ES 2.0. The rendering seems to be working fine, but of course input is a bit of a struggle on Linux. The framework that I’ve build does some simple input handling, and I was curious if there is any way that I can properly send this to ImGui, so that ImGui can use this input to do things like move a window (since I assume there is no way to get ImGui to work with Linux input directly).

Would setting the parameters of the Context ImGuiIO do the job? I see some values there with the comment “Fill before calling NewFrame”, and some that seem to be computed from this data.

I’ve tried setting just the MousePos and MouseDown[0] values, since for now all I want to do is move a window, but this doesn’t achieve much yet, what is it that I’m missing?


ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(SCRWIDTH, SCRHEIGHT); // in pixels
io.DeltaTime = deltatime;
io.MousePos = ImVec2(ImVec2(static_cast<float>(mouse.mouseX), static_cast<float>(mouse.mouseY))); // mouseX and mouseY are in pixels
io.MouseDown[0] = GetInput()->GetMouseData().leftButton;

ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();

Kind regards,
David.

0 Likes

#2

Issue is resolved, found that my mouse (0, 0) position was different from ImGui its (0, 0) position. Simple fix, but didn’t come to mind at first.

0 Likes