Browse Source

Remove stl dependency
update to new premake
update MSVC project generation to 2026

Jeffery Myers 3 weeks ago
parent
commit
286e11acd6
6 changed files with 28 additions and 9 deletions
  1. 9 0
      examples/simple.cpp
  2. 1 1
      premake-VisualStudio.bat
  3. BIN
      premake5
  4. BIN
      premake5.exe
  5. BIN
      premake5.osx
  6. 18 8
      rlImGui.cpp

+ 9 - 0
examples/simple.cpp

@@ -68,6 +68,15 @@ int main(int argc, char* argv[])
 		// end ImGui Content
 		rlImGuiEnd();
 
+		if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
+			DrawText("Prssed", 0, 0, 20, RED);
+
+		if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
+			DrawText("Down", 0, 20, 20, GREEN);
+
+		if (IsWindowFocused())
+			DrawText("Focused", 100, 20, 20, WHITE);
+
 		EndDrawing();
 		//----------------------------------------------------------------------------------
 	}

+ 1 - 1
premake-VisualStudio.bat

@@ -1,2 +1,2 @@
-premake5.exe vs2022
+premake5.exe vs2026
 pause

BIN
premake5


BIN
premake5.exe


BIN
premake5.osx


+ 18 - 8
rlImGui.cpp

@@ -37,7 +37,6 @@
 #include "imgui.h"
 
 #include <math.h>
-#include <map>
 #include <limits>
 #include <cstdint>
 
@@ -50,7 +49,9 @@ static MouseCursor MouseCursorMap[ImGuiMouseCursor_COUNT];
 
 ImGuiContext* GlobalContext = nullptr;
 
-static std::map<KeyboardKey, ImGuiKey> RaylibKeyMap;
+static constexpr size_t MAX_RAYLIB_KEY = 349;
+static ImGuiKey RaylibKeyMap[MAX_RAYLIB_KEY];
+static bool KeyMapInitialized = false;
 
 static bool LastFrameFocused = false;
 
@@ -327,9 +328,13 @@ void rlImGuiEndInitImGui(void)
 
 static void SetupKeymap(void)
 {
-    if (!RaylibKeyMap.empty())
+    if (KeyMapInitialized)
         return;
 
+    KeyMapInitialized = true;
+
+    memset(RaylibKeyMap, 0, MAX_RAYLIB_KEY * sizeof(ImGuiKey));
+
     // build up a map of raylib keys to ImGuiKeys
     RaylibKeyMap[KEY_APOSTROPHE] = ImGuiKey_Apostrophe;
     RaylibKeyMap[KEY_COMMA] = ImGuiKey_Comma;
@@ -838,12 +843,17 @@ bool ImGui_ImplRaylib_ProcessEvents(void)
     LastSuperPressed = superDown;
 
     // walk the keymap and check for up and down events
-    for (const auto keyItr : RaylibKeyMap)
+	for (int keyItr = 0; keyItr < MAX_RAYLIB_KEY; keyItr++)
     {
-        if (IsKeyReleased(keyItr.first))
-            io.AddKeyEvent(keyItr.second, false);
-        else if(IsKeyPressed(keyItr.first))
-            io.AddKeyEvent(keyItr.second, true);
+        const auto key = RaylibKeyMap[keyItr];
+
+        if (key == 0)
+            continue;
+
+        if (IsKeyReleased(keyItr))
+            io.AddKeyEvent(key, false);
+        else if(IsKeyPressed(keyItr))
+            io.AddKeyEvent(key, true);
     }
 
     if (io.WantCaptureKeyboard)