- [Custom controls] Changed some maths in calculating generated control.
- [Custom controls design] Try to fix hold issue.
- [ingame] Try to fix pointer capture issue.
This commit is contained in:
khanhduytran0 2020-11-20 20:36:46 +07:00
parent ec819ba538
commit 1373a76e74
5 changed files with 106 additions and 114 deletions

View file

@ -311,14 +311,14 @@ public abstract class HandleView extends View implements ViewPositionListener, V
return 0;
}
// MOD: Addition
// Addition
@Override
public boolean onLongClick(View view) {
showActionPopupWindow(0);
return true;
}
// MOD: Addition
// Addition
private float mDownX, mDownY;
@Override

View file

@ -83,7 +83,6 @@ public class BaseMainActivity extends LoggableActivity {
private TextView debugText;
private PointerOreoWrapper pointerSurface;
private View.OnTouchListener pointerCaptureListener;
// private String mQueueText = new String();
@ -530,7 +529,9 @@ public class BaseMainActivity extends LoggableActivity {
}
};
pointerCaptureListener = new OnTouchListener(){
if (isPointerCaptureSupported()) {
this.pointerSurface = new PointerOreoWrapper(minecraftGLView);
this.pointerSurface.setOnCapturedPointerListener(new PointerOreoWrapper.OnCapturedPointerListener(){
private int x, y;
private boolean debugErrored = false;
@ -545,8 +546,7 @@ public class BaseMainActivity extends LoggableActivity {
}
@Override
public boolean onTouch(View p1, MotionEvent e)
{
public boolean onCapturedPointer(View view, MotionEvent e) {
x += ((int) e.getX()) / scaleFactor;
y -= ((int) e.getY()) / scaleFactor;
@ -627,15 +627,6 @@ public class BaseMainActivity extends LoggableActivity {
return true;
// If onClick fail with false, change back to true
}
};
if (isPointerCaptureSupported()) {
this.pointerSurface = new PointerOreoWrapper(minecraftGLView);
this.pointerSurface.setOnCapturedPointerListener(new PointerOreoWrapper.OnCapturedPointerListener(){
@Override
public boolean onCapturedPointer(View view, MotionEvent event) {
return pointerCaptureListener.onTouch(view, event);
}
});
}

View file

@ -140,12 +140,13 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
}
switch (event.getActionMasked()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_DOWN:
mCanTriggerLongClick = true;
downX = event.getX();
downY = event.getY();
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_MOVE:
mCanTriggerLongClick = false;
moveX += event.getX() - downX;

View file

@ -40,7 +40,7 @@ public class ControlData implements Cloneable
if (SPECIAL_BUTTONS == null) {
ControlData[] specialButtons = new ControlData[]{
new ControlData("Keyboard", SPECIALBTN_KEYBOARD, "${margin} * 3 + ${width} * 2", "${margin}", false),
new ControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${bottom}"),
new ControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${bottom} - ${margin}"),
new ControlData("PRI", SPECIALBTN_MOUSEPRI, "${margin}", "${screen_height} - ${margin} * 3 - ${height} * 3"),
new ControlData("SEC", SPECIALBTN_MOUSESEC, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} * 3 - ${height} * 3"),
new ControlData("Mouse", SPECIALBTN_VIRTUALMOUSE, "${right}", "${margin}", false)

View file

@ -30,14 +30,14 @@ public class CustomControls
this.mControlDataList.add(new ControlData(ctx, R.string.control_listplayers, LWJGLGLFWKeycode.GLFW_KEY_TAB, "${margin} * 4 + ${width} * 3", "${margin}", false));
this.mControlDataList.add(new ControlData(ctx, R.string.control_thirdperson, LWJGLGLFWKeycode.GLFW_KEY_F5, "${margin}", "${height} + ${margin}", false));
this.mControlDataList.add(new ControlData(ctx, R.string.control_up, LWJGLGLFWKeycode.GLFW_KEY_W, "${margin} * 2 + ${width}", "${screen_height} - ${margin} * 3 - ${height} * 3", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_left, LWJGLGLFWKeycode.GLFW_KEY_A, "${margin}", "${screen_height} - ${margin} * 2 - ${height} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_down, LWJGLGLFWKeycode.GLFW_KEY_S, "${margin} * 2 + ${width}", "${screen_height} - ${margin} - ${width}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_right, LWJGLGLFWKeycode.GLFW_KEY_D, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} * 2 - ${width} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_up, LWJGLGLFWKeycode.GLFW_KEY_W, "${margin} * 2 + ${width}", "${bottom} - ${margin} * 3 - ${height} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_left, LWJGLGLFWKeycode.GLFW_KEY_A, "${margin}", "${bottom} - ${margin} * 2 - ${height}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_down, LWJGLGLFWKeycode.GLFW_KEY_S, "${margin} * 2 + ${width}", "${bottom} - ${margin}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_right, LWJGLGLFWKeycode.GLFW_KEY_D, "${margin} * 3 + ${width} * 2", "${bottom} - ${margin} * 2 - ${height}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_inventory, LWJGLGLFWKeycode.GLFW_KEY_E, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} - ${width}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_shift, LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT, "${margin} * 2 + ${width}", "${screen_height} - ${margin} * 2 - ${width} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_jump, LWJGLGLFWKeycode.GLFW_KEY_SPACE, "${screen_width} - ${margin} * 3 - ${width} * 2", "${screen_height} - ${margin} * 2 - ${width} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_inventory, LWJGLGLFWKeycode.GLFW_KEY_E, "${margin} * 3 + ${width} * 2", "${bottom} - ${margin}", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_shift, LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT, "${margin} * 2 + ${width}", "${screen_height} - ${margin} * 2 - ${height} * 2", true));
this.mControlDataList.add(new ControlData(ctx, R.string.control_jump, LWJGLGLFWKeycode.GLFW_KEY_SPACE, "${right} - ${margin} * 2 - ${width}", "${bottom} - ${margin} * 2 - ${height}", true));
}