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