mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
Changes
- Removed unused class ShellProcessOperation.java - Correctly implemented touching 2 fingers for scrolling.
This commit is contained in:
parent
2a8569146c
commit
df41a166bc
@ -407,7 +407,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
} else {
|
} else {
|
||||||
switch (e.getActionMasked()) {
|
switch (e.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN: // 0
|
case MotionEvent.ACTION_DOWN: // 0
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
|
||||||
CallbackBridge.sendPrepareGrabInitialPos();
|
CallbackBridge.sendPrepareGrabInitialPos();
|
||||||
|
|
||||||
isTouchInHotbar = hudKeyHandled != -1;
|
isTouchInHotbar = hudKeyHandled != -1;
|
||||||
@ -439,7 +438,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_UP: // 1
|
case MotionEvent.ACTION_UP: // 1
|
||||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
|
||||||
case MotionEvent.ACTION_CANCEL: // 3
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
if (!isTouchInHotbar) {
|
if (!isTouchInHotbar) {
|
||||||
CallbackBridge.mouseX = mouse_x;
|
CallbackBridge.mouseX = mouse_x;
|
||||||
@ -459,7 +457,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
if (isTouchInHotbar && Math.abs(hotbarX - mouse_x) < fingerStillThreshold && Math.abs(hotbarY - mouse_y) < fingerStillThreshold) {
|
if (isTouchInHotbar && Math.abs(hotbarX - mouse_x) < fingerStillThreshold && Math.abs(hotbarY - mouse_y) < fingerStillThreshold) {
|
||||||
sendKeyPress(hudKeyHandled, 0, false);
|
sendKeyPress(hudKeyHandled, 0, false);
|
||||||
} else if (!triggeredLeftMouseButton && Math.abs(initialX - mouse_x) < fingerStillThreshold && Math.abs(initialY - mouse_y) < fingerStillThreshold) {
|
} else if (!triggeredLeftMouseButton && Math.abs(initialX - mouse_x) < fingerStillThreshold && Math.abs(initialY - mouse_y) < fingerStillThreshold) {
|
||||||
if(!LauncherPreferences.PREF_DISABLE_GESTURES) {
|
if (!LauncherPreferences.PREF_DISABLE_GESTURES) {
|
||||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
|
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
|
||||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
|
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
|
||||||
}
|
}
|
||||||
@ -477,35 +475,25 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
CallbackBridge.sendScroll(x - scrollInitialX, y - scrollInitialY);
|
scrollInitialX = CallbackBridge.mouseX;
|
||||||
scrollInitialX = x;
|
scrollInitialY = CallbackBridge.mouseY;
|
||||||
scrollInitialY = y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||||
scrollInitialX = x;
|
|
||||||
scrollInitialY = y;
|
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
if (!isTouchInHotbar) {
|
if (!CallbackBridge.isGrabbing() && e.getPointerCount() == 2 && !LauncherPreferences.PREF_DISABLE_GESTURES) {
|
||||||
|
CallbackBridge.sendScroll(CallbackBridge.mouseX - scrollInitialX, CallbackBridge.mouseY - scrollInitialY);
|
||||||
|
scrollInitialX = CallbackBridge.mouseX;
|
||||||
|
scrollInitialY = CallbackBridge.mouseY;
|
||||||
|
} else if (!isTouchInHotbar) {
|
||||||
CallbackBridge.mouseX = mouse_x;
|
CallbackBridge.mouseX = mouse_x;
|
||||||
CallbackBridge.mouseY = mouse_y;
|
CallbackBridge.mouseY = mouse_y;
|
||||||
|
|
||||||
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
||||||
|
|
||||||
if (!CallbackBridge.isGrabbing()) {
|
|
||||||
/*
|
|
||||||
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, 0, isLeftMouseDown);
|
|
||||||
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, 0, isRightMouseDown);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// CallbackBridge.sendScroll(mouse_x - scrollInitialX, mouse_y - scrollInitialY);
|
|
||||||
scrollInitialX = mouse_x;
|
|
||||||
scrollInitialY = mouse_y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
package net.kdt.pojavlaunch;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import android.app.*;
|
|
||||||
|
|
||||||
public class ShellProcessOperation
|
|
||||||
{
|
|
||||||
private OnPrintListener listener;
|
|
||||||
private Process process;
|
|
||||||
|
|
||||||
public ShellProcessOperation(OnPrintListener listener) throws IOException {
|
|
||||||
this.listener = listener;
|
|
||||||
process = Runtime.getRuntime().exec("/system/bin/sh");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShellProcessOperation(OnPrintListener listener, String command) throws IOException {
|
|
||||||
this.listener = listener;
|
|
||||||
process = Runtime.getRuntime().exec(
|
|
||||||
command
|
|
||||||
); //"/system/bin/sh -c \"" + command + "\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToProcess(String[] cmdArr) throws IOException {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (String cmd : cmdArr) {sb.append(cmd + " ");}
|
|
||||||
writeToProcess(sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToProcess(String cmd) throws IOException {
|
|
||||||
// listener.onPrintLine(" > " + cmd + "\n");
|
|
||||||
|
|
||||||
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
|
||||||
os.writeBytes(cmd + "\n");
|
|
||||||
os.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initInputStream(Activity ctx) {
|
|
||||||
ctx.runOnUiThread(new Runnable(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
printStream(process.getInputStream());
|
|
||||||
printStream(process.getErrorStream());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public int exitCode() {
|
|
||||||
return process.exitValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int waitFor() throws InterruptedException {
|
|
||||||
return process.waitFor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int exit() throws InterruptedException, IOException {
|
|
||||||
writeToProcess("exit");
|
|
||||||
return waitFor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printStream(final InputStream stream) {
|
|
||||||
new Thread(new Runnable(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
BufferedReader buffStream = new BufferedReader(new InputStreamReader(stream));
|
|
||||||
String line = null;
|
|
||||||
while ((line = buffStream.readLine()) != null) {
|
|
||||||
listener.onPrintLine(line + "\n");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
listener.onPrintLine("PrintStream error: " + e.getMessage() + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface OnPrintListener {
|
|
||||||
public void onPrintLine(String text);
|
|
||||||
}
|
|
||||||
}
|
|
@ -214,7 +214,7 @@ public class JREUtils
|
|||||||
LD_LIBRARY_PATH = ldLibraryPath.toString();
|
LD_LIBRARY_PATH = ldLibraryPath.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setJavaEnvironment(LoggableActivity ctx, @Nullable ShellProcessOperation shell) throws Throwable {
|
public static void setJavaEnvironment(LoggableActivity ctx) throws Throwable {
|
||||||
Map<String, String> envMap = new ArrayMap<>();
|
Map<String, String> envMap = new ArrayMap<>();
|
||||||
envMap.put("JAVA_HOME", Tools.DIR_HOME_JRE);
|
envMap.put("JAVA_HOME", Tools.DIR_HOME_JRE);
|
||||||
envMap.put("HOME", Tools.DIR_GAME_NEW);
|
envMap.put("HOME", Tools.DIR_GAME_NEW);
|
||||||
@ -261,15 +261,7 @@ public class JREUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> env : envMap.entrySet()) {
|
for (Map.Entry<String, String> env : envMap.entrySet()) {
|
||||||
try {
|
Os.setenv(env.getKey(), env.getValue(), true);
|
||||||
if (shell == null) {
|
|
||||||
Os.setenv(env.getKey(), env.getValue(), true);
|
|
||||||
} else {
|
|
||||||
shell.writeToProcess("export " + env.getKey() + "=" + env.getValue());
|
|
||||||
}
|
|
||||||
} catch (Throwable th) {
|
|
||||||
ctx.appendlnToLog(Log.getStackTraceString(th));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shell == null) {
|
if (shell == null) {
|
||||||
@ -312,7 +304,7 @@ public class JREUtils
|
|||||||
ctx.appendlnToLog("Executing JVM: \"" + sbJavaArgs.toString() + "\"");
|
ctx.appendlnToLog("Executing JVM: \"" + sbJavaArgs.toString() + "\"");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
setJavaEnvironment(ctx, null);
|
setJavaEnvironment(ctx);
|
||||||
initJavaRuntime();
|
initJavaRuntime();
|
||||||
chdir(Tools.DIR_GAME_NEW);
|
chdir(Tools.DIR_GAME_NEW);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user