[nostalglia/core/glfw] Cleanup event handling

This commit is contained in:
Gary Talent 2021-06-19 11:19:44 -05:00
parent faf8fa0668
commit 6882dc8404

View File

@ -18,16 +18,25 @@ namespace nostalgia::core {
void draw(Context *ctx) noexcept; void draw(Context *ctx) noexcept;
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) { static void handleKeyPress(Context *ctx, int key) {
const auto ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
const auto id = ctx->windowerData<GlfwImplData>(); const auto id = ctx->windowerData<GlfwImplData>();
switch (action) {
case GLFW_PRESS:
switch (key) { switch (key) {
case GLFW_KEY_ESCAPE:
case GLFW_KEY_Q: case GLFW_KEY_Q:
id->running = false; id->running = false;
break; break;
default:
break;
} }
}
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) {
const auto ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
switch (action) {
case GLFW_PRESS:
handleKeyPress(ctx, key);
break;
default:
break; break;
} }
} }