Fix: issues with legacy versions
This picks up the following commits from Android repo: * https://github.com/PojavLauncherTeam/PojavLauncher/commit/4716e99df12ab 5bfcaade881774e3b07e8e35450: Don't call Display.create in AWTGLCanvas constructor (fixes Minecraft 1.2.1-1.2.4) * https://github.com/PojavLauncherTeam/PojavLauncher/commit/693cff45b09b3 ca09784a3038a3f9c89cacd391f: Infdev cursor grab: the Pojav part + Window resize on first key even poll (actual on iOS is on grab state changes because Android's approach does not work) * https://github.com/PojavLauncherTeam/PojavLauncher/commit/ee39334bf31ed 0687c750f37229cf6bea8919b4c (Comment out unnecessary calls to resize)
This commit is contained in:
1 parent
4c71a17a35
commit
fd436d9f88
7 files changed
+82
-7
No files matched your search
Binary file not shown.
@@ -509,8 +509,8 @@ public class GLFW
|
||||
}
|
||||
|
||||
// Minecraft triggers a glfwPollEvents() on splash screen, so update window size there.
|
||||
CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight, 0, 0);
|
||||
CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_WINDOW_SIZE, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight, 0, 0);
|
||||
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight, 0, 0);
|
||||
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_WINDOW_SIZE, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight, 0, 0);
|
||||
|
||||
mGLFWErrorCallback = GLFWErrorCallback.createPrint();
|
||||
mGLFWKeyCodes = new ArrayMap<>();
|
||||
|
||||
@@ -29,6 +29,9 @@ public class Cursor {
|
||||
/** Flag set when the cursor has been destroyed */
|
||||
private boolean destroyed;
|
||||
|
||||
/** Flag set if the cursor is empty */
|
||||
private boolean isEmpty;
|
||||
|
||||
/**
|
||||
* Constructs a new Cursor, with the given parameters. Mouse must have been
|
||||
* created before you can create Cursor objects. Cursor images are in ARGB
|
||||
@@ -59,14 +62,19 @@ public class Cursor {
|
||||
*/
|
||||
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays)
|
||||
throws LWJGLException {
|
||||
|
||||
cursors = new CursorElement[numImages];
|
||||
|
||||
IntBuffer flippedImages = BufferUtils.createIntBuffer(images.limit());
|
||||
flipImages(width, height, numImages, images, flippedImages);
|
||||
|
||||
ByteBuffer pixels = convertARGBIntBuffertoRGBAByteBuffer(width, height, flippedImages);
|
||||
|
||||
if(numImages == 1) {
|
||||
isEmpty = true;
|
||||
for(int i = 0; i < width*height; i++) if(pixels.get(i) != 0) {
|
||||
System.out.println("Encountered non-zero byte at "+i+", custom cursor is not empty!");
|
||||
isEmpty = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < numImages; i++) {
|
||||
int size = width * height;
|
||||
ByteBuffer image = BufferUtils.createByteBuffer(size);
|
||||
@@ -248,6 +256,14 @@ public class Cursor {
|
||||
index = ++index % cursors.length;
|
||||
}
|
||||
|
||||
/**
|
||||
/* Returns wheteher the cursor image is empty or not
|
||||
*/
|
||||
|
||||
/*package-private*/ boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* A single cursor element, used when animating
|
||||
*/
|
||||
@@ -266,5 +282,4 @@ public class Cursor {
|
||||
throw new RuntimeException("Error creating GLFW cursor");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.lwjgl.input;
|
||||
|
||||
import net.java.openjdk.cacio.ctc.ExternalMouseReader;
|
||||
import net.java.openjdk.cacio.ctc.InfdevGrabHandler;
|
||||
|
||||
public class InfdevMouse implements ExternalMouseReader, Mouse.EmptyCursorGrabListener {
|
||||
static {
|
||||
InfdevGrabHandler.setMouseReader(new InfdevMouse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return Mouse.getAbsoluteX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return Mouse.getAbsoluteY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGrab(boolean grabbing) {
|
||||
InfdevGrabHandler.setGrabbed(grabbing);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@
|
||||
*/
|
||||
package org.lwjgl.input;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.security.AccessController;
|
||||
@@ -144,6 +145,7 @@ public class Mouse {
|
||||
private static boolean isGrabbed;
|
||||
|
||||
private static InputImplementation implementation;
|
||||
private static EmptyCursorGrabListener grabListener = null;
|
||||
|
||||
/** Whether we need cursor animation emulation */
|
||||
private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS ||
|
||||
@@ -151,6 +153,16 @@ public class Mouse {
|
||||
|
||||
private static boolean clipMouseCoordinatesToWindow = !getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
|
||||
|
||||
static {
|
||||
try {
|
||||
Class infdevMouse = Class.forName("org.lwjgl.input.InfdevMouse");
|
||||
Constructor constructor = infdevMouse.getConstructor();
|
||||
grabListener = (EmptyCursorGrabListener) constructor.newInstance();
|
||||
}catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mouse cannot be constructed.
|
||||
*/
|
||||
@@ -164,7 +176,6 @@ public class Mouse {
|
||||
*/
|
||||
public static Cursor getNativeCursor() {
|
||||
return currentCursor;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +192,14 @@ public class Mouse {
|
||||
*/
|
||||
public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException {
|
||||
//dummy
|
||||
if(cursor == null && currentCursor.isEmpty()) {
|
||||
Mouse.setGrabbed(false);
|
||||
if(grabListener != null) grabListener.onGrab(false);
|
||||
}
|
||||
if(cursor != null && cursor.isEmpty()) {
|
||||
Mouse.setGrabbed(true);
|
||||
if(grabListener != null) grabListener.onGrab(true);
|
||||
}
|
||||
currentCursor = cursor;
|
||||
return currentCursor;
|
||||
}
|
||||
@@ -625,4 +644,18 @@ public class Mouse {
|
||||
public static boolean isInsideWindow() {
|
||||
return implementation.isInsideWindow();
|
||||
}
|
||||
|
||||
/*
|
||||
* Package private methods to get the absolute unclipped X/Y coordiates
|
||||
*/
|
||||
/*package-private*/ static int getAbsoluteX() {
|
||||
return absolute_x;
|
||||
}
|
||||
/*package-private*/ static int getAbsoluteY() {
|
||||
return absolute_y;
|
||||
}
|
||||
|
||||
interface EmptyCursorGrabListener {
|
||||
void onGrab(boolean grabbing);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,8 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener,
|
||||
}
|
||||
|
||||
public AWTGLCanvas() throws LWJGLException {
|
||||
Display.create();
|
||||
System.out.println("AWTGLCanvas constructor called on thread:"+Thread.currentThread().getName());
|
||||
//Display.create();
|
||||
}
|
||||
|
||||
public AWTGLCanvas(PixelFormat pixel_format) throws LWJGLException {
|
||||
|
||||
Reference in new issue
Block a user