From 493735bade73b92e9b1f93b19134fdcc9151592f Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Wed, 6 Dec 2023 08:42:12 +0300 Subject: [PATCH] Replace keyboard monitor from loop to callback Replace keyboard monitor from loop to callback --- src/editor/Renderer.cpp | 15 +++------------ src/editor/Renderer.h | 2 -- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/editor/Renderer.cpp b/src/editor/Renderer.cpp index 1a091779..7b4c6ec2 100644 --- a/src/editor/Renderer.cpp +++ b/src/editor/Renderer.cpp @@ -38,6 +38,9 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod { g_app->hideGui = !g_app->hideGui; } + + g_app->oldPressed[key] = g_app->pressed[key]; + g_app->pressed[key] = action != GLFW_RELEASE; } void drop_callback(GLFWwindow* window, int count, const char** paths) @@ -349,18 +352,6 @@ void Renderer::renderLoop() oldRightMouse = curRightMouse; curRightMouse = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT); - for (int i = GLFW_KEY_SPACE; i < GLFW_KEY_LAST; i++) - { - oldPressed[i] = pressed[i]; - oldReleased[i] = released[i]; - } - - for (int i = GLFW_KEY_SPACE; i < GLFW_KEY_LAST; i++) - { - pressed[i] = glfwGetKey(window, i) == GLFW_PRESS; - released[i] = glfwGetKey(window, i) == GLFW_RELEASE; - } - DebugKeyPressed = pressed[GLFW_KEY_F1]; anyCtrlPressed = pressed[GLFW_KEY_LEFT_CONTROL] || pressed[GLFW_KEY_RIGHT_CONTROL]; diff --git a/src/editor/Renderer.h b/src/editor/Renderer.h index d395d656..1b06921d 100644 --- a/src/editor/Renderer.h +++ b/src/editor/Renderer.h @@ -217,9 +217,7 @@ class Renderer int oldScroll; bool pressed[GLFW_KEY_LAST]; - bool released[GLFW_KEY_LAST]; bool oldPressed[GLFW_KEY_LAST]; - bool oldReleased[GLFW_KEY_LAST]; bool anyCtrlPressed; bool anyAltPressed;