mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
[Custom control] Fix the key index
This commit is contained in:
parent
9e6fbfd2d7
commit
9a48f624d8
@ -4,6 +4,7 @@
|
|||||||
• ClassWrapperMC: A simple wrapper to help launching Minecraft LaunchWrapper on JRE9 and later.<br>
|
• ClassWrapperMC: A simple wrapper to help launching Minecraft LaunchWrapper on JRE9 and later.<br>
|
||||||
• gl4es: OpenGL for OpenGL ES devices by lunixbochs and ptitSeb.<br>
|
• gl4es: OpenGL for OpenGL ES devices by lunixbochs and ptitSeb.<br>
|
||||||
• Apache Commons Compress.<br>
|
• Apache Commons Compress.<br>
|
||||||
|
• exp4j.<br>
|
||||||
• LWJGL2 and LWJGL3.<br>
|
• LWJGL2 and LWJGL3.<br>
|
||||||
|
|
||||||
* License:<br>
|
* License:<br>
|
||||||
|
@ -135,7 +135,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
|||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_spinner_item);
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_spinner_item);
|
||||||
|
|
||||||
String[] oldSpecialArr = ControlData.buildSpecialButtonArray();
|
String[] oldSpecialArr = ControlData.buildSpecialButtonArray();
|
||||||
String[] specialArr = new String[oldSpecialArr.length];
|
final String[] specialArr = new String[oldSpecialArr.length];
|
||||||
for (int i = 0; i < specialArr.length; i++) {
|
for (int i = 0; i < specialArr.length; i++) {
|
||||||
specialArr[i] = "SPECIAL_" + oldSpecialArr[i];
|
specialArr[i] = "SPECIAL_" + oldSpecialArr[i];
|
||||||
}
|
}
|
||||||
@ -145,15 +145,15 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
|||||||
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||||
spinnerKeycode.setAdapter(adapter);
|
spinnerKeycode.setAdapter(adapter);
|
||||||
if (properties.keycode < 0) {
|
if (properties.keycode < 0) {
|
||||||
spinnerKeycode.setSelection(properties.keycode + 5);
|
spinnerKeycode.setSelection(properties.keycode + specialArr.length);
|
||||||
} else {
|
} else {
|
||||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode + 5));
|
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode));
|
||||||
}
|
}
|
||||||
spinnerKeycode.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
|
spinnerKeycode.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
|
||||||
normalBtnLayout.setVisibility(id < 2 ? View.GONE : View.VISIBLE);
|
normalBtnLayout.setVisibility(id < specialArr.length ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -173,7 +173,11 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
|||||||
if (editName.getText().toString().isEmpty()) {
|
if (editName.getText().toString().isEmpty()) {
|
||||||
editName.setError(view.getResources().getString(R.string.global_error_field_empty));
|
editName.setError(view.getResources().getString(R.string.global_error_field_empty));
|
||||||
} else {
|
} else {
|
||||||
properties.keycode = AndroidLWJGLKeycode.getKeyIndex(spinnerKeycode.getSelectedItemPosition()) - 5;
|
if (spinnerKeycode.getSelectedItemPosition() < specialArr.length) {
|
||||||
|
properties.keycode = spinnerKeycode.getSelectedItemPosition() - specialArr.length;
|
||||||
|
} else {
|
||||||
|
properties.keycode = AndroidLWJGLKeycode.getKeyByIndex(spinnerKeycode.getSelectedItemPosition() - specialArr.length);
|
||||||
|
}
|
||||||
properties.name = editName.getText().toString();
|
properties.name = editName.getText().toString();
|
||||||
properties.hidden = checkHidden.isChecked();
|
properties.hidden = checkHidden.isChecked();
|
||||||
|
|
||||||
|
@ -208,10 +208,10 @@ public class AndroidLWJGLKeycode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void execKeyIndex(BaseMainActivity mainActivity, int index) {
|
public static void execKeyIndex(BaseMainActivity mainActivity, int index) {
|
||||||
mainActivity.sendKeyPress(getKeyIndex(index));
|
mainActivity.sendKeyPress(getKeyByIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getKeyIndex(int index) {
|
public static int getKeyByIndex(int index) {
|
||||||
return androidToLwjglMap.valueAt(index);
|
return androidToLwjglMap.valueAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user