diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4feeeedc3..364b65943 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,11 +25,13 @@ 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: @@ -37,14 +39,14 @@ jobs: 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 @@ -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 .. @@ -66,11 +68,13 @@ 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: @@ -78,21 +82,21 @@ jobs: 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 .. diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java index 7026b52ec..b05ba9cfb 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java @@ -2,6 +2,7 @@ package net.kdt.pojavlaunch; 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; @@ -153,6 +154,10 @@ public class BaseMainActivity extends BaseActivity { 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); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLView.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLView.java index a45d6b135..ddcc65c13 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLView.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLView.java @@ -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 */ @@ -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 */ @@ -208,11 +205,11 @@ public class MinecraftGLView extends TextureView { //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; } } @@ -229,7 +226,7 @@ public class MinecraftGLView extends TextureView { // Touch hover if(pointerCount == 1){ - CallbackBridge.sendCursorPos(mouse_x, mouse_y); + CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY); prevX = e.getX(); prevY = e.getY(); break; @@ -264,14 +261,14 @@ public class MinecraftGLView extends TextureView { } // 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 @@ -287,20 +284,20 @@ public class MinecraftGLView extends TextureView { } 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; @@ -333,7 +330,7 @@ public class MinecraftGLView extends TextureView { // 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); } @@ -400,9 +397,9 @@ public class MinecraftGLView extends TextureView { } 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; @@ -424,10 +421,8 @@ public class MinecraftGLView extends TextureView { @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(); @@ -445,8 +440,8 @@ public class MinecraftGLView extends TextureView { 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) { @@ -462,7 +457,7 @@ public class MinecraftGLView extends TextureView { 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); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Touchpad.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Touchpad.java index bbd5d7fa9..348388bd7 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Touchpad.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Touchpad.java @@ -28,13 +28,10 @@ import org.lwjgl.glfw.CallbackBridge; 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 */ @@ -51,7 +48,6 @@ public class Touchpad extends FrameLayout { public Touchpad(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(); - } private void init(){ @@ -122,9 +118,9 @@ public class Touchpad extends FrameLayout { 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; @@ -162,7 +158,7 @@ public class Touchpad extends FrameLayout { 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; @@ -186,9 +182,9 @@ public class Touchpad extends FrameLayout { 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); } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/Gamepad.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/Gamepad.java index 7988680f1..81db7f57f 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/Gamepad.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/Gamepad.java @@ -2,9 +2,6 @@ package net.kdt.pojavlaunch.customcontrols.gamepad; import android.content.Context; -import android.os.Handler; -import android.os.Looper; -import android.util.Log; import android.view.Choreographer; import android.view.InputDevice; import android.view.KeyEvent; @@ -18,11 +15,10 @@ import android.widget.Toast; import androidx.core.content.res.ResourcesCompat; import androidx.core.math.MathUtils; -import net.kdt.pojavlaunch.BaseMainActivity; import net.kdt.pojavlaunch.LWJGLGLFWKeycode; -import net.kdt.pojavlaunch.MainActivity; import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.prefs.LauncherPreferences; +import net.kdt.pojavlaunch.utils.MCOptionUtils; import org.lwjgl.glfw.CallbackBridge; @@ -72,12 +68,17 @@ public class Gamepad { private GamepadMap currentMap = gameMap; private boolean lastGrabbingState = true; - private final boolean mModifierDigitalTriggers; + //private final boolean mModifierDigitalTriggers; + private final boolean mModifierAnalogTriggers; private boolean mModifierSwappedAxis = true; //Triggers and right stick axis are swapped. + /* Choreographer with time to compute delta on ticking */ private final Choreographer screenChoreographer; private long lastFrameTime; + /* Listen for change in gui scale */ + private MCOptionUtils.MCOptionListener GUIScaleListener = () -> notifyGUISizeChange(getMcScale()); + public Gamepad(View contextView, InputDevice inputDevice){ screenChoreographer = Choreographer.getInstance(); Choreographer.FrameCallback frameCallback = new Choreographer.FrameCallback() { @@ -91,6 +92,9 @@ public class Gamepad { screenChoreographer.postFrameCallback(frameCallback); lastFrameTime = System.nanoTime(); + /* Add the listener for the cross hair */ + MCOptionUtils.addMCOptionListener(GUIScaleListener); + Toast.makeText(contextView.getContext(),"GAMEPAD CREATED", Toast.LENGTH_LONG).show(); for(InputDevice.MotionRange range : inputDevice.getMotionRanges()){ if(range.getAxis() == MotionEvent.AXIS_RTRIGGER @@ -108,7 +112,8 @@ public class Gamepad { else rightJoystick = new GamepadJoystick(MotionEvent.AXIS_RX, MotionEvent.AXIS_RY, inputDevice); - mModifierDigitalTriggers = inputDevice.hasKeys(KeyEvent.KEYCODE_BUTTON_R2)[0]; + //mModifierDigitalTriggers = inputDevice.hasKeys(KeyEvent.KEYCODE_BUTTON_R2)[0]; + mModifierAnalogTriggers = supportAnalogTriggers(inputDevice); Context ctx = contextView.getContext(); pointerView = new ImageView(contextView.getContext()); @@ -126,7 +131,10 @@ public class Gamepad { ((ViewGroup)contextView.getParent()).addView(pointerView); } - + /** + * Send the new mouse position, computing the delta + * @param frameTimeNanos The time to render the frame, used to compute mouse delta + */ public void tick(long frameTimeNanos){ //update mouse position if(lastHorizontalValue != 0 || lastVerticalValue != 0){ @@ -239,7 +247,7 @@ public class Gamepad { } private void updateAnalogTriggers(MotionEvent event){ - if(!mModifierDigitalTriggers){ + if(mModifierAnalogTriggers){ getCurrentMap().TRIGGER_LEFT.update( (event.getAxisValue(MotionEvent.AXIS_LTRIGGER) > 0.5) || (event.getAxisValue(MotionEvent.AXIS_BRAKE) > 0.5) @@ -258,6 +266,25 @@ public class Gamepad { } + /** + * Detect if a gamepad supports analog triggers + * @param inputDevice The input device with all the MotionRange + * @return Whether the gamepad supports analog triggers + */ + private boolean supportAnalogTriggers(InputDevice inputDevice){ + for(InputDevice.MotionRange motionRange : inputDevice.getMotionRanges()){ + int axis = motionRange.getAxis(); + + if( axis == MotionEvent.AXIS_BRAKE || axis == MotionEvent.AXIS_GAS || + axis == MotionEvent.AXIS_LTRIGGER || axis == MotionEvent.AXIS_RTRIGGER || + (mModifierSwappedAxis && axis == MotionEvent.AXIS_Z) || + (mModifierSwappedAxis && axis == MotionEvent.AXIS_RZ)){ + return true; + } + } + return false; + } + private GamepadMap getCurrentMap(){ return currentMap; } @@ -330,9 +357,11 @@ public class Gamepad { //Triggers case KeyEvent.KEYCODE_BUTTON_L2: + if(mModifierAnalogTriggers) break; getCurrentMap().TRIGGER_LEFT.update(isDown); break; case KeyEvent.KEYCODE_BUTTON_R2: + if(mModifierAnalogTriggers) break; getCurrentMap().TRIGGER_RIGHT.update(isDown); break; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/ControlOffsetPreference.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/ControlOffsetPreference.java index c11c569eb..3d07fb242 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/ControlOffsetPreference.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/ControlOffsetPreference.java @@ -76,22 +76,22 @@ public class ControlOffsetPreference extends Preference { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if(seekBar == topOffsetSeekbar){ - String text = String.format("%s%d", getContext().getString(R.string.control_top_offset), i); + String text = String.format("%s %d%s", getContext().getString(R.string.control_top_offset), i, " px"); topOffsetTextView.setText(text); return; } if(seekBar == rightOffsetSeekbar){ - String text = String.format("%s%d", getContext().getString(R.string.control_right_offset), i); + String text = String.format("%s %d%s", getContext().getString(R.string.control_right_offset), i, " px"); rightOffsetTextView.setText(text); return; } if(seekBar == bottomOffsetSeekbar){ - String text = String.format("%s%d", getContext().getString(R.string.control_bottom_offset), i); + String text = String.format("%s %d%s", getContext().getString(R.string.control_bottom_offset), i, " px"); bottomOffsetTextView.setText(text); return; } if(seekBar == leftOffsetSeekbar){ - String text = String.format("%s%d", getContext().getString(R.string.control_left_offset), i); + String text = String.format("%s %d%s", getContext().getString(R.string.control_left_offset), i, " px"); leftOffsetTextView.setText(text); return; } @@ -112,6 +112,11 @@ public class ControlOffsetPreference extends Preference { bottomOffsetSeekbar.setProgress(PREF_CONTROL_BOTTOM_OFFSET); leftOffsetSeekbar.setProgress(PREF_CONTROL_LEFT_OFFSET); + seekBarChangeListener.onProgressChanged(topOffsetSeekbar, PREF_CONTROL_TOP_OFFSET, false); + seekBarChangeListener.onProgressChanged(rightOffsetSeekbar, PREF_CONTROL_RIGHT_OFFSET, false); + seekBarChangeListener.onProgressChanged(bottomOffsetSeekbar, PREF_CONTROL_BOTTOM_OFFSET, false); + seekBarChangeListener.onProgressChanged(leftOffsetSeekbar, PREF_CONTROL_LEFT_OFFSET, false); + // Custom writing to preferences preferenceDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> { DEFAULT_PREF.edit().putInt("controlTopOffset", topOffsetSeekbar.getProgress()).apply(); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/LauncherPreferences.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/LauncherPreferences.java index 38c524040..aff6d5e4b 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/LauncherPreferences.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/LauncherPreferences.java @@ -37,6 +37,8 @@ public class LauncherPreferences public static boolean PREF_ENABLE_PROFILES = true; public static String PREF_GLES_SHRINK_HACK = "0"; public static boolean PREF_VBO_DISABLE_HACK = false; + public static boolean PREF_VIRTUAL_MOUSE_START = false; + public static boolean PREF_OPENGL_VERSION_HACK = false; public static void loadPreferences(Context ctx) { @@ -69,6 +71,8 @@ public class LauncherPreferences PREF_GLES_SHRINK_HACK = DEFAULT_PREF.getString("gl4es_shrink_hack", "0"); PREF_VBO_DISABLE_HACK = DEFAULT_PREF.getBoolean("vbo_disable_hack", false); PREF_ENABLE_PROFILES = DEFAULT_PREF.getBoolean("enable_profiles", false); + PREF_VIRTUAL_MOUSE_START = DEFAULT_PREF.getBoolean("mouse_start", false); + PREF_OPENGL_VERSION_HACK = DEFAULT_PREF.getBoolean("gles_version_hack", false); /* if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) { diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java index 94e17f22f..1e1dfcf7c 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java @@ -5,6 +5,7 @@ import static net.kdt.pojavlaunch.Architecture.archAsString; import static net.kdt.pojavlaunch.Architecture.is64BitsDevice; import static net.kdt.pojavlaunch.Tools.LOCAL_RENDERER; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GLES_SHRINK_HACK; +import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_OPENGL_VERSION_HACK; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_VBO_DISABLE_HACK; import android.app.*; @@ -210,11 +211,17 @@ public class JREUtils { envMap.put("TMPDIR", activity.getCacheDir().getAbsolutePath()); envMap.put("LIBGL_MIPMAP", "3"); + // On certain GLES drivers, overloading default functions shader hack fails, so disable it + envMap.put("LIBGL_NOINTOVLHACK", "1"); + // The shrink hack can be enabled from the experimental settings envMap.put("LIBGL_SHRINK", PREF_GLES_SHRINK_HACK); // VBO disable hack - if(PREF_VBO_DISABLE_HACK) envMap.put("LIBGL_USEVBO","0"); + if (PREF_VBO_DISABLE_HACK) envMap.put("LIBGL_USEVBO","0"); + + // openGL version hack + if (PREF_OPENGL_VERSION_HACK) envMap.put("LIBGL_ES", "1"); // Fix white color on banner and sheep, since GL4ES 1.1.5 envMap.put("LIBGL_NORMALIZE", "1"); @@ -396,20 +403,32 @@ public class JREUtils { ArrayList parsedArguments = new ArrayList<>(0); args = args.trim().replace(" ", ""); //For each prefixes, we separate args. - for(String prefix : new String[]{"-XX:-","-XX:+", "-XX:","-"}){ + for(String prefix : new String[]{"-XX:-","-XX:+", "-XX:","--","-"}){ while (true){ int start = args.indexOf(prefix); if(start == -1) break; //Get the end of the current argument int end = args.indexOf("-", start + prefix.length()); if(end == -1) end = args.length(); + //Extract it String parsedSubString = args.substring(start, end); args = args.replace(parsedSubString, ""); //Check if two args aren't bundled together by mistake - if(parsedSubString.indexOf('=') == parsedSubString.lastIndexOf('=')) + if(parsedSubString.indexOf('=') == parsedSubString.lastIndexOf('=')) { + int arraySize = parsedArguments.size(); + if(arraySize > 0){ + String lastString = parsedArguments.get(arraySize - 1); + // Looking for list elements + if(lastString.charAt(lastString.length() - 1) == ',' || + parsedSubString.contains(",")){ + parsedArguments.set(arraySize - 1, lastString + parsedSubString); + continue; + } + } parsedArguments.add(parsedSubString); + } else Log.w("JAVA ARGS PARSER", "Removed improper arguments: " + parsedSubString); } } diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml index 01b0482e1..9a1bd9f70 100644 --- a/app_pojavlauncher/src/main/res/values/strings.xml +++ b/app_pojavlauncher/src/main/res/values/strings.xml @@ -265,6 +265,8 @@ Control side offsets Set a custom offset to each side of the screen + Start with virtual mouse on + Using this option will get you judged by Mathias-Boulay Video and renderer Resolution, scaling type, and renderer Control customization @@ -296,4 +298,6 @@ Delete Java Runtime Renderer + Force openGL 1 + Help with compatibility on some old versions diff --git a/app_pojavlauncher/src/main/res/xml/pref_control.xml b/app_pojavlauncher/src/main/res/xml/pref_control.xml index b896c67ac..982daf915 100644 --- a/app_pojavlauncher/src/main/res/xml/pref_control.xml +++ b/app_pojavlauncher/src/main/res/xml/pref_control.xml @@ -60,6 +60,12 @@ app2:selectable="false" app2:seekBarIncrement="5" app2:showSeekBarValue="true" /> + + diff --git a/app_pojavlauncher/src/main/res/xml/pref_experimental.xml b/app_pojavlauncher/src/main/res/xml/pref_experimental.xml index b4286bc49..cc2326d90 100644 --- a/app_pojavlauncher/src/main/res/xml/pref_experimental.xml +++ b/app_pojavlauncher/src/main/res/xml/pref_experimental.xml @@ -24,5 +24,12 @@ android:title="@string/option_enable_profiles" android:summary="@string/option_enable_profiles_descritption"/> + + \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLException.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLException.java new file mode 100644 index 000000000..79ef96bcd --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLException.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl; + +/** + *

+ * This exception is supplied to make exception handling more generic for LWJGL + * specific exceptions + *

+ * + * @author Brian Matzon + * @version $Revision$ + * $Id$ + */ +public class LWJGLException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Plain c'tor + */ + public LWJGLException() { + super(); + } + + /** + * Creates a new LWJGLException + * + * @param msg + * String identifier for exception + */ + public LWJGLException(String msg) { + super(msg); + } + + /** + * @param message + * @param cause + */ + public LWJGLException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param cause + */ + public LWJGLException(Throwable cause) { + super(cause); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java index aa9a9361a..702fa1155 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java @@ -817,17 +817,17 @@ public class GLFW isGLFWReady = invokeI(__functionAddress) != 0; } return isGLFWReady; - } + } - public static void glfwTerminate() { + public static void glfwTerminate() { mGLFWIsInputReady = false; CallbackBridge.nativeSetInputReady(false); long __functionAddress = Functions.Terminate; invokeV(__functionAddress); - } + } - public static void glfwInitHint(int hint, int value) { } + public static void glfwInitHint(int hint, int value) { } @NativeType("GLFWwindow *") public static long glfwGetCurrentContext() { @@ -835,27 +835,16 @@ public class GLFW return invokeP(__functionAddress); } - public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) { + public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) { if (CHECKS) { checkSafe(width, 1); checkSafe(height, 1); } width.put(internalGetWindow(window).width); height.put(internalGetWindow(window).height); - } - - public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { - if (CHECKS) { - // check(window); - checkSafe(width, 1); - checkSafe(height, 1); - } - - width[0] = internalGetWindow(window).width; - height[0] = internalGetWindow(window).height; } - @Nullable + @Nullable @NativeType("GLFWmonitor **") public static PointerBuffer glfwGetMonitors() { PointerBuffer pBuffer = PointerBuffer.allocateDirect(1); @@ -892,33 +881,6 @@ public class GLFW height.put(mGLFWWindowHeight); } - public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) { - if (CHECKS) { - // check(monitor); - checkSafe(xpos, 1); - checkSafe(ypos, 1); - } - - xpos[0] = 0; - ypos[0] = 0; - } - - /** Array version of: {@link #glfwGetMonitorWorkarea GetMonitorWorkarea} */ - public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { - if (CHECKS) { - // check(monitor); - checkSafe(xpos, 1); - checkSafe(ypos, 1); - checkSafe(width, 1); - checkSafe(height, 1); - } - - xpos[0] = 0; - ypos[0] = 0; - width[0] = mGLFWWindowWidth; - height[0] = mGLFWWindowHeight; - } - @NativeType("GLFWmonitor *") public static long glfwGetWindowMonitor(@NativeType("GLFWwindow *") long window) { return mGLFWWindowMonitor; @@ -1328,4 +1290,140 @@ return false; public static boolean glfwGetGamepadState(int jid, GLFWGamepadState state) { return false; } + + /** Array version of: {@link #glfwGetVersion GetVersion} */ + public static void glfwGetVersion(@Nullable @NativeType("int *") int[] major, @Nullable @NativeType("int *") int[] minor, @Nullable @NativeType("int *") int[] rev) { + if (CHECKS) { + checkSafe(major, 1); + checkSafe(minor, 1); + checkSafe(rev, 1); + } + major[0] = GLFW_VERSION_MAJOR; + minor[0] = GLFW_VERSION_MINOR; + rev[0] = GLFW_VERSION_REVISION; + } + + /** Array version of: {@link #glfwGetMonitorPos GetMonitorPos} */ + public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) { + if (CHECKS) { + // check(monitor); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + xpos[0] = 0; + ypos[0] = 0; + } + + /** Array version of: {@link #glfwGetMonitorWorkarea GetMonitorWorkarea} */ + public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { + if (CHECKS) { + // check(monitor); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + checkSafe(width, 1); + checkSafe(height, 1); + } + + xpos[0] = 0; + ypos[0] = 0; + width[0] = mGLFWWindowWidth; + height[0] = mGLFWWindowHeight; + } + + /** Array version of: {@link #glfwGetMonitorPhysicalSize GetMonitorPhysicalSize} */ +/* + public static void glfwGetMonitorPhysicalSize(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] widthMM, @Nullable @NativeType("int *") int[] heightMM) { + long __functionAddress = Functions.GetMonitorPhysicalSize; + if (CHECKS) { + // check(monitor); + checkSafe(widthMM, 1); + checkSafe(heightMM, 1); + } + invokePPPV(monitor, widthMM, heightMM, __functionAddress); + } +*/ + + /** Array version of: {@link #glfwGetMonitorContentScale GetMonitorContentScale} */ +/* + public static void glfwGetMonitorContentScale(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("float *") float[] xscale, @Nullable @NativeType("float *") float[] yscale) { + long __functionAddress = Functions.GetMonitorContentScale; + if (CHECKS) { + // check(monitor); + checkSafe(xscale, 1); + checkSafe(yscale, 1); + } + invokePPPV(monitor, xscale, yscale, __functionAddress); + } +*/ + + /** Array version of: {@link #glfwGetWindowPos GetWindowPos} */ + public static void glfwGetWindowPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) { + if (CHECKS) { + // check(window); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + xpos[0] = 0; + ypos[0] = 0; + } + + /** Array version of: {@link #glfwGetWindowSize GetWindowSize} */ + public static void glfwGetWindowSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { + if (CHECKS) { + // check(window); + checkSafe(width, 1); + checkSafe(height, 1); + } + width[0] = internalGetWindow(window).width; + height[0] = internalGetWindow(window).height; + } + + /** Array version of: {@link #glfwGetFramebufferSize GetFramebufferSize} */ + public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { + if (CHECKS) { + // check(window); + checkSafe(width, 1); + checkSafe(height, 1); + } + width[0] = internalGetWindow(window).width; + height[0] = internalGetWindow(window).height; + } + + /** Array version of: {@link #glfwGetWindowFrameSize GetWindowFrameSize} */ + public static void glfwGetWindowFrameSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] left, @Nullable @NativeType("int *") int[] top, @Nullable @NativeType("int *") int[] right, @Nullable @NativeType("int *") int[] bottom) { + if (CHECKS) { + // check(window); + checkSafe(left, 1); + checkSafe(top, 1); + checkSafe(right, 1); + checkSafe(bottom, 1); + } + left[0] = top[0] = 0; + right[0] = internalGetWindow(window).width; + bottom[0] = internalGetWindow(window).height; + } + + /** Array version of: {@link #glfwGetWindowContentScale GetWindowContentScale} */ +/* + public static void glfwGetWindowContentScale(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("float *") float[] xscale, @Nullable @NativeType("float *") float[] yscale) { + long __functionAddress = Functions.GetWindowContentScale; + if (CHECKS) { + // check(window); + checkSafe(xscale, 1); + checkSafe(yscale, 1); + } + invokePPPV(window, xscale, yscale, __functionAddress); + } +*/ + + /** Array version of: {@link #glfwGetCursorPos GetCursorPos} */ + public static void glfwGetCursorPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("double *") double[] xpos, @Nullable @NativeType("double *") double[] ypos) { + if (CHECKS) { + // check(window); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + xpos[0] = mGLFWCursorX; + ypos[0] = mGLFWCursorY; + } }