From 6dc0566fed1eecdc588a2f621b68791e3a23e925 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 25 Jul 2024 12:19:32 +0200 Subject: [PATCH] Add UNKNOWN_MOUSE, rename UNKNOWN -> UNKNOWN_KEY --- .../sosengine/base/classes/helpers/EventHelper.java | 2 +- .../sosengine/graphics/glfw/callbacks/KeyCallback.java | 4 +++- .../sosengine/graphics/glfw/classes/GlfwWindow.java | 4 +++- .../sosengine/graphics/types/input/Key.java | 8 +++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index a26a98d..c288ab2 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -170,7 +170,7 @@ public class EventHelper { if (EngineConfiguration.getInstance().isOptimizeEvents()) Thread .ofVirtual() - .name("Event " + event.getName() + "[" + arguments + "]") + .name("Event " + event.getName()) .start(eventCode); else eventCode.run(); diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/callbacks/KeyCallback.java b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/callbacks/KeyCallback.java index f9fe5be..ce8dbde 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/callbacks/KeyCallback.java +++ b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/callbacks/KeyCallback.java @@ -31,6 +31,8 @@ import static org.lwjgl.glfw.GLFW.*; /** * A {@link GLFWKeyCallbackI} implementation. + * + * @since v1-alpha2 */ @SuppressWarnings({ "unused" }) public class KeyCallback extends WindowCallback implements GLFWKeyCallbackI { @@ -65,7 +67,7 @@ public class KeyCallback extends WindowCallback implements GLFWKeyCallbackI { getAttachedWindow(), // Key switch (key) { - case GLFW_KEY_UNKNOWN -> Key.UNKNOWN; + case GLFW_KEY_UNKNOWN -> Key.UNKNOWN_KEY; case GLFW_KEY_LEFT_ALT, GLFW_KEY_RIGHT_ALT -> Key.ALT; case GLFW_KEY_APOSTROPHE -> Key.APOSTROPHE; case GLFW_KEY_DOWN -> Key.ARROW_DOWN; diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java index d8ec8e3..bddddaa 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java +++ b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java @@ -157,8 +157,10 @@ public abstract class GlfwWindow extends Window { // Set swap interval based on isDisallowTearing setting glfwSwapInterval(Miscellaneous.getIntegerizedBoolean(GraphicsSubsystemConfiguration.getInstance().isDisallowTearing())); - // Set callbacks + // Create callbacks keyCallback = GLFWKeyCallback.create(new KeyCallback(this)); + + // Set callback glfwSetKeyCallback(identifierLong, keyCallback); // Update the window state diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/types/input/Key.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/types/input/Key.java index 9cd5977..b635543 100644 --- a/graphics/src/main/java/de/staropensource/sosengine/graphics/types/input/Key.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/types/input/Key.java @@ -32,7 +32,13 @@ public enum Key { * * @since v1-alpha2 */ - UNKNOWN, + UNKNOWN_KEY, + /** + * An unknown mouse button. + * + * @since v1-alpha2 + */ + UNKNOWN_MOUSE, /** * The left mouse button.