From d47f13a7aa5aebbc6a829d2d972a1dfbbcb14fdf Mon Sep 17 00:00:00 2001 From: PanJohnny Date: Wed, 25 Oct 2023 20:47:39 +0200 Subject: [PATCH] Created an event to be called when key callback is invoked --- .../java/com/panjohnny/pjgl/adapt/lwjgl/GLFWKeyboard.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/panjohnny/pjgl/adapt/lwjgl/GLFWKeyboard.java b/src/main/java/com/panjohnny/pjgl/adapt/lwjgl/GLFWKeyboard.java index 4703066..504b641 100644 --- a/src/main/java/com/panjohnny/pjgl/adapt/lwjgl/GLFWKeyboard.java +++ b/src/main/java/com/panjohnny/pjgl/adapt/lwjgl/GLFWKeyboard.java @@ -1,6 +1,7 @@ package com.panjohnny.pjgl.adapt.lwjgl; import com.panjohnny.pjgl.adapt.Adaptation; +import com.panjohnny.pjgl.api.event.PJGLEvent; import com.panjohnny.pjgl.core.adapters.KeyboardAdapter; import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFWKeyCallbackI; @@ -8,6 +9,7 @@ @Adaptation("lwjgl@pjgl") public class GLFWKeyboard implements KeyboardAdapter, GLFWKeyCallbackI { private final boolean[] keys; + public PJGLEvent GLFW_INVOKE = new PJGLEvent<>(); public GLFWKeyboard() { this.keys = new boolean[GLFW.GLFW_KEY_LAST]; @@ -40,5 +42,10 @@ public void invoke(long window, int key, int scancode, int action, int mods) { if (key >= 0 && key < keys.length) { keys[key] = action != GLFW.GLFW_RELEASE; } + GLFW_INVOKE.call(new KeyCallbackParams(window, key, scancode, action, mods)); + } + + public record KeyCallbackParams(long window, int key, int scancode, int action, int mods) { + } }