Fix macOS cmd + <key> not sending <key> pressed (#79)

* Fix macOS cmd + <key> not sending <key> pressed

* Cancel Super+key char events on non-mac platforms

* Update buildscript and fix wildcard imports

---------

Co-authored-by: Raven Szewczyk <[email protected]>
This commit is contained in:
ghostflybyandRaven Szewczyk authored and GitHub committed 2023-09-23 11:17:20 +01:00
1 parent 4cf597e9b3
commit be28e276b8
12 files changed
+108 -25

No files matched your search

+8 -2
View File
@@ -15,7 +15,13 @@
*/
package org.lwjglx;
import java.nio.*;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
/**
* <p>
@@ -24,7 +30,7 @@ import java.nio.*;
*
* Internal class, don't use.
* </p>
*
*
* @author cix_foo <[email protected]>
* @author elias_naur <[email protected]>
* @version $Revision$ $Id$
+6 -1
View File
@@ -24,7 +24,12 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.lwjgl.system.Platform;
+8 -2
View File
@@ -15,8 +15,14 @@
*/
package org.lwjglx;
import java.nio.*;
import java.nio.charset.*;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
/**
* [INTERNAL USE ONLY]
+1 -1
View File
@@ -16,7 +16,7 @@
package org.lwjglx;
import java.lang.reflect.Field;
import java.nio.*;
import java.nio.ByteBuffer;
import javax.annotation.Nullable;
@@ -15,7 +15,11 @@
*/
package org.lwjglx.opengl;
import java.awt.*;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.Point;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.HierarchyEvent;
+13 -3
View File
@@ -3,24 +3,28 @@ package org.lwjglx.opengl;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.system.MemoryUtil.NULL;
import java.awt.*;
import java.awt.Canvas;
import java.awt.event.KeyEvent;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.glfw.*;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWCharCallback;
import org.lwjgl.glfw.GLFWCursorPosCallback;
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
import org.lwjgl.glfw.GLFWImage;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.glfw.GLFWMouseButtonCallback;
import org.lwjgl.glfw.GLFWScrollCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.glfw.GLFWWindowFocusCallback;
import org.lwjgl.glfw.GLFWWindowIconifyCallback;
import org.lwjgl.glfw.GLFWWindowPosCallback;
import org.lwjgl.glfw.GLFWWindowRefreshCallback;
import org.lwjgl.glfw.GLFWWindowSizeCallback;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.Platform;
import org.lwjglx.BufferUtils;
import org.lwjglx.Sys;
import org.lwjglx.input.KeyCodes;
@@ -169,7 +173,13 @@ public class Display {
cancelNextChar = false;
if (key > GLFW_KEY_SPACE && key <= GLFW_KEY_GRAVE_ACCENT) { // Handle keys have a char. Exclude space to
// avoid extra input when switching IME
if ((GLFW_MOD_CONTROL & mods) != 0 && (GLFW_MOD_ALT & mods) == 0) { // Handle ctrl + x/c/v.
if ((GLFW_MOD_SUPER & mods) != 0) {
Keyboard.addGlfwKeyEvent(window, key, scancode, action, mods, (char) key);
if (Platform.get() != Platform.MACOSX) {
// MacOS doesn't send a char event for Cmd+KEY presses, but other platforms do.
cancelNextChar = true;
}
} else if ((GLFW_MOD_CONTROL & mods) != 0 && (GLFW_MOD_ALT & mods) == 0) { // Handle ctrl + x/c/v.
Keyboard.addGlfwKeyEvent(window, key, scancode, action, mods, (char) (key & 0x1f));
cancelNextChar = true; // Cancel char event from ctrl key since its already handled here
} else if (action > 0) { // Delay press and repeat key event to actual char input. There is ALWAYS a