diff --git a/src/nostalgia/core/glfw/core.cpp b/src/nostalgia/core/glfw/core.cpp index 90508749..0157e4df 100644 --- a/src/nostalgia/core/glfw/core.cpp +++ b/src/nostalgia/core/glfw/core.cpp @@ -18,16 +18,25 @@ namespace nostalgia::core { void draw(Context *ctx) noexcept; +static void handleKeyPress(Context *ctx, int key) { + const auto id = ctx->windowerData(); + switch (key) { + case GLFW_KEY_ESCAPE: + case GLFW_KEY_Q: + id->running = false; + break; + default: + break; + } +} + static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) { const auto ctx = static_cast(glfwGetWindowUserPointer(window)); - const auto id = ctx->windowerData(); switch (action) { case GLFW_PRESS: - switch (key) { - case GLFW_KEY_Q: - id->running = false; - break; - } + handleKeyPress(ctx, key); + break; + default: break; } }