Moved the setModifiers to the CallbackBridge

This commit is contained in:
SerpentSpirale 2021-07-23 11:12:00 +02:00
parent f425322eb5
commit 59bc3764dd
2 changed files with 25 additions and 23 deletions

View File

@ -133,29 +133,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
((ControlLayout) getParent()).setModified(modified);
}
private void setHolding(int keyCode, boolean isDown){
switch (keyCode){
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT:
CallbackBridge.holdingShift = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_CONTROL:
CallbackBridge.holdingCtrl = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_ALT:
CallbackBridge.holdingAlt = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_CAPS_LOCK:
CallbackBridge.holdingCapslock = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_NUM_LOCK:
CallbackBridge.holdingNumlock = isDown;
return;
}
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
@ -353,7 +331,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
for(int keycode : mProperties.keycodes){
if(keycode >= GLFW_KEY_UNKNOWN){
MainActivity.sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown);
setHolding(keycode, isDown);
CallbackBridge.setModifiers(keycode, isDown);
}else {
super.onTouchEvent(event);
}

View File

@ -166,6 +166,30 @@ public class CallbackBridge {
return currMods;
}
public static void setModifiers(int keyCode, boolean isDown){
switch (keyCode){
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT:
CallbackBridge.holdingShift = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_CONTROL:
CallbackBridge.holdingCtrl = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_LEFT_ALT:
CallbackBridge.holdingAlt = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_CAPS_LOCK:
CallbackBridge.holdingCapslock = isDown;
return;
case LWJGLGLFWKeycode.GLFW_KEY_NUM_LOCK:
CallbackBridge.holdingNumlock = isDown;
return;
}
}
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
private static native boolean nativeSendChar(char codepoint);