mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-19 00:56:57 -04:00
[Custom controls] Implements keycode send
This commit is contained in:
@@ -1073,11 +1073,11 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
// this.secondaryButton.setBackgroundDrawable(this.rightOverride ? this.secondaryButtonColorBackground : this.secondaryButtonDefaultBackground);
|
||||
}
|
||||
|
||||
public void sendKeyPress(int keyCode, int modifiers, boolean status) {
|
||||
public static void sendKeyPress(int keyCode, int modifiers, boolean status) {
|
||||
sendKeyPress(keyCode, '\u0000', modifiers, status);
|
||||
}
|
||||
|
||||
public void sendKeyPress(int keyCode, char keyChar, int modifiers, boolean status) {
|
||||
public static void sendKeyPress(int keyCode, char keyChar, int modifiers, boolean status) {
|
||||
CallbackBridge.sendKeycode(keyCode, keyChar, modifiers, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View p1)
|
||||
{
|
||||
public boolean onLongClick(View p1) {
|
||||
if (!mCanTriggerLongClick) return false;
|
||||
|
||||
if (mHandleView.isShowing()) {
|
||||
@@ -116,7 +115,27 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
public boolean onTouch(View view, MotionEvent event) {
|
||||
if (!mCanModify) {
|
||||
mCanTriggerLongClick = false;
|
||||
|
||||
if (mProperties.keycode >= 0) {
|
||||
boolean isDown;
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN: // 0
|
||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||
isDown = true;
|
||||
break;
|
||||
case MotionEvent.ACTION_UP: // 1
|
||||
case MotionEvent.ACTION_CANCEL: // 3
|
||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||
isDown = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
MainActivity.sendKeyPress(mProperties.keycode, 0, isDown);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user