fix library and input

This commit is contained in:
max 2024-07-05 23:22:11 +02:00
parent 1e1ed303ad
commit 7cbb745721
2 changed files with 42 additions and 63 deletions

View File

@ -66,6 +66,7 @@ public Controller(GraphicsDevice graphicsDevice, Window mainWindow, Color clearC
UniformBufferCount = 1,
};
imGuiVertexShader = new Shader(graphicsDevice, Path.Combine(shaderContentPath, "imgui-vertex.spv"), "main", in vertexCreateInfo);
ShaderCreateInfo fragCreateInfo = new ShaderCreateInfo {
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
@ -204,46 +205,46 @@ private void UpdateInput()
io.MouseWheel = Mouse.GetWheel();
//io.AddKeyEvent(ImGuiKey.A, Keyboard.IsKeyDown(Key.A));
//io.AddKeyEvent(ImGuiKey.Z, Keyboard.IsKeyDown(Key.Z));
//io.AddKeyEvent(ImGuiKey.Y, Keyboard.IsKeyDown(Key.Y));
//io.AddKeyEvent(ImGuiKey.X, Keyboard.IsKeyDown(Key.X));
//io.AddKeyEvent(ImGuiKey.C, Keyboard.IsKeyDown(Key.C));
//io.AddKeyEvent(ImGuiKey.V, Keyboard.IsKeyDown(Key.V));
io.AddKeyEvent(ImGuiKey.A, Keyboard.IsKeyDown(Key.A));
io.AddKeyEvent(ImGuiKey.Z, Keyboard.IsKeyDown(Key.Z));
io.AddKeyEvent(ImGuiKey.Y, Keyboard.IsKeyDown(Key.Y));
io.AddKeyEvent(ImGuiKey.X, Keyboard.IsKeyDown(Key.X));
io.AddKeyEvent(ImGuiKey.C, Keyboard.IsKeyDown(Key.C));
io.AddKeyEvent(ImGuiKey.V, Keyboard.IsKeyDown(Key.V));
//io.AddKeyEvent(ImGuiKey.Tab, Keyboard.IsKeyDown(Key.Tab));
//io.AddKeyEvent(ImGuiKey.LeftArrow, Keyboard.IsKeyDown(Key.Left));
//io.AddKeyEvent(ImGuiKey.RightArrow, Keyboard.IsKeyDown(Key.Right));
//io.AddKeyEvent(ImGuiKey.UpArrow, Keyboard.IsKeyDown(Key.Up));
//io.AddKeyEvent(ImGuiKey.DownArrow, Keyboard.IsKeyDown(Key.Down));
//io.AddKeyEvent(ImGuiKey.Enter, Keyboard.IsKeyDown(Key.Enter));
//io.AddKeyEvent(ImGuiKey.Escape, Keyboard.IsKeyDown(Key.Escape));
//io.AddKeyEvent(ImGuiKey.Delete, Keyboard.IsKeyDown(Key.Delete));
//io.AddKeyEvent(ImGuiKey.Backspace, Keyboard.IsKeyDown(Key.Backspace));
//io.AddKeyEvent(ImGuiKey.Home, Keyboard.IsKeyDown(Key.Home));
//io.AddKeyEvent(ImGuiKey.End, Keyboard.IsKeyDown(Key.End));
//io.AddKeyEvent(ImGuiKey.PageDown, Keyboard.IsKeyDown(Key.PageDown));
//io.AddKeyEvent(ImGuiKey.PageUp, Keyboard.IsKeyDown(Key.PageUp));
//io.AddKeyEvent(ImGuiKey.Insert, Keyboard.IsKeyDown(Key.Insert));
io.AddKeyEvent(ImGuiKey.Tab, Keyboard.IsKeyDown(Key.Tab));
io.AddKeyEvent(ImGuiKey.LeftArrow, Keyboard.IsKeyDown(Key.Left));
io.AddKeyEvent(ImGuiKey.RightArrow, Keyboard.IsKeyDown(Key.Right));
io.AddKeyEvent(ImGuiKey.UpArrow, Keyboard.IsKeyDown(Key.Up));
io.AddKeyEvent(ImGuiKey.DownArrow, Keyboard.IsKeyDown(Key.Down));
io.AddKeyEvent(ImGuiKey.Enter, Keyboard.IsKeyDown(Key.Enter));
io.AddKeyEvent(ImGuiKey.Escape, Keyboard.IsKeyDown(Key.Escape));
io.AddKeyEvent(ImGuiKey.Delete, Keyboard.IsKeyDown(Key.Delete));
io.AddKeyEvent(ImGuiKey.Backspace, Keyboard.IsKeyDown(Key.Backspace));
io.AddKeyEvent(ImGuiKey.Home, Keyboard.IsKeyDown(Key.Home));
io.AddKeyEvent(ImGuiKey.End, Keyboard.IsKeyDown(Key.End));
io.AddKeyEvent(ImGuiKey.PageDown, Keyboard.IsKeyDown(Key.PageDown));
io.AddKeyEvent(ImGuiKey.PageUp, Keyboard.IsKeyDown(Key.PageUp));
io.AddKeyEvent(ImGuiKey.Insert, Keyboard.IsKeyDown(Key.Insert));
//io.AddKeyEvent(ImGuiKey.ModCtrl, Keyboard.IsKeyDown(Key.LeftControl) || Keyboard.IsKeyDown(Key.RightControl));
//io.AddKeyEvent(ImGuiKey.ModShift, Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
//io.AddKeyEvent(ImGuiKey.ModAlt, Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt));
//io.AddKeyEvent(ImGuiKey.ModSuper, Keyboard.IsKeyDown(Key.LeftSuper) || Keyboard.IsKeyDown(Key.RightSuper));
io.AddKeyEvent(ImGuiKey.ModCtrl, Keyboard.IsKeyDown(Key.LeftControl) || Keyboard.IsKeyDown(Key.RightControl));
io.AddKeyEvent(ImGuiKey.ModShift, Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
io.AddKeyEvent(ImGuiKey.ModAlt, Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt));
io.AddKeyEvent(ImGuiKey.ModSuper, Keyboard.IsKeyDown(Key.LeftSuper) || Keyboard.IsKeyDown(Key.RightSuper));
//ReadOnlySpan<char> input = Keyboard.GetTextInput();
//if (!input.IsEmpty)
//{
// foreach (char c in input)
// {
// if (c == '\t')
// {
// break;
// }
ReadOnlySpan<char> input = Keyboard.GetTextInput();
if (!input.IsEmpty)
{
foreach (char c in input)
{
if (c == '\t')
{
break;
}
// io.AddInputCharacter(c);
// }
//}
io.AddInputCharacter(c);
}
}
}
private unsafe void UpdateMonitors()
@ -505,32 +506,8 @@ private void CreateWindow(ImGuiViewportPtr vp)
{
WindowCreateInfo info = new WindowCreateInfo("Window Title", (uint)vp.Pos.X, (uint)vp.Pos.Y, ScreenMode.Windowed);
//SDL2.SDL.SDL_WindowFlags flags = graphicsDevice.WindowFlags;
//flags |= SDL2.SDL.SDL_WindowFlags.SDL_WINDOW_HIDDEN;
//if ((vp.Flags & ImGuiViewportFlags.NoTaskBarIcon) != 0)
//{
// flags |= SDL2.SDL.SDL_WindowFlags.SDL_WINDOW_SKIP_TASKBAR;
//}
//if ((vp.Flags & ImGuiViewportFlags.NoDecoration) != 0)
//{
// flags |= SDL2.SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS;
// info.SystemResizable = false;
//}
//else
//{
// flags |= SDL2.SDL.SDL_WindowFlags.SDL_WINDOW_RESIZABLE;
// info.SystemResizable = true;
//}
//if ((vp.Flags & ImGuiViewportFlags.TopMost) != 0)
//{
// flags |= SDL2.SDL.SDL_WindowFlags.SDL_WINDOW_ALWAYS_ON_TOP;
//}
Window window = new Window(graphicsDevice, info);
graphicsDevice.ClaimWindow(window, SwapchainComposition.SDR, PresentMode.Immediate);
graphicsDevice.ClaimWindow(window, SwapchainComposition.SDR, PresentMode.Immediate); // What PresentMode do we need?
GCHandle handle = GCHandle.Alloc(window);
vp.PlatformUserData = (IntPtr)handle;
@ -652,6 +629,8 @@ public void Dispose()
foreach (KeyValuePair<Window, GCHandle> window in windows)
{
if (window.Key == mainWindow) continue;
graphicsDevice.UnclaimWindow(window.Key);
window.Key.Dispose();
window.Value.Free();

BIN
libs/x64/cimgui.dll (Stored with Git LFS)

Binary file not shown.