From 93f49243c21bf09e833487104097a02204fa00a4 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Wed, 3 Feb 2021 21:31:14 +0700 Subject: [PATCH] [AWT launcher] add PRI, SEC --- .../pojavlaunch/JavaGUILauncherActivity.java | 34 +++++++++++++++- .../src/main/res/layout/install_mod.xml | 39 +++++++++++++------ 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java index ee3034239..01ca524f5 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java @@ -16,7 +16,7 @@ import net.kdt.pojavlaunch.prefs.*; import net.kdt.pojavlaunch.utils.*; import org.lwjgl.glfw.*; -public class JavaGUILauncherActivity extends LoggableActivity { +public class JavaGUILauncherActivity extends LoggableActivity implements View.OnTouchListener { private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028; private AWTCanvasView mTextureView; @@ -74,6 +74,9 @@ public class JavaGUILauncherActivity extends LoggableActivity { CallbackBridge.windowWidth = (int) ((float)displayMetrics.widthPixels * scaleFactor); CallbackBridge.windowHeight = (int) ((float)displayMetrics.heightPixels * scaleFactor); System.out.println("WidthHeight: " + CallbackBridge.windowWidth + ":" + CallbackBridge.windowHeight); + + findViewById(R.id.installmod_mouse_pri).setOnTouchListener(this); + findViewById(R.id.installmod_mouse_sec).setOnTouchListener(this); this.touchPad = findViewById(R.id.main_touchpad); touchPad.setFocusable(false); @@ -228,6 +231,35 @@ public class JavaGUILauncherActivity extends LoggableActivity { } } + @Override + public boolean onTouch(View v, MotionEvent e) { + boolean isDown; + switch (e.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; + } + + switch (v.getId()) { + case R.id.installmod_mouse_pri: + AWTInputBridge.sendMousePress(AWTInputEvent.BUTTON1_DOWN_MASK, isDown); + break; + + case R.id.installmod_mouse_sec: + AWTInputBridge.sendMousePress(AWTInputEvent.BUTTON3_DOWN_MASK, isDown); + break; + } + return true; + } + public void placeMouseAdd(float x, float y) { this.mousePointer.setTranslationX(mousePointer.getTranslationX() + x); this.mousePointer.setTranslationY(mousePointer.getTranslationY() + y); diff --git a/app_pojavlauncher/src/main/res/layout/install_mod.xml b/app_pojavlauncher/src/main/res/layout/install_mod.xml index d957ea7e9..05ad90921 100644 --- a/app_pojavlauncher/src/main/res/layout/install_mod.xml +++ b/app_pojavlauncher/src/main/res/layout/install_mod.xml @@ -13,19 +13,19 @@ android:layout_width="match_parent" android:id="@+id/installmod_surfaceview"/> - + - + - +