Fix missing key index mappings (#110)

* Fix missing key index->name mappings at runtime

* Update dependencies

* Keyboard init goes into ClientProxy

* Spotless
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2024-01-20 09:27:09 +00:00
1 parent b4b733ceb2
commit 3c03c17404
8 files changed
+58 -28

No files matched your search

+10 -2
View File
@@ -165,6 +165,8 @@ public class Keyboard {
public static final int keyCount;
private static final Map<String, Integer> reverseKeyMap = new ConcurrentHashMap<>();
public enum KeyState {
PRESS(true),
@@ -203,6 +205,7 @@ public class Keyboard {
String name = field.getName()
.substring(4);
unlocalizedKeyNameMiniLut[key] = name;
reverseKeyMap.put(name, key);
keyCounter++;
}
}
@@ -216,6 +219,13 @@ public class Keyboard {
eventQueue.add(new KeyEvent(0, '\0', KeyState.RELEASE, Sys.getNanoTime()));
}
/** Populates the key name->index lookup table with the current keyboard layout based names. */
public static void populateKeyLookupTables() {
for (int key = 0; key <= 255; key++) {
getKeyName(key);
}
}
public static void addRawKeyEvent(KeyEvent event) {
if (event == null || (event.state == KeyState.REPEAT && !doRepeatEvents)) {
return;
@@ -312,8 +322,6 @@ public class Keyboard {
return eventQueue.peek().nano;
}
private static final Map<String, Integer> reverseKeyMap = new ConcurrentHashMap<>();
public static String getKeyName(int key) {
if (key == KEY_NONE) {
return "NONE";