Fix the incorrectly set modifiers

This commit is contained in:
artdeell
2021-01-14 18:44:12 +03:00
parent 3395b43c91
commit ea355d326a
5 changed files with 19 additions and 11 deletions

View File

@@ -27,7 +27,7 @@ android {
applicationId "net.kdt.pojavlaunch"
minSdkVersion 21
targetSdkVersion 29
versionCode 156237
versionCode 156238
versionName "3.3.1b_6409b_" + getDate()
multiDexEnabled true //important
}

View File

Binary file not shown.

View File

@@ -164,14 +164,19 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
private void setHolding(boolean isDown) {
if (mProperties.holdAlt || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_LEFT_ALT || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_RIGHT_ALT) {
CallbackBridge.holdingAlt = isDown;
System.out.println("holdingAlt="+CallbackBridge.holdingAlt);
} if (mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_CAPS_LOCK) {
CallbackBridge.holdingCapslock = isDown;
System.out.println("holdingCapslock="+CallbackBridge.holdingCapslock);
} if (mProperties.holdCtrl || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_LEFT_CONTROL || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_RIGHT_CONTROL) {
CallbackBridge.holdingCtrl = isDown;
System.out.println("holdingCtrl="+CallbackBridge.holdingCtrl);
} if (mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_NUM_LOCK) {
CallbackBridge.holdingNumlock = isDown;
System.out.println("holdingNumlock="+CallbackBridge.holdingNumlock);
} if (mProperties.holdShift || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT || mProperties.keycode == LWJGLGLFWKeycode.GLFW_KEY_RIGHT_SHIFT) {
CallbackBridge.holdingShift = isDown;
System.out.println("holdingShift="+CallbackBridge.holdingShift);
}
}
@@ -187,18 +192,19 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN: // 0
case MotionEvent.ACTION_POINTER_DOWN: // 5
isDown = true;
setHolding(true);
MainActivity.sendKeyPress(mProperties.keycode, CallbackBridge.getCurrentMods(), true);
break;
case MotionEvent.ACTION_UP: // 1
case MotionEvent.ACTION_CANCEL: // 3
case MotionEvent.ACTION_POINTER_UP: // 6
isDown = false;
setHolding(false);
MainActivity.sendKeyPress(mProperties.keycode, CallbackBridge.getCurrentMods(), false);
break;
default:
return false;
}
setHolding(isDown);
MainActivity.sendKeyPress(mProperties.keycode, CallbackBridge.getCurrentMods(), isDown);
} else if (mGestureDetector.onTouchEvent(event)) {
mChecked = !mChecked;
invalidate();

View File

@@ -71,6 +71,8 @@ public class ControlLayout extends FrameLayout
view.setModifiable(mModifiable);
if (!mModifiable) {
view.setAlpha(1f - view.getProperties().transparency / 100);
view.setFocusable(false);
view.setFocusableInTouchMode(false);
}
addView(view);

View File

@@ -135,20 +135,20 @@ public class CallbackBridge {
private static native void nativeSendData(boolean isAndroid, int type, String data);
*/
public static boolean holdingAlt, holdingCapslock, holdingCtrl,
public volatile static boolean holdingAlt, holdingCapslock, holdingCtrl,
holdingNumlock, holdingShift;
public static int getCurrentMods() {
int currMods = 0;
if (holdingAlt) {
currMods &= LWJGLGLFWKeycode.GLFW_MOD_ALT;
currMods |= LWJGLGLFWKeycode.GLFW_MOD_ALT;
} if (holdingCapslock) {
currMods &= LWJGLGLFWKeycode.GLFW_MOD_CAPS_LOCK;
currMods |= LWJGLGLFWKeycode.GLFW_MOD_CAPS_LOCK;
} if (holdingCtrl) {
currMods &= LWJGLGLFWKeycode.GLFW_MOD_CONTROL;
currMods |= LWJGLGLFWKeycode.GLFW_MOD_CONTROL;
} if (holdingNumlock) {
currMods &= LWJGLGLFWKeycode.GLFW_MOD_NUM_LOCK;
currMods |= LWJGLGLFWKeycode.GLFW_MOD_NUM_LOCK;
} if (holdingShift) {
currMods &= LWJGLGLFWKeycode.GLFW_MOD_SHIFT;
currMods |= LWJGLGLFWKeycode.GLFW_MOD_SHIFT;
}
return currMods;
}