Reimplement the key pipe as Android docs suggest

This commit is contained in:
artdeell 2020-12-31 15:50:34 +03:00
parent 5400f82323
commit a17ba2170f
2 changed files with 21 additions and 6 deletions

View File

@ -738,7 +738,7 @@ public class BaseMainActivity extends LoggableActivity {
Tools.showError(this, e, true);
}
}
/*
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
switch (event.getAction()) {
@ -753,7 +753,7 @@ public class BaseMainActivity extends LoggableActivity {
return super.dispatchKeyEvent(event);
}
*/
//private Dialog menuDial;
@Override
@ -1056,6 +1056,7 @@ public class BaseMainActivity extends LoggableActivity {
public void showKeyboard() {
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
minecraftGLView.requestFocusFromTouch();
minecraftGLView.requestFocus();
}
protected void setRightOverride(boolean val) {

View File

@ -15,12 +15,12 @@ import org.lwjgl.glfw.CallbackBridge;
public class MinecraftGLView extends TextureView
{
volatile Context ctx;
volatile BaseMainActivity ctx;
// private View.OnTouchListener mTouchListener;
public MinecraftGLView(Context context) {
super(context);
//setPreserveEGLContextOnPause(true);
ctx = context;
ctx = (BaseMainActivity) context;
}
public MinecraftGLView(Context context, AttributeSet attributeSet) {
@ -34,10 +34,22 @@ public class MinecraftGLView extends TextureView
if(!isHardKB(this.getContext())) {
return new MyInputConnection(this, false);
}else{
return null;
return new BaseInputConnection(this,false);
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
AndroidLWJGLKeycode.execKey(event,keyCode,false);
return true;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
AndroidLWJGLKeycode.execKey(event,keyCode,true);
return true;
}
@Override
public boolean onCheckIsTextEditor() {
return false;
@ -65,7 +77,9 @@ class MyInputConnection extends BaseInputConnection {
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;
}
}