Backslash key triggered twice per key press
miozune opened this issue ยท 13 comments
mod: lwjgl3ify-1.1.17
OS: Windows 10
Java: 17.0.5
In the following video I pressed backslash key only once.
Minecraft.1.7.10.2023-02-03.00-02-22_Trim.mp4
@miozune can you download 1.1.19, go into the configs and set this:
debug {
# Print keyboard-related events to the log [default: false]
B:printKeyEvents=true
# Print mouse-related events to the log [default: false]
B:printMouseEvents=false
}
Then type something like a\b
on your keyboard and post the logs here?
backslash / vertical line key
[13:37:34] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:65 scancode:30 action:1 mods:0 char:A
[13:37:34] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:97 char:a
[13:37:34] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a
[13:37:34] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:65 scancode:30 action:0 mods:0 char:A
[13:37:35] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:-1 scancode:125 action:1 mods:0 char:?
[13:37:35] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:92 char:\
[13:37:35] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\
[13:37:35] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:-1 scancode:125 action:0 mods:0 char:?
[13:37:35] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\\
[13:37:36] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:66 scancode:48 action:1 mods:0 char:B
[13:37:36] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:98 char:b
[13:37:36] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\\b
[13:37:36] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:66 scancode:48 action:0 mods:0 char:B
backslash / underscore key
[13:38:21] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:65 scancode:30 action:1 mods:0 char:A
[13:38:21] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:97 char:a
[13:38:21] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a
[13:38:21] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:65 scancode:30 action:0 mods:0 char:A
[13:38:22] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:-1 scancode:115 action:1 mods:0 char:?
[13:38:22] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:92 char:\
[13:38:22] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\
[13:38:22] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:-1 scancode:115 action:0 mods:0 char:?
[13:38:22] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\\
[13:38:23] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:66 scancode:48 action:1 mods:0 char:B
[13:38:23] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] char window:2692148581280 codepoint:98 char:b
[13:38:23] [Client thread/DEBUG] [NotEnoughItems/]: Searching for a\\b
[13:38:23] [Client thread/INFO] [lwjgl3ify/]: [DEBUG-KEY] key window:2692148581280 key:66 scancode:48 action:0 mods:0 char:B
I can reproduce the issue with runClient on lwjgl3ify mod, but not when I pause the game with debug...
#define GLFW_RELEASE 0
The key or mouse button was released.
#define GLFW_PRESS 1
The key or mouse button was pressed.
#define GLFW_REPEAT 2
The key was held down until it repeated.
It does indeed seem that the backslash is triggering both on key press and key release looking at the logs they provided.
Added breakpoint but cannot see difference for me.
Also added some more debug prints but not really sure
[01:04:38] [Client thread/INFO]: next
[01:04:38] [Client thread/INFO]: char: a
[01:04:38] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:04:38] [Client thread/INFO]: Searching for a
[01:04:38] [Client thread/INFO]: stacktrace: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), codechicken.nei.SearchField.onTextChange(SearchField.java:117), codechicken.nei.TextField.handleKeyPress(TextField.java:89), codechicken.nei.LayoutManager.keyTyped(LayoutManager.java:202), codechicken.nei.guihook.GuiContainerManager.firstKeyTyped(GuiContainerManager.java:407), codechicken.nei.guihook.GuiContainerManager.keyTyped(GuiContainerManager.java:615), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:604), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:04:38] [Client thread/INFO]: next
[01:04:38] [Client thread/INFO]: char: a
[01:04:38] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:03] [Client thread/INFO]: next
[01:05:03] [Client thread/INFO]: char: \
[01:05:03] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:03] [Client thread/INFO]: Searching for a\
[01:05:03] [Client thread/INFO]: stacktrace: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), codechicken.nei.SearchField.onTextChange(SearchField.java:117), codechicken.nei.TextField.handleKeyPress(TextField.java:89), codechicken.nei.LayoutManager.keyTyped(LayoutManager.java:202), codechicken.nei.guihook.GuiContainerManager.firstKeyTyped(GuiContainerManager.java:407), codechicken.nei.guihook.GuiContainerManager.keyTyped(GuiContainerManager.java:615), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:604), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:03] [Client thread/INFO]: next
[01:05:03] [Client thread/INFO]: char: \
[01:05:03] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:03] [Client thread/INFO]: Searching for a\\
[01:05:03] [Client thread/INFO]: stacktrace: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), codechicken.nei.SearchField.onTextChange(SearchField.java:117), codechicken.nei.TextField.handleKeyPress(TextField.java:89), codechicken.nei.LayoutManager.keyTyped(LayoutManager.java:202), codechicken.nei.guihook.GuiContainerManager.firstKeyTyped(GuiContainerManager.java:407), codechicken.nei.guihook.GuiContainerManager.keyTyped(GuiContainerManager.java:615), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:604), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:15] [Client thread/INFO]: next
[01:05:15] [Client thread/INFO]: char: b
[01:05:15] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:15] [Client thread/INFO]: Searching for a\\b
[01:05:15] [Client thread/INFO]: stacktrace: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), codechicken.nei.SearchField.onTextChange(SearchField.java:117), codechicken.nei.TextField.handleKeyPress(TextField.java:89), codechicken.nei.LayoutManager.keyTyped(LayoutManager.java:202), codechicken.nei.guihook.GuiContainerManager.firstKeyTyped(GuiContainerManager.java:407), codechicken.nei.guihook.GuiContainerManager.keyTyped(GuiContainerManager.java:615), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:604), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
[01:05:16] [Client thread/INFO]: next
[01:05:16] [Client thread/INFO]: char: b
[01:05:16] [Client thread/INFO]: [java.base/java.lang.Thread.getStackTrace(Thread.java:1610), org.lwjglx.input.Keyboard.getEventCharacter(Keyboard.java:300), codechicken.nei.guihook.GuiContainerManager.handleKeyboardInput(GuiContainerManager.java:601), net.minecraft.client.gui.inventory.GuiContainer.handleKeyboardInput(GuiContainer.java), net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:321), net.minecraft.client.Minecraft.runTick(Minecraft.java:1731), net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039), net.minecraft.client.Minecraft.run(Minecraft.java:962), net.minecraft.client.main.Main.main(Main.java:164), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.base/java.lang.reflect.Method.invoke(Method.java:568), net.minecraft.launchwrapper.Launch.launch(Launch.java:165), net.minecraft.launchwrapper.Launch.main(Launch.java:29), net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97), GradleStart.main(GradleStart.java:40)]
This code seems suspicious in NEI GuiContainerManager, it's possible (k==0) gets passed for the unrecognized \
key. It's weird that it ignores press/release state in this case:
// Support inputting Chinese characters
public void handleKeyboardInput() {
// Support for LWGJL 2.9.0 or later
int k = Keyboard.getEventKey();
char c = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState() || (k == 0 && Character.isDefined(c))) {
try {
keyTyped(c, k);
} catch (java.lang.IndexOutOfBoundsException e) {
System.err.println("Caught out of bounds exception pressing " + c + " " + k);
e.printStackTrace();
}
}
window.mc.func_152348_aa();
}
Seems to fit with char:?
Probably handling something odd for lwjgl2 and needs to be updated for 3?
It seems there are ~3 characters on the US keyboard that are causing this, we can special case those or find some other way to identify them.
How does JEI or REI handle this? Is this something we can delegate back to MC, or borrow from later versions of forge/mods/mc?
Making condition check only for Keyboard.getEventKeyState()
fixes the issue, but then it doesn't allow inputting Chinese characters
I imagine newer mc (haven't looked at the code) uses the proper events for IME support: use char events for text input boxes and key events for keybindings. I can add an api for this and patch some of the gui classes in mc to support it I guess