Allow unicode input on LWJGL3

This commit is contained in:
artdeell 2020-12-31 14:25:41 +03:00
parent 012d4dd0d7
commit 48be7be01d
2 changed files with 54 additions and 3 deletions

View file

@ -1055,6 +1055,7 @@ public class BaseMainActivity extends LoggableActivity {
public void showKeyboard() {
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
minecraftGLView.requestFocusFromTouch();
}
protected void setRightOverride(boolean val) {
@ -1075,8 +1076,14 @@ public class BaseMainActivity extends LoggableActivity {
}
public void sendKeyPress(char keyChar) {
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), true);
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
try {
int keyCode = KeyEvent.class.getField("KEYCODE_" + Character.toUpperCase(keyChar)).getInt(null);
sendKeyPress(keyCode, keyChar, 0, CallbackBridge.getCurrentMods(), true);
sendKeyPress(keyCode, keyChar, 0, CallbackBridge.getCurrentMods(), false);
}catch(Exception e) {
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), true);
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
}
}
public void sendKeyPress(int keyCode) {