Custom controls changes

- Add key combination: Alt, Control, Shift.
- Add new special button: middle mouse.
- Allow rename a special button.
This commit is contained in:
khanhduytran0
2020-11-21 11:53:53 +07:00
parent c25b7bd768
commit dd6d080b4e
7 changed files with 69 additions and 35 deletions

View File

@@ -76,6 +76,10 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
break;
case ControlData.SPECIALBTN_MOUSEMID:
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_MIDDLE, isDown);
break;
case ControlData.SPECIALBTN_MOUSESEC:
if (CallbackBridge.isGrabbing()) {
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown);

View File

@@ -52,9 +52,6 @@ public class MainActivity extends BaseMainActivity implements OnClickListener, O
this.toggleControlButton.setOnClickListener(this);
this.zoomButton.setVisibility(mVersionInfo.optifineLib == null ? View.GONE : View.VISIBLE);
ControlData[] specialButtons = ControlData.getSpecialButtons();
specialButtons[1].specialButtonListener = this;
// toggleGui(null);
onClick(toggleControlButton);
}

View File

@@ -16,6 +16,8 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
private boolean mCanModify = false;
private boolean mCanTriggerLongClick = true;
private int mMods;
public ControlButton(Context ctx, ControlData properties) {
super(ctx);
@@ -47,6 +49,14 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
public void setProperties(ControlData properties, boolean changePos) {
mProperties = properties;
properties.update();
if (properties.holdAlt) {
mMods &= LWJGLGLFWKeycode.GLFW_MOD_ALT;
} if (properties.holdCtrl) {
mMods &= LWJGLGLFWKeycode.GLFW_MOD_CONTROL;
} if (properties.holdShift) {
mMods &= LWJGLGLFWKeycode.GLFW_MOD_SHIFT;
}
// com.android.internal.R.string.delete
// android.R.string.
@@ -131,7 +141,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
default:
return false;
}
MainActivity.sendKeyPress(mProperties.keycode, 0, isDown);
MainActivity.sendKeyPress(mProperties.keycode, mMods, isDown);
return true;
}

View File

@@ -19,6 +19,7 @@ public class ControlData implements Cloneable
public static final int SPECIALBTN_MOUSEPRI = -3;
public static final int SPECIALBTN_MOUSESEC = -4;
public static final int SPECIALBTN_VIRTUALMOUSE = -5;
public static final int SPECIALBTN_MOUSEMID = -6;
private static ControlData[] SPECIAL_BUTTONS;
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
@@ -42,6 +43,7 @@ public class ControlData implements Cloneable
new ControlData("Keyboard", SPECIALBTN_KEYBOARD, "${margin} * 3 + ${width} * 2", "${margin}", false),
new ControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${bottom} - ${margin}"),
new ControlData("PRI", SPECIALBTN_MOUSEPRI, "${margin}", "${screen_height} - ${margin} * 3 - ${height} * 3"),
new ControlData("MID", SPECIALBTN_MOUSEMID, "${margin}", "${margin}"),
new ControlData("SEC", SPECIALBTN_MOUSESEC, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} * 3 - ${height} * 3"),
new ControlData("Mouse", SPECIALBTN_VIRTUALMOUSE, "${right}", "${margin}", false)
};