mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 17:15:40 -04:00
Transition to the efficient keycode converter.
This commit is contained in:
parent
bf2670aa89
commit
f7ef779d05
@ -607,7 +607,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
|
|
||||||
boolean isKeyboard(KeyEvent evt) {
|
boolean isKeyboard(KeyEvent evt) {
|
||||||
System.out.println("Event:" +evt);
|
System.out.println("Event:" +evt);
|
||||||
return AndroidLWJGLKeycode.androidToLwjglMap.containsKey(evt.getKeyCode());
|
return EfficientAndroidLWJGLKeycode.containsKey(evt.getKeyCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(isKeyboard(event)) {
|
if(isKeyboard(event)) {
|
||||||
AndroidLWJGLKeycode.execKey(event,event.getKeyCode(),event.getAction() == KeyEvent.ACTION_DOWN);
|
EfficientAndroidLWJGLKeycode.execKey(event,event.getKeyCode(),event.getAction() == KeyEvent.ACTION_DOWN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,7 +734,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
private void dialogSendCustomKey() {
|
private void dialogSendCustomKey() {
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||||
dialog.setTitle(R.string.control_customkey);
|
dialog.setTitle(R.string.control_customkey);
|
||||||
dialog.setItems(AndroidLWJGLKeycode.generateKeyName(), (dInterface, position) -> AndroidLWJGLKeycode.execKeyIndex(BaseMainActivity.this, position));
|
dialog.setItems(EfficientAndroidLWJGLKeycode.generateKeyName(), (dInterface, position) -> EfficientAndroidLWJGLKeycode.execKeyIndex(BaseMainActivity.this, position));
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,8 +878,8 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
if(doesObjectContainField(KeyEvent.class,"KEYCODE_" + Character.toUpperCase(keyChar))) {
|
if(doesObjectContainField(KeyEvent.class,"KEYCODE_" + Character.toUpperCase(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(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
sendKeyPress(EfficientAndroidLWJGLKeycode.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), true);
|
||||||
sendKeyPress(AndroidLWJGLKeycode.androidToLwjglMap.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
sendKeyPress(EfficientAndroidLWJGLKeycode.get(keyCode), keyChar, 0, CallbackBridge.getCurrentMods(), false);
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import net.kdt.pojavlaunch.AndroidLWJGLKeycode;
|
import net.kdt.pojavlaunch.EfficientAndroidLWJGLKeycode;
|
||||||
import net.kdt.pojavlaunch.R;
|
import net.kdt.pojavlaunch.R;
|
||||||
import net.kdt.pojavlaunch.customcontrols.buttons.ControlButton;
|
import net.kdt.pojavlaunch.customcontrols.buttons.ControlButton;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
@ -163,7 +163,7 @@ public class EditControlButtonPopup {
|
|||||||
specialArr[i] = "SPECIAL_" + oldSpecialArr[specialArr.length - i - 1];
|
specialArr[i] = "SPECIAL_" + oldSpecialArr[specialArr.length - i - 1];
|
||||||
}
|
}
|
||||||
adapter.addAll(specialArr);
|
adapter.addAll(specialArr);
|
||||||
adapter.addAll(AndroidLWJGLKeycode.generateKeyName());
|
adapter.addAll(EfficientAndroidLWJGLKeycode.generateKeyName());
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||||
|
|
||||||
for (Spinner spinner : spinnersKeycode) {
|
for (Spinner spinner : spinnersKeycode) {
|
||||||
@ -175,7 +175,6 @@ public class EditControlButtonPopup {
|
|||||||
buttonStrokeColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit stroke color", false, ((ColorDrawable) buttonStrokeColor.getBackground()).getColor(), buttonStrokeColor));
|
buttonStrokeColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit stroke color", false, ((ColorDrawable) buttonStrokeColor.getBackground()).getColor(), buttonStrokeColor));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Set dialog buttons behavior
|
//Set dialog buttons behavior
|
||||||
setupDialogButtons();
|
setupDialogButtons();
|
||||||
|
|
||||||
@ -235,7 +234,7 @@ public class EditControlButtonPopup {
|
|||||||
if (properties.keycodes[i] < 0) {
|
if (properties.keycodes[i] < 0) {
|
||||||
spinnersKeycode[i].setSelection(properties.keycodes[i] + specialArr.length);
|
spinnersKeycode[i].setSelection(properties.keycodes[i] + specialArr.length);
|
||||||
} else {
|
} else {
|
||||||
spinnersKeycode[i].setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycodes[i]) + specialArr.length);
|
spinnersKeycode[i].setSelection(EfficientAndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycodes[i]) + specialArr.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,7 +272,7 @@ public class EditControlButtonPopup {
|
|||||||
if (spinnersKeycode[i].getSelectedItemPosition() < specialArr.length) {
|
if (spinnersKeycode[i].getSelectedItemPosition() < specialArr.length) {
|
||||||
properties.keycodes[i] = spinnersKeycode[i].getSelectedItemPosition() - specialArr.length;
|
properties.keycodes[i] = spinnersKeycode[i].getSelectedItemPosition() - specialArr.length;
|
||||||
} else {
|
} else {
|
||||||
properties.keycodes[i] = AndroidLWJGLKeycode.getKeyByIndex(spinnersKeycode[i].getSelectedItemPosition() - specialArr.length);
|
properties.keycodes[i] = EfficientAndroidLWJGLKeycode.getKeyByIndex(spinnersKeycode[i].getSelectedItemPosition() - specialArr.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user