mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 21:40:15 -07:00
Allow unicode input on LWJGL3
This commit is contained in:
parent
012d4dd0d7
commit
48be7be01d
2 changed files with 54 additions and 3 deletions
|
|
@ -1055,6 +1055,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||||
|
|
||||||
public void showKeyboard() {
|
public void showKeyboard() {
|
||||||
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||||
|
minecraftGLView.requestFocusFromTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setRightOverride(boolean val) {
|
protected void setRightOverride(boolean val) {
|
||||||
|
|
@ -1075,9 +1076,15 @@ public class BaseMainActivity extends LoggableActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendKeyPress(char keyChar) {
|
public void sendKeyPress(char keyChar) {
|
||||||
|
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(), true);
|
||||||
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void sendKeyPress(int keyCode) {
|
public void sendKeyPress(int keyCode) {
|
||||||
sendKeyPress(keyCode, CallbackBridge.getCurrentMods(), true);
|
sendKeyPress(keyCode, CallbackBridge.getCurrentMods(), true);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,64 @@
|
||||||
package net.kdt.pojavlaunch;
|
package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
import android.view.inputmethod.BaseInputConnection;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputConnection;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.CallbackBridge;
|
||||||
|
|
||||||
public class MinecraftGLView extends TextureView
|
public class MinecraftGLView extends TextureView
|
||||||
{
|
{
|
||||||
|
volatile Context ctx;
|
||||||
// private View.OnTouchListener mTouchListener;
|
// private View.OnTouchListener mTouchListener;
|
||||||
public MinecraftGLView(Context context) {
|
public MinecraftGLView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
//setPreserveEGLContextOnPause(true);
|
//setPreserveEGLContextOnPause(true);
|
||||||
|
ctx = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecraftGLView(Context context, AttributeSet attributeSet) {
|
public MinecraftGLView(Context context, AttributeSet attributeSet) {
|
||||||
super(context, attributeSet);
|
super(context, attributeSet);
|
||||||
//setPreserveEGLContextOnPause(true);
|
//setPreserveEGLContextOnPause(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||||
|
outAttrs.inputType = EditorInfo.TYPE_NULL;
|
||||||
|
Log.d("EnhancedTextInput","Context: " + ctx);
|
||||||
|
return new MyInputConnection(this,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCheckIsTextEditor() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class MyInputConnection extends BaseInputConnection {
|
||||||
|
private SpannableStringBuilder _editable;
|
||||||
|
BaseMainActivity parent;
|
||||||
|
public MyInputConnection(View targetView, boolean fullEditor) {
|
||||||
|
super(targetView, fullEditor);
|
||||||
|
|
||||||
|
parent = (BaseMainActivity)targetView.getContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Editable getEditable() {
|
||||||
|
if (_editable == null) {
|
||||||
|
_editable = (SpannableStringBuilder) Editable.Factory.getInstance()
|
||||||
|
.newEditable("Placeholder");
|
||||||
|
}
|
||||||
|
return _editable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean commitText(CharSequence text, int newCursorPosition) {
|
||||||
|
Log.d("EnhancedTextInput","Text committed: "+text);
|
||||||
|
parent.sendKeyPress(text.charAt(0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue