mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -04:00
Add experimental resolution changer
This commit is contained in:
parent
7ab575a870
commit
ac4c4ccf09
@ -35,7 +35,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
LWJGLGLFWKeycode.GLFW_KEY_7, LWJGLGLFWKeycode.GLFW_KEY_8, LWJGLGLFWKeycode.GLFW_KEY_9};
|
||||
|
||||
private boolean rightOverride = false;
|
||||
private int scaleFactor = 1;
|
||||
private float scaleFactor = 1;
|
||||
private int fingerStillThreshold = 8;
|
||||
private int initialX;
|
||||
private int initialY;
|
||||
@ -135,8 +135,8 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
isInputStackCall = mVersionInfo.arguments != null;
|
||||
|
||||
this.displayMetrics = Tools.getDisplayMetrics(this);
|
||||
CallbackBridge.windowWidth = displayMetrics.widthPixels / scaleFactor;
|
||||
CallbackBridge.windowHeight = displayMetrics.heightPixels / scaleFactor;
|
||||
CallbackBridge.windowWidth = (int) ((float)displayMetrics.widthPixels / scaleFactor);
|
||||
CallbackBridge.windowHeight = (int) ((float)displayMetrics.heightPixels / scaleFactor);
|
||||
System.out.println("WidthHeight: " + CallbackBridge.windowWidth + ":" + CallbackBridge.windowHeight);
|
||||
|
||||
MCOptionUtils.load();
|
||||
@ -221,7 +221,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
AndroidLWJGLKeycode.isBackspaceAfterChar = true; // mVersionInfo.minimumLauncherVersion >= 18;
|
||||
*/
|
||||
placeMouseAt(CallbackBridge.windowWidth / 2, CallbackBridge.windowHeight / 2);
|
||||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||
new Thread(new Runnable(){
|
||||
|
||||
private boolean isCapturing = false;
|
||||
@ -236,7 +236,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
{
|
||||
if (lastGrab && !CallbackBridge.isGrabbing() && lastEnabled) {
|
||||
touchPad.setVisibility(View.VISIBLE);
|
||||
placeMouseAt(CallbackBridge.windowWidth / 2, CallbackBridge.windowHeight / 2);
|
||||
placeMouseAt(displayMetrics.widthPixels / 2, displayMetrics.heightPixels / 2);
|
||||
}
|
||||
|
||||
if (!CallbackBridge.isGrabbing()) {
|
||||
@ -293,7 +293,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
if (gestureDetector.onTouchEvent(event)) {
|
||||
|
||||
CallbackBridge.sendCursorPos((int) mouseX, (int) mouseY);
|
||||
CallbackBridge.sendCursorPos((int) (mouseX / scaleFactor), (int) (mouseY /scaleFactor));
|
||||
CallbackBridge.sendMouseKeycode(rightOverride ? LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT : LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT);
|
||||
if (!rightOverride) {
|
||||
CallbackBridge.mouseLeft = true;
|
||||
@ -309,11 +309,11 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE: // 2
|
||||
mouseX = Math.max(0, Math.min(CallbackBridge.windowWidth, mouseX + x - prevX));
|
||||
mouseY = Math.max(0, Math.min(CallbackBridge.windowHeight, mouseY + y - prevY));
|
||||
mouseX = Math.max(0, Math.min(displayMetrics.widthPixels, mouseX + x - prevX));
|
||||
mouseY = Math.max(0, Math.min(displayMetrics.heightPixels, mouseY + y - prevY));
|
||||
placeMouseAt(mouseX, mouseY);
|
||||
|
||||
CallbackBridge.sendCursorPos((int) mouseX, (int) mouseY);
|
||||
CallbackBridge.sendCursorPos((int) (mouseX / scaleFactor), (int) (mouseY /scaleFactor));
|
||||
/*
|
||||
if (!CallbackBridge.isGrabbing()) {
|
||||
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, 0, isLeftMouseDown);
|
||||
@ -353,8 +353,8 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
}
|
||||
if (mptrIndex != -1) {
|
||||
//handle mouse events by just sending the coords of the new point in touch event
|
||||
int x = ((int) e.getX(mptrIndex)) / scaleFactor;
|
||||
int y = ((int) e.getY(mptrIndex)) / scaleFactor;
|
||||
int x = (int) (e.getX(mptrIndex) / scaleFactor);
|
||||
int y = (int) (e.getY(mptrIndex) / scaleFactor);
|
||||
CallbackBridge.mouseX = x;
|
||||
CallbackBridge.mouseY = y;
|
||||
CallbackBridge.sendCursorPos(x, y);
|
||||
@ -370,8 +370,8 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
y += (int)(e.getY() - e.getHistoricalY(0));
|
||||
}
|
||||
if(!CallbackBridge.isGrabbing()) {
|
||||
x = (int) e.getX();
|
||||
y = (int) e.getY();
|
||||
x = (int) (e.getX() / scaleFactor);
|
||||
y = (int) (e.getY() / scaleFactor);
|
||||
}
|
||||
|
||||
int hudKeyHandled = handleGuiBar((int)e.getX(), (int)e.getY());
|
||||
@ -654,10 +654,13 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
private boolean isCalled = false;
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
|
||||
CallbackBridge.windowWidth = width;
|
||||
CallbackBridge.windowHeight = height;
|
||||
scaleFactor = (LauncherPreferences.DEFAULT_PREF.getInt("resolutionRatio",0)/100f) + 1f;
|
||||
texture.setDefaultBufferSize((int)(width/scaleFactor),(int)(height/scaleFactor));
|
||||
CallbackBridge.windowWidth = (int)(width/scaleFactor);
|
||||
CallbackBridge.windowHeight = (int)(height/scaleFactor);
|
||||
//CallbackBridge.sendUpdateWindowSize((int)(width/scaleFactor),(int)(height/scaleFactor));
|
||||
|
||||
calculateMcScale();
|
||||
|
||||
// Should we do that?
|
||||
if (!isCalled) {
|
||||
isCalled = true;
|
||||
@ -686,9 +689,9 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int width, int height) {
|
||||
CallbackBridge.windowWidth = width;
|
||||
CallbackBridge.windowHeight = height;
|
||||
CallbackBridge.sendUpdateWindowSize(width, height);
|
||||
CallbackBridge.windowWidth = (int)(width/scaleFactor);
|
||||
CallbackBridge.windowHeight = (int)(height/scaleFactor);
|
||||
CallbackBridge.sendUpdateWindowSize((int)(width/scaleFactor),(int)(height/scaleFactor));
|
||||
calculateMcScale();
|
||||
|
||||
// TODO: Implement this method for GLFW window size callback
|
||||
|
@ -333,12 +333,12 @@ public final class Tools
|
||||
public static DisplayMetrics currentDisplayMetrics;
|
||||
public static void updateWindowSize(Activity ctx) {
|
||||
currentDisplayMetrics = getDisplayMetrics(ctx);
|
||||
CallbackBridge.windowWidth = currentDisplayMetrics.widthPixels;
|
||||
CallbackBridge.windowHeight = currentDisplayMetrics.heightPixels;
|
||||
CallbackBridge.physicalWidth = (int) (currentDisplayMetrics.widthPixels);
|
||||
CallbackBridge.physicalHeight = (int) (currentDisplayMetrics.heightPixels);
|
||||
|
||||
if (CallbackBridge.windowWidth < CallbackBridge.windowHeight) {
|
||||
CallbackBridge.windowWidth = currentDisplayMetrics.heightPixels;
|
||||
CallbackBridge.windowHeight = currentDisplayMetrics.widthPixels;
|
||||
if (CallbackBridge.physicalWidth < CallbackBridge.physicalHeight) {
|
||||
CallbackBridge.physicalWidth = (int) (currentDisplayMetrics.heightPixels);
|
||||
CallbackBridge.physicalHeight = (int) (currentDisplayMetrics.widthPixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
if (!mProperties.isDynamicBtn) {
|
||||
mProperties.x = x;
|
||||
mProperties.dynamicX = Float.toString(x / CallbackBridge.windowWidth) + " * ${screen_width}";
|
||||
mProperties.dynamicX = Float.toString(x / CallbackBridge.physicalWidth) + " * ${screen_width}";
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
if (!mProperties.isDynamicBtn) {
|
||||
mProperties.y = y;
|
||||
mProperties.dynamicY = Float.toString(y / CallbackBridge.windowHeight) + " * ${screen_height}";
|
||||
mProperties.dynamicY = Float.toString(y / CallbackBridge.physicalHeight) + " * ${screen_height}";
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +151,12 @@ public class ControlData implements Cloneable
|
||||
Map<String, String> keyValueMap = new ArrayMap<>();
|
||||
keyValueMap.put("top", "0");
|
||||
keyValueMap.put("left", "0");
|
||||
keyValueMap.put("right", Float.toString(CallbackBridge.windowWidth - width));
|
||||
keyValueMap.put("bottom", Float.toString(CallbackBridge.windowHeight - height));
|
||||
keyValueMap.put("right", Float.toString(CallbackBridge.physicalWidth - width));
|
||||
keyValueMap.put("bottom", Float.toString(CallbackBridge.physicalHeight - height));
|
||||
keyValueMap.put("width", Float.toString(width));
|
||||
keyValueMap.put("height", Float.toString(height));
|
||||
keyValueMap.put("screen_width", Integer.toString(CallbackBridge.windowWidth));
|
||||
keyValueMap.put("screen_height", Integer.toString(CallbackBridge.windowHeight));
|
||||
keyValueMap.put("screen_width", Integer.toString(CallbackBridge.physicalWidth));
|
||||
keyValueMap.put("screen_height", Integer.toString(CallbackBridge.physicalHeight));
|
||||
keyValueMap.put("margin", Integer.toString((int) Tools.dpToPx(2)));
|
||||
|
||||
// Insert value to ${variable}
|
||||
|
@ -50,8 +50,8 @@ public class ControlLayout extends FrameLayout
|
||||
button.width = button.width / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE;
|
||||
button.height = button.height / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE;
|
||||
if (!button.isDynamicBtn) {
|
||||
button.dynamicX = Float.toString(button.x / CallbackBridge.windowWidth) + " * ${screen_width}";
|
||||
button.dynamicY = Float.toString(button.y / CallbackBridge.windowHeight) + " * ${screen_height}";
|
||||
button.dynamicX = Float.toString(button.x / CallbackBridge.physicalWidth) + " * ${screen_width}";
|
||||
button.dynamicY = Float.toString(button.y / CallbackBridge.physicalHeight) + " * ${screen_height}";
|
||||
}
|
||||
button.update();
|
||||
addControlView(button);
|
||||
|
@ -14,6 +14,7 @@ public class CallbackBridge {
|
||||
public static final int CLIPBOARD_PASTE = 2001;
|
||||
|
||||
public static volatile int windowWidth, windowHeight;
|
||||
public static volatile int physicalWidth, physicalHeight;
|
||||
public static int mouseX, mouseY;
|
||||
public static boolean mouseLeft;
|
||||
public static StringBuilder DEBUG_STRING = new StringBuilder();
|
||||
|
@ -224,4 +224,6 @@
|
||||
<string name="auto_ram_subtitle">Enables automatic RAM adjuster</string>
|
||||
<string name="auto_ram_title">Auto RAM</string>
|
||||
<string name="autoram_info_msg">Memory set to %d MB</string>
|
||||
<string name="resolution_decrease_subtitle">Allows you to decrease the game resolution. Improves framerate. 0 is the default.</string>
|
||||
<string name="resolution_decrease_title">Resolution decrease ratio</string>
|
||||
</resources>
|
||||
|
@ -18,7 +18,13 @@
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false"
|
||||
app2:icon="@drawable/tap_len" />
|
||||
|
||||
<androidx.preference.SeekBarPreference
|
||||
android:key="resolutionRatio"
|
||||
android:summary="@string/resolution_decrease_subtitle"
|
||||
android:title="@string/resolution_decrease_title"
|
||||
android:max="500"
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false" />
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="freeform"
|
||||
|
Loading…
x
Reference in New Issue
Block a user