diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 4b3d0a6704..5deed5972f 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -28,13 +28,13 @@ jobs: - name: Upload modules release output if: ${{matrix.arch == 'arm64'}} # Only upload this once - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: lwjgl3-android-modules path: bin/RELEASE - name: Upload native build output - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: lwjgl3-android-natives-${{matrix.arch}} path: bin/out diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index a71a03e41f..681ca329c9 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -24,13 +24,13 @@ jobs: bash ci_build_ios.bash - name: Upload modules release output - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: lwjgl3-ios-modules path: bin/RELEASE - name: Upload native build output - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: lwjgl3-ios-natives path: bin/out diff --git a/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/input/GLFWInputImplementation.java b/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/input/GLFWInputImplementation.java index 49bce344f3..1cbc584906 100644 --- a/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/input/GLFWInputImplementation.java +++ b/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/input/GLFWInputImplementation.java @@ -16,14 +16,10 @@ public class GLFWInputImplementation implements InputImplementation { private final ByteBuffer keyboardEvent = ByteBuffer.allocate(Keyboard.EVENT_SIZE); public final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; public final byte[] mouse_buffer = new byte[3]; - public int mouseX = 0; - public int mouseY = 0; - public int mouseLastEventX = 0; - public int mouseLastEventY = 0; + public int mouseX = 0, lastPhysicalX = 0; + public int mouseY = 0, lastPhysicalY = 0; public int mouseLastX = 0; public int mouseLastY = 0; - public int mouseComparatorX; - public int mouseComparatorY; public boolean grab; private long last_event_nanos = System.nanoTime(); @Override @@ -140,23 +136,27 @@ public boolean isInsideWindow() { return true; } - public void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { - int acoord1=0; - int acoord2=0; - if(coord1 == -1 && coord2 == -1) { - acoord1 = mouseX; - acoord2 = mouseY; - }else{ - acoord1 = coord1; - acoord2= coord2; + public void putMouseEventWithCoords(byte button, byte state, int px, int py, int dz, long nanos) { + if(px == -1 && py == -1) { + px = lastPhysicalX; + py = lastPhysicalY; } event_buffer.clear(); event_buffer.put(button).put(state); //always put deltas when grabbed if (grab) { - event_buffer.putInt(acoord1-mouseX).putInt(acoord2-mouseY); + int dx = px - lastPhysicalX; + // The coordinate from GLFW is inverted relative to LWJGL2's input, so + // invert the delta here for more consitency between resolution changes + int dy = (py - lastPhysicalY) * -1; + mouseX += dx; + mouseY += dy; + event_buffer.putInt(dx).putInt(dy); }else{ - event_buffer.putInt(acoord1).putInt(acoord2); + mouseX = px; + // If not grabbing, invert absolute coordinate in the window's coordinate space + mouseY = (int)((py - Display.getHeight())*-1); + event_buffer.putInt(mouseX).putInt(mouseY); } if(button != -1) { mouse_buffer[button]=state; @@ -165,8 +165,8 @@ public void putMouseEventWithCoords(byte button, byte state, int coord1, int coo event_buffer.flip(); event_queue.putEvent(event_buffer); last_event_nanos = nanos; - mouseX = acoord1; - mouseY = acoord2; + lastPhysicalX = px; + lastPhysicalY = py; } public void setMouseButtonInGrabMode(byte button, byte state) { diff --git a/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/opengl/Display.java b/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/opengl/Display.java index 36eefc73c3..122af2c8ca 100644 --- a/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/opengl/Display.java +++ b/modules/lwjgl/lwjglx/src/main/java/org/lwjgl/opengl/Display.java @@ -305,7 +305,7 @@ public void invoke(long window, boolean entered) { Window.cursorPosCallback = new GLFWCursorPosCallback() { @Override public void invoke(long window, double xpos, double ypos) { - GLFWInputImplementation.singleton.putMouseEventWithCoords((byte)-1, (byte)0,(int)xpos,(int)((ypos - Display.getHeight())*-1),0,Sys.getNanoTime()); + GLFWInputImplementation.singleton.putMouseEventWithCoords((byte)-1, (byte)0,(int)xpos,(int)ypos,0,Sys.getNanoTime()); } };