WIP(ControlMap): Add documentation and sendKeyPress keychar overload

This commit is contained in:
alexytomi
2025-08-14 22:02:33 +08:00
parent 717aa001b3
commit a28904d67f

View File

@@ -56,6 +56,17 @@ public class CallbackBridge {
nativeSendCursorPos(mouseX, mouseY);
}
/**
* Sends keycodes if keycode is populated. Used for in-game controls.
* Sends character if keychar is populated. Used for chat and text input.
* You can refer to glfwSetKeyCallback for the arguments.
* @param keycode LwjglGlfwKeycode
* @param keychar Literal char. Modifier keys does not affect this.
* @param scancode
* @param modifiers The action is one of The action is one of GLFW_PRESS, or GLFW_RELEASE.
* We don't have GLFW_REPEAT working.
* @param isDown If its being pressed down or not. 1 is true.
*/
public static void sendKeycode(int keycode, char keychar, int scancode, int modifiers, boolean isDown) {
// TODO CHECK: This may cause input issue, not receive input!
if(keycode != 0) nativeSendKey(keycode,scancode,isDown ? 1 : 0, modifiers);
@@ -82,6 +93,10 @@ public class CallbackBridge {
CallbackBridge.sendKeycode(keyCode, keyChar, scancode, modifiers, status);
}
public static void sendKeyPress(int keyCode, char keyChar, int modifiers, boolean status) {
sendKeyPress(keyCode, keyChar, 0, modifiers, status);
}
public static void sendKeyPress(int keyCode) {
sendKeyPress(keyCode, CallbackBridge.getCurrentMods(), true);
sendKeyPress(keyCode, CallbackBridge.getCurrentMods(), false);