Final fix on Russian character doubling; remove redundant debugging

This commit is contained in:
artdeell 2020-12-31 19:39:45 +03:00
parent 882be4cbf8
commit a40eff3fb1
4 changed files with 19 additions and 10 deletions

View File

@ -1085,13 +1085,24 @@ public class BaseMainActivity extends LoggableActivity {
public static void sendKeyPress(int keyCode, char keyChar, int scancode, int modifiers, boolean status) { public static void sendKeyPress(int keyCode, char keyChar, int scancode, int modifiers, boolean status) {
CallbackBridge.sendKeycode(keyCode, keyChar, scancode, modifiers, status); CallbackBridge.sendKeycode(keyCode, keyChar, scancode, modifiers, status);
} }
public static boolean doesObjectContainField(Class objectClass, String fieldName) {
for (Field field : objectClass.getFields()) {
if (field.getName().equals(fieldName)) {
return true;
}
}
return false;
}
public void sendKeyPress(char keyChar) { public void sendKeyPress(char keyChar) {
try { if(doesObjectContainField(KeyEvent.class,"KEYCODE_" + Character.toUpperCase(keyChar))) {
int keyCode = KeyEvent.class.getField("KEYCODE_" + Character.toUpperCase(keyChar)).getInt(null); try {
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true); int keyCode = KeyEvent.class.getField("KEYCODE_" + Character.toUpperCase(keyChar)).getInt(null);
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false); sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true);
} catch (IllegalAccessException | NoSuchFieldException e) { sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false);
} catch (IllegalAccessException | NoSuchFieldException e) {
}
}else{
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), true); sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), true);
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false); sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
} }

View File

@ -60,9 +60,7 @@ class MinecraftInputConnection extends BaseInputConnection {
} }
public boolean commitText(CharSequence text, int newCursorPosition) { public boolean commitText(CharSequence text, int newCursorPosition) {
Log.d("EnhancedTextInput","Text committed: "+text); parent.sendKeyPress(text.charAt(0));
parent.sendKeyPress(text.charAt(0
));
return true; return true;
} }

View File

@ -55,7 +55,7 @@ public class CallbackBridge {
*/ */
//nativeSendKeycode(keycode, keychar, scancode, isDown ? 1 : 0, modifiers); //nativeSendKeycode(keycode, keychar, scancode, isDown ? 1 : 0, modifiers);
nativeSendKey(keycode,scancode,isDown ? 1 : 0, modifiers); if(keycode != 0 || !isDown) nativeSendKey(keycode,scancode,isDown ? 1 : 0, modifiers);
if(isDown && keychar != '\u0000') { if(isDown && keychar != '\u0000') {
nativeSendCharMods(keychar,modifiers); nativeSendCharMods(keychar,modifiers);
nativeSendChar(keychar); nativeSendChar(keychar);