From 99eb846a066e86d6627f9b1ef3d05cbf01a22d58 Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 7 Jul 2026 01:19:33 -0700 Subject: [PATCH] fix for updated imgui. --- attachments/sync2_engine/CMakeLists.txt | 2 ++ attachments/sync2_engine/imgui_system.cpp | 34 +++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/attachments/sync2_engine/CMakeLists.txt b/attachments/sync2_engine/CMakeLists.txt index 3ee1acc4..541843ef 100644 --- a/attachments/sync2_engine/CMakeLists.txt +++ b/attachments/sync2_engine/CMakeLists.txt @@ -146,6 +146,8 @@ set(SOURCES_COMMON imgui_system.cpp ${SIMPLE_ENGINE_DIR}/imgui/imgui.cpp ${SIMPLE_ENGINE_DIR}/imgui/imgui_draw.cpp + ${SIMPLE_ENGINE_DIR}/imgui/imgui_tables.cpp + ${SIMPLE_ENGINE_DIR}/imgui/imgui_widgets.cpp ${SIMPLE_ENGINE_DIR}/vulkan_device.cpp pipeline.cpp ${SIMPLE_ENGINE_DIR}/descriptor_manager.cpp diff --git a/attachments/sync2_engine/imgui_system.cpp b/attachments/sync2_engine/imgui_system.cpp index 95fb1f36..3e008116 100644 --- a/attachments/sync2_engine/imgui_system.cpp +++ b/attachments/sync2_engine/imgui_system.cpp @@ -548,13 +548,23 @@ void ImGuiSystem::HandleMouse(float x, float y, uint32_t buttons) { ImGuiIO& io = ImGui::GetIO(); - // Update mouse position - io.MousePos = ImVec2(x, y); + // Update mouse position (v1.87+ event API) + io.AddMousePosEvent(x, y); + + // Update mouse buttons (v1.87+ event API) + // We compare with current state to send events only on change + static uint32_t lastButtons = 0; + if ((buttons & 0x01) != (lastButtons & 0x01)) { + io.AddMouseButtonEvent(0, (buttons & 0x01) != 0); + } + if ((buttons & 0x02) != (lastButtons & 0x02)) { + io.AddMouseButtonEvent(1, (buttons & 0x02) != 0); + } + if ((buttons & 0x04) != (lastButtons & 0x04)) { + io.AddMouseButtonEvent(2, (buttons & 0x04) != 0); + } - // Update mouse buttons - io.MouseDown[0] = (buttons & 0x01) != 0; // Left button - io.MouseDown[1] = (buttons & 0x02) != 0; // Right button - io.MouseDown[2] = (buttons & 0x04) != 0; // Middle button + lastButtons = buttons; } void ImGuiSystem::HandleKeyboard(uint32_t key, bool pressed) { @@ -564,17 +574,11 @@ void ImGuiSystem::HandleKeyboard(uint32_t key, bool pressed) { ImGuiIO& io = ImGui::GetIO(); - // Update key state + // Update key state (v1.87+ event API) + // GLFW key codes are compatible with ImGuiKey values in modern ImGui backends if (key < 512) { - io.KeysDown[key] = pressed; + io.AddKeyEvent((ImGuiKey)key, pressed); } - - // Update modifier keys - // Using GLFW key codes instead of Windows-specific VK_* constants - io.KeyCtrl = io.KeysDown[341] || io.KeysDown[345]; // Left/Right Control - io.KeyShift = io.KeysDown[340] || io.KeysDown[344]; // Left/Right Shift - io.KeyAlt = io.KeysDown[342] || io.KeysDown[346]; // Left/Right Alt - io.KeySuper = io.KeysDown[343] || io.KeysDown[347]; // Left/Right Super } void ImGuiSystem::HandleChar(uint32_t c) {