mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
Disable enhanced soft input if hardware keyboard is present
This commit is contained in:
parent
65a64402eb
commit
d340b1d6a8
@ -2,14 +2,17 @@ package net.kdt.pojavlaunch;
|
||||
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
|
||||
import java.net.CookieHandler;
|
||||
import java.util.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
|
||||
public class AndroidLWJGLKeycode {
|
||||
// Fix double letters on MC 1.9 and above
|
||||
public static boolean isBackspaceAfterChar = true;
|
||||
private static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
||||
private static String[] androidKeyNameArray;
|
||||
public static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
||||
public static String[] androidKeyNameArray;
|
||||
|
||||
static {
|
||||
// Mapping Android Keycodes to LWJGL Keycodes
|
||||
androidToLwjglMap = new ArrayMap<Integer, Integer>();
|
||||
|
@ -1066,7 +1066,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
public static void sendKeyPress(int keyCode, int modifiers, boolean status) {
|
||||
sendKeyPress(keyCode, 0, modifiers, status);
|
||||
}
|
||||
|
||||
|
||||
public static void sendKeyPress(int keyCode, int scancode, int modifiers, boolean status) {
|
||||
sendKeyPress(keyCode, '\u0000', scancode, modifiers, status);
|
||||
}
|
||||
@ -1078,9 +1078,9 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
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(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
||||
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
||||
sendKeyPress(0, keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.Configuration;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.util.*;
|
||||
@ -30,14 +31,20 @@ public class MinecraftGLView extends TextureView
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
outAttrs.inputType = EditorInfo.TYPE_NULL;
|
||||
Log.d("EnhancedTextInput","Context: " + ctx);
|
||||
return new MyInputConnection(this,false);
|
||||
if(!isHardKB(this.getContext())) {
|
||||
return new MyInputConnection(this, false);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCheckIsTextEditor() {
|
||||
return false;
|
||||
}
|
||||
public static boolean isHardKB(Context ctx) {
|
||||
return ctx.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
|
||||
}
|
||||
}
|
||||
class MyInputConnection extends BaseInputConnection {
|
||||
private SpannableStringBuilder _editable;
|
||||
|
Loading…
x
Reference in New Issue
Block a user