mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 07:05:40 -04:00
- Add auto-correct support
- Fix F25 key when setting controls.
This commit is contained in:
parent
a47361cba0
commit
47f467e705
@ -46,23 +46,19 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
@Override
|
||||
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
|
||||
super.onTextChanged(text, start, lengthBefore, lengthAfter);
|
||||
if(isDoingInternalChanges){
|
||||
isDoingInternalChanges = false;
|
||||
return;
|
||||
if(isDoingInternalChanges)return;
|
||||
|
||||
for(int i=0; i< lengthBefore; ++i){
|
||||
CallbackBridge.sendKeycode(LWJGLGLFWKeycode.GLFW_KEY_BACKSPACE, '\u0008', 0, 0, true);
|
||||
}
|
||||
if(lengthAfter < lengthBefore){
|
||||
for(int i=0; i< lengthBefore-lengthAfter; ++i){
|
||||
CallbackBridge.sendKeycode(LWJGLGLFWKeycode.GLFW_KEY_BACKSPACE, '\u0008', 0, 0, true);
|
||||
}
|
||||
}else{
|
||||
for(int i=lengthBefore, index=lengthBefore+start; i < lengthAfter; ++i){
|
||||
//I didn't know F25 existed before that. I just need a full fat keycode for mc 1.13+
|
||||
CallbackBridge.sendKeycode(LWJGLGLFWKeycode.GLFW_KEY_F25, text.charAt(index), 0, 0, true);
|
||||
index ++;
|
||||
}
|
||||
for(int i=start, count = 0; count < lengthAfter; ++i){
|
||||
//I didn't know F25 existed before that. I just need a full fat keycode for mc 1.13+
|
||||
CallbackBridge.sendChar(text.charAt(i), 0);
|
||||
++count;
|
||||
}
|
||||
|
||||
clear();
|
||||
//Reset the keyboard state
|
||||
if(text.length() < 1) clear();
|
||||
}
|
||||
|
||||
|
||||
@ -88,10 +84,6 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
return super.onKeyPreIme(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(int index) {
|
||||
super.setSelection(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle on and off the soft keyboard, depending of the state
|
||||
@ -125,8 +117,9 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
isDoingInternalChanges = true;
|
||||
//Braille space, doesn't trigger keyboard auto-complete
|
||||
//replacing directly the text without though setText avoids notifying changes
|
||||
getText().replace(0, getText().length(),"\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800");
|
||||
setSelection(5);
|
||||
setText(" ");
|
||||
setSelection(getText().length());
|
||||
isDoingInternalChanges = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +152,6 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function deals with anything that has to be executed when the constructor is called
|
||||
*/
|
||||
|
@ -79,6 +79,11 @@ public class CallbackBridge {
|
||||
// sendData(JRE_TYPE_KEYCODE_CONTROL, keycode, Character.toString(keychar), Boolean.toString(isDown), modifiers);
|
||||
}
|
||||
|
||||
public static void sendChar(char keychar, int modifiers){
|
||||
nativeSendCharMods(keychar,modifiers);
|
||||
nativeSendChar(keychar);
|
||||
}
|
||||
|
||||
public static void sendMouseKeycode(int button, int modifiers, boolean isDown) {
|
||||
DEBUG_STRING.append("MouseKey=").append(button).append(", down=").append(isDown).append("\n");
|
||||
// if (isGrabbing()) DEBUG_STRING.append("MouseGrabStrace: " + android.util.Log.getStackTraceString(new Throwable()) + "\n");
|
||||
|
@ -53,8 +53,8 @@
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:ems="10"
|
||||
android:imeOptions="flagNoFullscreen|flagNoExtractUi|flagNoPersonalizedLearning|actionSend"
|
||||
android:inputType="textVisiblePassword"
|
||||
android:imeOptions="flagNoFullscreen|flagNoExtractUi|flagNoPersonalizedLearning|actionDone"
|
||||
android:inputType="textFilter|textImeMultiLine|textAutoComplete|textAutoCorrect"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</net.kdt.pojavlaunch.customcontrols.ControlLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user