mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -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.util.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
|
||||||
|
import java.net.CookieHandler;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
|
|
||||||
public class AndroidLWJGLKeycode {
|
public class AndroidLWJGLKeycode {
|
||||||
// Fix double letters on MC 1.9 and above
|
// Fix double letters on MC 1.9 and above
|
||||||
public static boolean isBackspaceAfterChar = true;
|
public static boolean isBackspaceAfterChar = true;
|
||||||
private static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
public static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
||||||
private static String[] androidKeyNameArray;
|
public static String[] androidKeyNameArray;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Mapping Android Keycodes to LWJGL Keycodes
|
// Mapping Android Keycodes to LWJGL Keycodes
|
||||||
androidToLwjglMap = new ArrayMap<Integer, Integer>();
|
androidToLwjglMap = new ArrayMap<Integer, Integer>();
|
||||||
|
@ -1078,9 +1078,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
public void sendKeyPress(char keyChar) {
|
public void sendKeyPress(char keyChar) {
|
||||||
try {
|
try {
|
||||||
int keyCode = KeyEvent.class.getField("KEYCODE_" + Character.toUpperCase(keyChar)).getInt(null);
|
int keyCode = KeyEvent.class.getField("KEYCODE_" + Character.toUpperCase(keyChar)).getInt(null);
|
||||||
sendKeyPress(keyCode, keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
||||||
sendKeyPress(keyCode, keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
||||||
}catch(Exception e) {
|
} catch (IllegalAccessException | NoSuchFieldException 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);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.kdt.pojavlaunch;
|
package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
@ -30,14 +31,20 @@ public class MinecraftGLView extends TextureView
|
|||||||
@Override
|
@Override
|
||||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||||
outAttrs.inputType = EditorInfo.TYPE_NULL;
|
outAttrs.inputType = EditorInfo.TYPE_NULL;
|
||||||
Log.d("EnhancedTextInput","Context: " + ctx);
|
if(!isHardKB(this.getContext())) {
|
||||||
return new MyInputConnection(this,false);
|
return new MyInputConnection(this, false);
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCheckIsTextEditor() {
|
public boolean onCheckIsTextEditor() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public static boolean isHardKB(Context ctx) {
|
||||||
|
return ctx.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class MyInputConnection extends BaseInputConnection {
|
class MyInputConnection extends BaseInputConnection {
|
||||||
private SpannableStringBuilder _editable;
|
private SpannableStringBuilder _editable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user