From 674c0232280b5fb6efc12e8ab7a84e6947a0a5c4 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Sun, 12 Jul 2026 20:43:04 +0800 Subject: [PATCH] feat(input): add KeyAction::REPEAT for key repeat events Add a new REPEAT value to the KeyAction enum and update the input callbacks to map GLFW_REPEAT actions to the new value instead of treating them as press. --- include/Cubed/input/key.hpp | 2 +- src/app.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/Cubed/input/key.hpp b/include/Cubed/input/key.hpp index 847ce60..8d01abf 100644 --- a/include/Cubed/input/key.hpp +++ b/include/Cubed/input/key.hpp @@ -123,5 +123,5 @@ enum class Key { NUMPAD_DECIMAL, // . NUMPAD_ENTER }; -enum class KeyAction { PRESS, RELEASE }; +enum class KeyAction { PRESS, RELEASE, REPEAT }; } // namespace Cubed \ No newline at end of file diff --git a/src/app.cpp b/src/app.cpp index 438aa2b..599b024 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -521,10 +521,12 @@ void App::key_callback(GLFWwindow* window, int key, int scancode, int action, return; } - if (action == GLFW_PRESS || action == GLFW_REPEAT) { + if (action == GLFW_PRESS) { act = KeyAction::PRESS; - } else { + } else if (action == GLFW_RELEASE) { act = KeyAction::RELEASE; + } else { + act = KeyAction::REPEAT; } app->dispatch_event(KeyEvent{pkey, act}); @@ -570,10 +572,12 @@ void App::mouse_button_callback(GLFWwindow* window, int button, int action, Logger::error("Unknown Mouse Button {}", button); return; } - if (action == GLFW_PRESS || action == GLFW_REPEAT) { + if (action == GLFW_PRESS) { act = KeyAction::PRESS; - } else { + } else if (action == GLFW_RELEASE) { act = KeyAction::RELEASE; + } else { + act = KeyAction::REPEAT; } app->dispatch_event(MouseButtonEvent{key, act});