mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 23:59:21 -04:00
[x86 fix] can't locate properly
This commit is contained in:
parent
4a853ec08f
commit
d3e270e96b
@ -1,7 +1,10 @@
|
|||||||
package net.kdt.pojavlaunch.customcontrols;
|
package net.kdt.pojavlaunch.customcontrols;
|
||||||
|
|
||||||
|
import android.util.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import net.kdt.pojavlaunch.*;
|
import net.kdt.pojavlaunch.*;
|
||||||
|
import net.kdt.pojavlaunch.utils.*;
|
||||||
|
import net.objecthunter.exp4j.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
|
|
||||||
public class ControlData implements Cloneable
|
public class ControlData implements Cloneable
|
||||||
@ -20,14 +23,23 @@ public class ControlData implements Cloneable
|
|||||||
private static ControlData[] SPECIAL_BUTTONS;
|
private static ControlData[] SPECIAL_BUTTONS;
|
||||||
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Both fields below are dynamic position data, auto updates
|
||||||
|
* X and Y position, unlike the original one which uses fixed
|
||||||
|
* position, so it does not provide auto-location when a control
|
||||||
|
* is made on a small device, then import the control to a
|
||||||
|
* bigger device or vice versa.
|
||||||
|
*/
|
||||||
|
public String dynamicX, dynamicY;
|
||||||
|
|
||||||
public static ControlData[] getSpecialButtons(){
|
public static ControlData[] getSpecialButtons(){
|
||||||
if (SPECIAL_BUTTONS == null) {
|
if (SPECIAL_BUTTONS == null) {
|
||||||
SPECIAL_BUTTONS = new ControlData[]{
|
SPECIAL_BUTTONS = new ControlData[]{
|
||||||
new DynamicControlData("Keyboard", SPECIALBTN_KEYBOARD, "${margin} * 3 + ${width} * 2", "${margin}", false),
|
new ControlData("Keyboard", SPECIALBTN_KEYBOARD, "${margin} * 3 + ${width} * 2", "${margin}", false),
|
||||||
new DynamicControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${screen_width} - ${width} * 2 + ${margin}"),
|
new ControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${bottom}"),
|
||||||
new DynamicControlData("PRI", SPECIALBTN_MOUSEPRI, "${margin}", "${screen_height} - ${height} * 4 + ${margin} * 2"),
|
new ControlData("PRI", SPECIALBTN_MOUSEPRI, "${margin}", "${screen_height} - ${margin} * 3 - ${height} * 3"),
|
||||||
new DynamicControlData("SEC", SPECIALBTN_MOUSESEC, "${margin} * 3 + ${width} * 2", "${screen_height} - ${height} * 4 + ${margin} * 2"),
|
new ControlData("SEC", SPECIALBTN_MOUSESEC, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} * 3 - ${height} * 3"),
|
||||||
new DynamicControlData("Mouse", SPECIALBTN_VIRTUALMOUSE, "${right}", "${margin}", false)
|
new ControlData("Mouse", SPECIALBTN_VIRTUALMOUSE, "${right}", "${margin}", false)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,15 +100,68 @@ public class ControlData implements Cloneable
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ControlData(String name, int keycode, String dynamicX, String dynamicY) {
|
||||||
|
this(name, keycode, dynamicX, dynamicY, pixelOf50dp, pixelOf50dp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlData(android.content.Context ctx, int resId, int keycode, String dynamicX, String dynamicY, boolean isSquare) {
|
||||||
|
this(ctx.getResources().getString(resId), keycode, dynamicX, dynamicY, isSquare);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlData(String name, int keycode, String dynamicX, String dynamicY, boolean isSquare) {
|
||||||
|
this(name, keycode, dynamicX, dynamicY, isSquare ? pixelOf50dp : pixelOf80dp, isSquare ? pixelOf50dp : pixelOf30dp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlData(String name, int keycode, String dynamicX, String dynamicY, int width, int height) {
|
||||||
|
this(name, keycode, 0, 0, width, height);
|
||||||
|
this.dynamicX = dynamicX;
|
||||||
|
this.dynamicY = dynamicY;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
public void execute(BaseMainActivity act, boolean isDown) {
|
public void execute(BaseMainActivity act, boolean isDown) {
|
||||||
act.sendKeyPress(keycode, 0, isDown);
|
act.sendKeyPress(keycode, 0, isDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControlData clone() {
|
public ControlData clone() {
|
||||||
if (this instanceof DynamicControlData) {
|
if (this instanceof ControlData) {
|
||||||
return new DynamicControlData(name, keycode, ((DynamicControlData) this).dynamicX, ((DynamicControlData) this).dynamicY, width, height);
|
return new ControlData(name, keycode, ((ControlData) this).dynamicX, ((ControlData) this).dynamicY, width, height);
|
||||||
} else {
|
} else {
|
||||||
return new ControlData(name, keycode, x, y, width, height);
|
return new ControlData(name, keycode, x, y, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if (dynamicX == null || dynamicY == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values in the map below may be always changed
|
||||||
|
Map<String, String> keyValueMap = new ArrayMap<>();
|
||||||
|
keyValueMap.put("top", "0");
|
||||||
|
keyValueMap.put("left", "0");
|
||||||
|
keyValueMap.put("right", Integer.toString(CallbackBridge.windowWidth - width));
|
||||||
|
keyValueMap.put("bottom", Integer.toString(CallbackBridge.windowHeight - height));
|
||||||
|
keyValueMap.put("width", Integer.toString(width));
|
||||||
|
keyValueMap.put("height", Integer.toString(height));
|
||||||
|
keyValueMap.put("screen_width", Integer.toString(CallbackBridge.windowWidth));
|
||||||
|
keyValueMap.put("screen_height", Integer.toString(CallbackBridge.windowHeight));
|
||||||
|
keyValueMap.put("margin", Integer.toString(pixelOf2dp));
|
||||||
|
|
||||||
|
// Insert JSON values to variables
|
||||||
|
String insertedX = JSONUtils.insertSingleJSONValue(dynamicX, keyValueMap);
|
||||||
|
String insertedY = JSONUtils.insertSingleJSONValue(dynamicY, keyValueMap);
|
||||||
|
|
||||||
|
// Calculate and save, because the dynamic position contains some math equations
|
||||||
|
x = calculate(insertedX);
|
||||||
|
y = calculate(insertedY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float calculate(String math) {
|
||||||
|
// try {
|
||||||
|
return (float) new ExpressionBuilder(math).build().evaluate();
|
||||||
|
/* } catch (e) {
|
||||||
|
|
||||||
|
} */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,13 +152,19 @@ public class JREUtils
|
|||||||
if (JRE_ARCHITECTURE == null) {
|
if (JRE_ARCHITECTURE == null) {
|
||||||
Map<String, String> jreReleaseList = JREUtils.readJREReleaseProperties();
|
Map<String, String> jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||||
JRE_ARCHITECTURE = jreReleaseList.get("OS_ARCH");
|
JRE_ARCHITECTURE = jreReleaseList.get("OS_ARCH");
|
||||||
|
if (JRE_ARCHITECTURE.startsWith("i") && JRE_ARCHITECTURE.endsWith("86") && Tools.currentArch.contains("x86") && !Tools.currentArch.contains("64")) {
|
||||||
|
JRE_ARCHITECTURE = "i386/i486/i586";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
||||||
|
|
||||||
File f = new File(Tools.homeJreDir, "lib/" + JRE_ARCHITECTURE);
|
for (String arch : JRE_ARCHITECTURE.split("/")) {
|
||||||
if (f.exists() && f.isDirectory()) {
|
File f = new File(Tools.homeJreDir, "lib/" + arch);
|
||||||
Tools.homeJreLib = "lib/" + JRE_ARCHITECTURE;
|
if (f.exists() && f.isDirectory()) {
|
||||||
|
Tools.homeJreLib = "lib/" + arch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user