do not log if keycode = -1

This commit is contained in:
Tungstend 2024-01-13 19:09:44 +08:00
parent 3d899fef9d
commit 8ad7e1ceb9
3 changed files with 230 additions and 249 deletions

View File

@ -1 +1 @@
1705142618589
1705144140575

View File

@ -6,10 +6,10 @@ public class KeyCodes {
public static int toLwjglKey(int glfwKeyCode) {
switch(glfwKeyCode) {
switch (glfwKeyCode) {
case GLFW.GLFW_KEY_ESCAPE : return Keyboard.KEY_ESCAPE;
case GLFW.GLFW_KEY_BACKSPACE: return Keyboard.KEY_BACK;
case GLFW.GLFW_KEY_BACKSPACE : return Keyboard.KEY_BACK;
case GLFW.GLFW_KEY_TAB : return Keyboard.KEY_TAB;
case GLFW.GLFW_KEY_ENTER : return Keyboard.KEY_RETURN;
case GLFW.GLFW_KEY_SPACE : return Keyboard.KEY_SPACE;
@ -72,7 +72,7 @@ public class KeyCodes {
case GLFW.GLFW_KEY_HOME : return Keyboard.KEY_HOME;
case GLFW.GLFW_KEY_END : return Keyboard.KEY_END;
case GLFW.GLFW_KEY_PAGE_UP : return Keyboard.KEY_PRIOR;
case GLFW.GLFW_KEY_PAGE_DOWN: return Keyboard.KEY_NEXT;
case GLFW.GLFW_KEY_PAGE_DOWN : return Keyboard.KEY_NEXT;
case GLFW.GLFW_KEY_F1 : return Keyboard.KEY_F1;
case GLFW.GLFW_KEY_F2 : return Keyboard.KEY_F2;
@ -108,20 +108,20 @@ public class KeyCodes {
case GLFW.GLFW_KEY_KP_ADD : return Keyboard.KEY_ADD;
case GLFW.GLFW_KEY_KP_SUBTRACT : return Keyboard.KEY_SUBTRACT;
case GLFW.GLFW_KEY_KP_MULTIPLY : return Keyboard.KEY_MULTIPLY;
case GLFW.GLFW_KEY_KP_DIVIDE: return Keyboard.KEY_DIVIDE;
case GLFW.GLFW_KEY_KP_DIVIDE : return Keyboard.KEY_DIVIDE;
case GLFW.GLFW_KEY_KP_DECIMAL : return Keyboard.KEY_DECIMAL;
case GLFW.GLFW_KEY_KP_EQUAL : return Keyboard.KEY_NUMPADEQUALS;
case GLFW.GLFW_KEY_KP_ENTER : return Keyboard.KEY_NUMPADENTER;
case GLFW.GLFW_KEY_NUM_LOCK : return Keyboard.KEY_NUMLOCK;
case GLFW.GLFW_KEY_SEMICOLON: return Keyboard.KEY_SEMICOLON;
case GLFW.GLFW_KEY_BACKSLASH: return Keyboard.KEY_BACKSLASH;
case GLFW.GLFW_KEY_SEMICOLON : return Keyboard.KEY_SEMICOLON;
case GLFW.GLFW_KEY_BACKSLASH : return Keyboard.KEY_BACKSLASH;
case GLFW.GLFW_KEY_COMMA : return Keyboard.KEY_COMMA;
case GLFW.GLFW_KEY_PERIOD : return Keyboard.KEY_PERIOD;
case GLFW.GLFW_KEY_SLASH : return Keyboard.KEY_SLASH;
case GLFW.GLFW_KEY_GRAVE_ACCENT : return Keyboard.KEY_GRAVE;
case GLFW.GLFW_KEY_CAPS_LOCK: return Keyboard.KEY_CAPITAL;
case GLFW.GLFW_KEY_CAPS_LOCK : return Keyboard.KEY_CAPITAL;
case GLFW.GLFW_KEY_SCROLL_LOCK : return Keyboard.KEY_SCROLL;
case GLFW.GLFW_KEY_WORLD_1 : return Keyboard.KEY_CIRCUMFLEX; // TODO not sure if correct
@ -132,37 +132,16 @@ public class KeyCodes {
case GLFW.GLFW_KEY_LEFT_BRACKET : return Keyboard.KEY_LBRACKET;
case GLFW.GLFW_KEY_RIGHT_BRACKET: return Keyboard.KEY_RBRACKET;
case GLFW.GLFW_KEY_APOSTROPHE : return Keyboard.KEY_APOSTROPHE;
// public static final int KEY_AT = 0x91; /* (NEC PC98) */
// public static final int KEY_COLON = 0x92; /* (NEC PC98) */
// public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */
// public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
// public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
// public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
// public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
// public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */
// public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */
// public static final int KEY_STOP = 0x95; /* (NEC PC98) */
// public static final int KEY_AX = 0x96; /* (Japan AX) */
// public static final int KEY_UNLABELED = 0x97; /* (J3100) */
// public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
// public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
// public static final int KEY_SYSRQ = 0xB7;
// public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
// public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
// public static final int KEY_APPS = 0xDD; /* AppMenu key */
// public static final int KEY_POWER = 0xDE;
// public static final int KEY_SLEEP = 0xDF;
default: System.out.println("UNKNOWN GLFW KEY CODE: " + glfwKeyCode);
default:
if (glfwKeyCode != -1)
System.out.println("UNKNOWN GLFW KEY CODE: " + glfwKeyCode);
return Keyboard.KEY_NONE;
}
}
public static int toGlfwKey(int lwjglKeyCode) {
switch(lwjglKeyCode) {
switch (lwjglKeyCode) {
case Keyboard.KEY_ESCAPE : return GLFW.GLFW_KEY_ESCAPE;
case Keyboard.KEY_BACK : return GLFW.GLFW_KEY_BACKSPACE;
@ -289,7 +268,9 @@ public class KeyCodes {
case Keyboard.KEY_RBRACKET : return GLFW.GLFW_KEY_RIGHT_BRACKET;
case Keyboard.KEY_APOSTROPHE: return GLFW.GLFW_KEY_APOSTROPHE;
default: System.out.println("UNKNOWN LWJGL KEY CODE: " + lwjglKeyCode);
default:
if (lwjglKeyCode != -1)
System.out.println("UNKNOWN LWJGL KEY CODE: " + lwjglKeyCode);
return GLFW.GLFW_KEY_UNKNOWN;
}
}