From 0d45a4e170b565432a46c53eeabececa0381509b Mon Sep 17 00:00:00 2001 From: SerpentSpirale Date: Fri, 13 Aug 2021 23:18:50 +0200 Subject: [PATCH] Fix broken special buttons introduced in the previous commit --- .../pojavlaunch/customcontrols/ControlLayout.java | 6 +++--- .../customcontrols/buttons/ControlButton.java | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java index 621486469..6dacb6746 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java @@ -260,7 +260,7 @@ public class ControlLayout extends FrameLayout //Check if the action is cancelling, reset the lastControl button associated to the view if(ev.getActionMasked() == MotionEvent.ACTION_UP || ev.getActionMasked() == MotionEvent.ACTION_CANCEL){ - if(lastControlButton != null) lastControlButton.sendKeyPresses(false); + if(lastControlButton != null) lastControlButton.sendKeyPresses(ev,false); mapTable.put(v, null); return true; } @@ -276,7 +276,7 @@ public class ControlLayout extends FrameLayout } //Release last keys - if (lastControlButton != null) lastControlButton.sendKeyPresses(false); + if (lastControlButton != null) lastControlButton.sendKeyPresses(ev,false); mapTable.put(v, null); //Look for another SWIPEABLE button @@ -288,7 +288,7 @@ public class ControlLayout extends FrameLayout //Press the new key if(!button.equals(lastControlButton)){ - button.sendKeyPresses(true); + button.sendKeyPresses(ev,true); mapTable.put(v, button); } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java index 8290efe24..20a85ca6d 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/buttons/ControlButton.java @@ -269,7 +269,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp if(mProperties.isSwipeable && !isPointerOutOfBounds){ //Remove keys if(!triggerToggle(event)) { - sendKeyPresses(false); + sendKeyPresses(event,false); } } isPointerOutOfBounds = true; @@ -282,7 +282,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp ((ControlLayout) getParent()).onTouch(this, event); //RE-press the button if(mProperties.isSwipeable && !mProperties.isToggle){ - sendKeyPresses(true); + sendKeyPresses(event,true); } } isPointerOutOfBounds = false; @@ -291,7 +291,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp case MotionEvent.ACTION_DOWN: // 0 case MotionEvent.ACTION_POINTER_DOWN: // 5 if(!mProperties.isToggle){ - sendKeyPresses(true); + sendKeyPresses(event,true); } break; @@ -306,7 +306,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp isPointerOutOfBounds = false; if(!triggerToggle(event)) { - sendKeyPresses(false); + sendKeyPresses(event,false); } break; @@ -465,17 +465,19 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp if(mProperties.isToggle){ isToggled = !isToggled; invalidate(); - sendKeyPresses(isToggled); + sendKeyPresses(event, isToggled); return true; } return false; } - public void sendKeyPresses(boolean isDown){ + public void sendKeyPresses(MotionEvent event, boolean isDown){ for(int keycode : mProperties.keycodes){ if(keycode >= GLFW_KEY_UNKNOWN){ MainActivity.sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown); CallbackBridge.setModifiers(keycode, isDown); + }else{ + super.onTouchEvent(event); } } }