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.
This commit is contained in:
2026-07-12 20:43:04 +08:00
parent d00ada1391
commit 674c023228
2 changed files with 9 additions and 5 deletions

View File

@@ -123,5 +123,5 @@ enum class Key {
NUMPAD_DECIMAL, // . NUMPAD_DECIMAL, // .
NUMPAD_ENTER NUMPAD_ENTER
}; };
enum class KeyAction { PRESS, RELEASE }; enum class KeyAction { PRESS, RELEASE, REPEAT };
} // namespace Cubed } // namespace Cubed

View File

@@ -521,10 +521,12 @@ void App::key_callback(GLFWwindow* window, int key, int scancode, int action,
return; return;
} }
if (action == GLFW_PRESS || action == GLFW_REPEAT) { if (action == GLFW_PRESS) {
act = KeyAction::PRESS; act = KeyAction::PRESS;
} else { } else if (action == GLFW_RELEASE) {
act = KeyAction::RELEASE; act = KeyAction::RELEASE;
} else {
act = KeyAction::REPEAT;
} }
app->dispatch_event(KeyEvent{pkey, act}); 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); Logger::error("Unknown Mouse Button {}", button);
return; return;
} }
if (action == GLFW_PRESS || action == GLFW_REPEAT) { if (action == GLFW_PRESS) {
act = KeyAction::PRESS; act = KeyAction::PRESS;
} else { } else if (action == GLFW_RELEASE) {
act = KeyAction::RELEASE; act = KeyAction::RELEASE;
} else {
act = KeyAction::REPEAT;
} }
app->dispatch_event(MouseButtonEvent{key, act}); app->dispatch_event(MouseButtonEvent{key, act});