mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
Swipeable buttons are a bit faster now
This commit is contained in:
parent
1929143337
commit
17f78bed03
@ -260,7 +260,7 @@ public class ControlLayout extends FrameLayout
|
|||||||
|
|
||||||
//Check if the action is cancelling, reset the lastControl button associated to the view
|
//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(ev.getActionMasked() == MotionEvent.ACTION_UP || ev.getActionMasked() == MotionEvent.ACTION_CANCEL){
|
||||||
if(lastControlButton != null) lastControlButton.onTouchEvent(ev);
|
if(lastControlButton != null) lastControlButton.sendKeyPresses(false);
|
||||||
mapTable.put(v, null);
|
mapTable.put(v, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -275,9 +275,8 @@ public class ControlLayout extends FrameLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Release the last key
|
//Release last keys
|
||||||
ev.setAction(MotionEvent.ACTION_POINTER_UP);
|
if (lastControlButton != null) lastControlButton.sendKeyPresses(false);
|
||||||
if (lastControlButton != null) lastControlButton.onTouchEvent(ev);
|
|
||||||
mapTable.put(v, null);
|
mapTable.put(v, null);
|
||||||
|
|
||||||
//Look for another SWIPEABLE button
|
//Look for another SWIPEABLE button
|
||||||
@ -289,8 +288,7 @@ public class ControlLayout extends FrameLayout
|
|||||||
|
|
||||||
//Press the new key
|
//Press the new key
|
||||||
if(!button.equals(lastControlButton)){
|
if(!button.equals(lastControlButton)){
|
||||||
ev.setAction(MotionEvent.ACTION_POINTER_DOWN);
|
button.sendKeyPresses(true);
|
||||||
button.onTouchEvent(ev);
|
|
||||||
|
|
||||||
mapTable.put(v, button);
|
mapTable.put(v, button);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
if(mProperties.isSwipeable && !isPointerOutOfBounds){
|
if(mProperties.isSwipeable && !isPointerOutOfBounds){
|
||||||
//Remove keys
|
//Remove keys
|
||||||
if(!triggerToggle(event)) {
|
if(!triggerToggle(event)) {
|
||||||
sendKeyPresses(event, false);
|
sendKeyPresses(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isPointerOutOfBounds = true;
|
isPointerOutOfBounds = true;
|
||||||
@ -282,7 +282,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
((ControlLayout) getParent()).onTouch(this, event);
|
((ControlLayout) getParent()).onTouch(this, event);
|
||||||
//RE-press the button
|
//RE-press the button
|
||||||
if(mProperties.isSwipeable && !mProperties.isToggle){
|
if(mProperties.isSwipeable && !mProperties.isToggle){
|
||||||
sendKeyPresses(event, true);
|
sendKeyPresses(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isPointerOutOfBounds = false;
|
isPointerOutOfBounds = false;
|
||||||
@ -291,7 +291,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
case MotionEvent.ACTION_DOWN: // 0
|
case MotionEvent.ACTION_DOWN: // 0
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
if(!mProperties.isToggle){
|
if(!mProperties.isToggle){
|
||||||
sendKeyPresses(event, true);
|
sendKeyPresses(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
isPointerOutOfBounds = false;
|
isPointerOutOfBounds = false;
|
||||||
|
|
||||||
if(!triggerToggle(event)) {
|
if(!triggerToggle(event)) {
|
||||||
sendKeyPresses(event, false);
|
sendKeyPresses(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -465,19 +465,17 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp
|
|||||||
if(mProperties.isToggle){
|
if(mProperties.isToggle){
|
||||||
isToggled = !isToggled;
|
isToggled = !isToggled;
|
||||||
invalidate();
|
invalidate();
|
||||||
sendKeyPresses(event, isToggled);
|
sendKeyPresses(isToggled);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendKeyPresses(MotionEvent event, boolean isDown){
|
public void sendKeyPresses(boolean isDown){
|
||||||
for(int keycode : mProperties.keycodes){
|
for(int keycode : mProperties.keycodes){
|
||||||
if(keycode >= GLFW_KEY_UNKNOWN){
|
if(keycode >= GLFW_KEY_UNKNOWN){
|
||||||
MainActivity.sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown);
|
MainActivity.sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown);
|
||||||
CallbackBridge.setModifiers(keycode, isDown);
|
CallbackBridge.setModifiers(keycode, isDown);
|
||||||
}else {
|
|
||||||
super.onTouchEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user