Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Jan 10, 2022
2 parents 15030ac + bb9d2ea commit b85dd16
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 102 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,28 @@ jobs:
java-version: 1.8

- name: Get gl4es latest commit hash
if: github.ref == 'refs/heads/v3_openjdk'
id: gl4es-sha
run: echo "::set-output name=sha::$(echo $(git ls-remote https://github.com/PojavLauncherTeam/gl4es refs/heads/master | grep -io '^\S*'))"
shell: bash

- name: Cache gl4es
if: github.ref == 'refs/heads/v3_openjdk'
uses: actions/cache@v2
id: gl4es-cache
with:
path: gl4es/libs
key: gl4es-android-shared-nodbg-test1-2-${{ steps.gl4es-sha.outputs.sha }}

- name: Get gl4es
if: steps.gl4es-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'ptitSeb/gl4es'
path: 'gl4es'

- name: Build gl4es
if: steps.gl4es-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cd gl4es
Expand All @@ -57,7 +59,7 @@ jobs:
$ANDROID_NDK_HOME/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
- name: Install gl4es
if: steps.gl4es-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
run: |
cp -R gl4es/libs/* app_pojavlauncher/src/main/jniLibs/
mv gl4es ..
Expand All @@ -66,33 +68,35 @@ jobs:
git push
- name: Get vgpu latest commit hash
if: github.ref == 'refs/heads/v3_openjdk'
id: vgpu-sha
run: echo "::set-output name=sha::$(echo $(git ls-remote https://github.com/PojavLauncherTeam/VGPU refs/heads/main | grep -io '^\S*'))"
shell: bash

- name: Cache vgpu
if: github.ref == 'refs/heads/v3_openjdk'
uses: actions/cache@v2
id: vgpu-cache
with:
path: vgpu/libs
key: vgpu-android-shared-1-${{ steps.vgpu-sha.outputs.sha }}

- name: Get vgpu
if: steps.vgpu-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'PojavLauncherTeam/VGPU'
path: 'vgpu'

- name: Build vgpu
if: steps.vgpu-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cd vgpu
$ANDROID_NDK_HOME/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
- name: Install vgpu
if: steps.vgpu-cache.outputs.cache-hit != 'true'
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
run: |
cp -R vgpu/libs/* app_pojavlauncher/src/main/jniLibs/
mv vgpu ..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static net.kdt.pojavlaunch.Architecture.ARCH_X86;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_VIRTUAL_MOUSE_START;

import static org.lwjgl.glfw.CallbackBridge.sendKeyPress;
import static org.lwjgl.glfw.CallbackBridge.windowHeight;
Expand Down Expand Up @@ -153,6 +154,10 @@ protected void initLayout(int resId) {

minecraftGLView.setSurfaceReadyListener(() -> {
try {
// Setup virtual mouse right before launching
if (PREF_VIRTUAL_MOUSE_START)
touchpad.switchState();

runCraft();
}catch (Throwable e){
Tools.showError(getApplicationContext(), e, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class MinecraftGLView extends TextureView {
private Gamepad gamepad = null;
/* Pointer Debug textview, used to show info about the pointer state */
private TextView pointerDebugText;

/* Resolution scaler option, allow downsizing a window */
private final float scaleFactor = LauncherPreferences.DEFAULT_PREF.getInt("resolutionRatio",100)/100f;
/* Display properties, such as resolution and DPI */
Expand All @@ -67,8 +66,6 @@ public class MinecraftGLView extends TextureView {
private boolean shouldBeDown = false;
/* When fingers are really near to each other, it tends to either swap or remove a pointer ! */
private int lastPointerCount = 0;
/* Mouse positions, scaled by the scaleFactor */
private float mouse_x, mouse_y;
/* Previous MotionEvent position, not scale */
private float prevX, prevY;
/* PointerID used for the moving camera */
Expand Down Expand Up @@ -208,11 +205,11 @@ public boolean onTouchEvent(MotionEvent e) {
//Getting scaled position from the event
/* Tells if a double tap happened [MOUSE GRAB ONLY]. Doesn't tell where though. */
if(!CallbackBridge.isGrabbing()) {
mouse_x = (e.getX() * scaleFactor);
mouse_y = (e.getY() * scaleFactor);
CallbackBridge.mouseX = (e.getX() * scaleFactor);
CallbackBridge.mouseY = (e.getY() * scaleFactor);
//One android click = one MC click
if(singleTapDetector.onTouchEvent(e)){
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, mouse_x, mouse_y);
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, CallbackBridge.mouseX, CallbackBridge.mouseY);
return true;
}
}
Expand All @@ -229,7 +226,7 @@ public boolean onTouchEvent(MotionEvent e) {

// Touch hover
if(pointerCount == 1){
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
prevX = e.getX();
prevY = e.getY();
break;
Expand Down Expand Up @@ -264,14 +261,14 @@ public boolean onTouchEvent(MotionEvent e) {
}
// Continue movement as usual
if(hudKeyHandled == -1){ //No camera on hotbar
mouse_x += (e.getX(pointerIndex) - prevX) * sensitivityFactor;
mouse_y += (e.getY(pointerIndex) - prevY) * sensitivityFactor;
CallbackBridge.mouseX += (e.getX(pointerIndex) - prevX) * sensitivityFactor;
CallbackBridge.mouseY += (e.getY(pointerIndex) - prevY) * sensitivityFactor;
}

prevX = e.getX(pointerIndex);
prevY = e.getY(pointerIndex);

CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
break;

case MotionEvent.ACTION_DOWN: // 0
Expand All @@ -287,20 +284,20 @@ public boolean onTouchEvent(MotionEvent e) {
}

theHandler.sendEmptyMessageDelayed(MSG_DROP_ITEM_BUTTON_CHECK, 350);
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
lastHotbarKey = hudKeyHandled;
break;
}

CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
prevX = e.getX();
prevY = e.getY();

if (CallbackBridge.isGrabbing()) {
currentPointerID = e.getPointerId(0);
// It cause hold left mouse while moving camera
initialX = mouse_x;
initialY = mouse_y;
initialX = CallbackBridge.mouseX;
initialY = CallbackBridge.mouseY;
theHandler.sendEmptyMessageDelayed(MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
}
lastHotbarKey = hudKeyHandled;
Expand Down Expand Up @@ -333,7 +330,7 @@ public boolean onTouchEvent(MotionEvent e) {

// In case of a short click, just send a quick right click
if(!LauncherPreferences.PREF_DISABLE_GESTURES &&
MathUtils.dist(initialX, initialY, mouse_x, mouse_y) < FINGER_STILL_THRESHOLD){
MathUtils.dist(initialX, initialY, CallbackBridge.mouseX, CallbackBridge.mouseY) < FINGER_STILL_THRESHOLD){
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
}
Expand Down Expand Up @@ -400,9 +397,9 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
}
switch(event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_MOVE:
mouse_x = (event.getX(mouseCursorIndex) * scaleFactor);
mouse_y = (event.getY(mouseCursorIndex) * scaleFactor);
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * scaleFactor);
CallbackBridge.mouseY = (event.getY(mouseCursorIndex) * scaleFactor);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
//debugText.setText(CallbackBridge.DEBUG_STRING.toString());
CallbackBridge.DEBUG_STRING.setLength(0);
return true;
Expand All @@ -424,10 +421,8 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
@RequiresApi(26)
@Override
public boolean dispatchCapturedPointerEvent(MotionEvent e) {
mouse_x += (e.getX()*scaleFactor);
mouse_y += (e.getY()*scaleFactor);
CallbackBridge.mouseX = mouse_x;
CallbackBridge.mouseY = mouse_y;
CallbackBridge.mouseX += (e.getX()*scaleFactor);
CallbackBridge.mouseY += (e.getY()*scaleFactor);
if(!CallbackBridge.isGrabbing()){
releasePointerCapture();
clearFocus();
Expand All @@ -445,8 +440,8 @@ public boolean dispatchCapturedPointerEvent(MotionEvent e) {
builder.append("RawX=").append(e.getRawX()).append("\n");
builder.append("RawY=").append(e.getRawY()).append("\n\n");

builder.append("XPos=").append(mouse_x).append("\n");
builder.append("YPos=").append(mouse_y).append("\n\n");
builder.append("XPos=").append(CallbackBridge.mouseX).append("\n");
builder.append("YPos=").append(CallbackBridge.mouseY).append("\n\n");
builder.append("MovingX=").append(getMoving(e.getX(), true)).append("\n");
builder.append("MovingY=").append(getMoving(e.getY(), false)).append("\n");
} catch (Throwable th) {
Expand All @@ -462,7 +457,7 @@ public boolean dispatchCapturedPointerEvent(MotionEvent e) {
CallbackBridge.DEBUG_STRING.setLength(0);
switch (e.getActionMasked()) {
case MotionEvent.ACTION_MOVE:
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
return true;
case MotionEvent.ACTION_BUTTON_PRESS:
return sendMouseButtonUnconverted(e.getActionButton(), true);
Expand Down
18 changes: 7 additions & 11 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Touchpad.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
public class Touchpad extends FrameLayout {
/* Whether the Touchpad should be displayed */
private boolean displayState;

/* Mouse pointer icon used by the touchpad */
private final ImageView mousePointer = new ImageView(getContext());
/* Detect a classic android Tap */
private final GestureDetector singleTapDetector = new GestureDetector(getContext(), new SingleTapConfirm());
/* Mc mouse position, scaled by the scaleFactor */
float mouse_x, mouse_y;
/* Resolution scaler option, allow downsizing a window */
private final float scaleFactor = DEFAULT_PREF.getInt("resolutionRatio",100)/100f;
/* Current pointer ID to move the mouse */
Expand All @@ -51,7 +48,6 @@ public Touchpad(@NonNull Context context) {
public Touchpad(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();

}

private void init(){
Expand Down Expand Up @@ -122,9 +118,9 @@ public boolean onTouchEvent(MotionEvent event) {
float mouseY = mousePointer.getY();

if (singleTapDetector.onTouchEvent(event)) {
mouse_x = (mouseX * scaleFactor);
mouse_y = (mouseY * scaleFactor);
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.mouseX = (mouseX * scaleFactor);
CallbackBridge.mouseY = (mouseY * scaleFactor);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT);

return true;
Expand Down Expand Up @@ -162,7 +158,7 @@ public boolean onTouchEvent(MotionEvent event) {
mouseY = Math.max(0, Math.min(currentDisplayMetrics.heightPixels, mouseY + (y - prevY) * LauncherPreferences.PREF_MOUSESPEED));

placeMouseAt(mouseX, mouseY);
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
}else currentPointerID = event.getPointerId(0);

prevX = x;
Expand All @@ -186,9 +182,9 @@ public boolean onTouchEvent(MotionEvent event) {
public void placeMouseAt(float x, float y) {
mousePointer.setX(x);
mousePointer.setY(y);
mouse_x = (x * scaleFactor);
mouse_y = (y * scaleFactor);
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
CallbackBridge.mouseX = (x * scaleFactor);
CallbackBridge.mouseY = (y * scaleFactor);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
}

}
Loading

0 comments on commit b85dd16

Please sign in to comment.