mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
Scroll when hold 2 fingers
This commit is contained in:
parent
ebc95ec9c7
commit
217f3997db
@ -333,26 +333,14 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_MOVE: // 2
|
case MotionEvent.ACTION_MOVE: // 2
|
||||||
try {
|
mouseX = Math.max(0, Math.min(CallbackBridge.windowWidth, mouseX + x - prevX));
|
||||||
mouseX += x - prevX;
|
mouseY = Math.max(0, Math.min(CallbackBridge.windowHeight, mouseY + y - prevY));
|
||||||
mouseY += y - prevY;
|
|
||||||
if (mouseX <= 0) {
|
|
||||||
mouseX = 0;
|
|
||||||
} else if (mouseX >= CallbackBridge.windowWidth) {
|
|
||||||
mouseX = CallbackBridge.windowWidth;
|
|
||||||
} if (mouseY <= 0) {
|
|
||||||
mouseY = 0;
|
|
||||||
} else if (mouseY >= CallbackBridge.windowHeight) {
|
|
||||||
mouseY = CallbackBridge.windowHeight;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
placeMouseAt(mouseX, mouseY);
|
placeMouseAt(mouseX, mouseY);
|
||||||
|
|
||||||
CallbackBridge.sendCursorPos((int) mouseX, (int) mouseY);
|
CallbackBridge.sendCursorPos((int) mouseX, (int) mouseY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
prevX = x;
|
prevX = x;
|
||||||
prevY = y;
|
prevY = y;
|
||||||
|
|
||||||
@ -372,6 +360,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
glTouchListener = new OnTouchListener(){
|
glTouchListener = new OnTouchListener(){
|
||||||
private boolean isTouchInHotbar = false;
|
private boolean isTouchInHotbar = false;
|
||||||
private int hotbarX, hotbarY;
|
private int hotbarX, hotbarY;
|
||||||
|
private int scrollInitialX, scrollInitialY, scrollX, scrollY;
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View p1, MotionEvent e)
|
public boolean onTouch(View p1, MotionEvent e)
|
||||||
{
|
{
|
||||||
@ -391,7 +380,6 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
} 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;
|
||||||
@ -410,6 +398,9 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CallbackBridge.isGrabbing()) {
|
if (CallbackBridge.isGrabbing()) {
|
||||||
|
scrollX = 0;
|
||||||
|
scrollY = 0;
|
||||||
|
|
||||||
// It cause hold left mouse while moving camera
|
// It cause hold left mouse while moving camera
|
||||||
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y);
|
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y);
|
||||||
initialX = x;
|
initialX = x;
|
||||||
@ -418,9 +409,9 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_UP: // 1
|
case MotionEvent.ACTION_UP: // 1
|
||||||
case MotionEvent.ACTION_CANCEL: // 3
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
|
||||||
if (!isTouchInHotbar) {
|
if (!isTouchInHotbar) {
|
||||||
CallbackBridge.mouseX = x;
|
CallbackBridge.mouseX = x;
|
||||||
CallbackBridge.mouseY = y;
|
CallbackBridge.mouseY = y;
|
||||||
@ -456,6 +447,20 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
|
scrollX = Math.max(0, scrollX + x - scrollInitialX);
|
||||||
|
scrollY = Math.max(0, scrollY + y - scrollInitialY);
|
||||||
|
|
||||||
|
CallbackBridge.sendScroll(scrollX, scrollY);
|
||||||
|
|
||||||
|
scrollInitialX = x;
|
||||||
|
scrollInitialY = y;
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||||
|
scrollInitialX = x;
|
||||||
|
scrollInitialY = y;
|
||||||
|
break;
|
||||||
|
|
||||||
// TODO implement GLFWScrollCallback to ACTION_SCROLL
|
// TODO implement GLFWScrollCallback to ACTION_SCROLL
|
||||||
default:
|
default:
|
||||||
if (!isTouchInHotbar) {
|
if (!isTouchInHotbar) {
|
||||||
@ -682,17 +687,6 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
minecraftGLView.setOnTouchListener(glTouchListener);
|
minecraftGLView.setOnTouchListener(glTouchListener);
|
||||||
minecraftGLView.setOnGenericMotionListener(new OnGenericMotionListener(){
|
|
||||||
@Override
|
|
||||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
|
||||||
switch (event.getActionMasked()) {
|
|
||||||
case MotionEvent.ACTION_SCROLL:
|
|
||||||
CallbackBridge.sendScroll((double) event.getAxisValue(MotionEvent.AXIS_VSCROLL), (double) event.getAxisValue(MotionEvent.AXIS_HSCROLL));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
minecraftGLView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
minecraftGLView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
||||||
|
|
||||||
@ -744,6 +738,20 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
OnGenericMotionListener gmlistener = new OnGenericMotionListener(){
|
||||||
|
@Override
|
||||||
|
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||||
|
switch (event.getActionMasked()) {
|
||||||
|
case MotionEvent.ACTION_SCROLL:
|
||||||
|
CallbackBridge.sendScroll((double) event.getAxisValue(MotionEvent.AXIS_VSCROLL), (double) event.getAxisValue(MotionEvent.AXIS_HSCROLL));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
minecraftGLView.setOnGenericMotionListener(gmlistener);
|
||||||
|
touchPad.setOnGenericMotionListener(gmlistener);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Tools.showError(this, e, true);
|
Tools.showError(this, e, true);
|
||||||
|
@ -113,6 +113,8 @@ public final class Tools
|
|||||||
overrideableArgList.add("-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath());
|
overrideableArgList.add("-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath());
|
||||||
// overrideableArgList.add("-Djava.library.path=" + JREUtils.LD_LIBRARY_PATH);
|
// overrideableArgList.add("-Djava.library.path=" + JREUtils.LD_LIBRARY_PATH);
|
||||||
overrideableArgList.add("-Duser.home=" + new File(Tools.MAIN_PATH).getParent());
|
overrideableArgList.add("-Duser.home=" + new File(Tools.MAIN_PATH).getParent());
|
||||||
|
overrideableArgList.add("-Duser.language=" + System.getProperty("user.language"));
|
||||||
|
// overrideableArgList.add("-Duser.timezone=GMT");
|
||||||
|
|
||||||
// Should be compatible?
|
// Should be compatible?
|
||||||
// overrideableArgList.add("-Dos.name=Android");
|
// overrideableArgList.add("-Dos.name=Android");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user