Fix double letters on MC 1.9 and above

This commit is contained in:
khanhduytran0
2020-03-30 06:24:38 +07:00
parent 5932f03a03
commit 7e98ecfd41
3 changed files with 8 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ import org.lwjgl.input.*;
import org.lwjgl.opengl.*;
public class AndroidLWJGLKeycode {
// public static boolean isSendChar;
public static boolean isBackspaceAfterChar;
private static final Map<Integer, Integer> androidToLwjglMap;
static {
androidToLwjglMap = new ArrayMap<Integer, Integer>();
@@ -119,15 +119,8 @@ public class AndroidLWJGLKeycode {
public static void execKey(MainActivity mainActivity, KeyEvent keyEvent, int i, boolean isDown) {
try {
// Old method works without dead chars:
/*
if (isDown) {
mainActivity.sendKeyPress((char) keyEvent.getUnicodeChar());
}
*/
System.out.println("Sending key as char: " + ((char) keyEvent.getUnicodeChar()));
// if (isSendChar)
mainActivity.sendKeyPress(0, (char) keyEvent.getUnicodeChar(), isDown);
mainActivity.sendKeyPress(0, (char) keyEvent.getUnicodeChar(), isDown);
} catch (Throwable th) {
th.printStackTrace();
}
@@ -137,6 +130,10 @@ public class AndroidLWJGLKeycode {
mainActivity.sendKeyPress(perKey.getValue(), isDown);
}
}
if (isBackspaceAfterChar) {
mainActivity.sendKeyPress(Keyboard.KEY_BACK, isDown);
}
}
}