diff --git a/src/java/org/lwjgl/input/Cursor.java b/src/java/org/lwjgl/input/Cursor.java index 3d177197..9128bfe4 100644 --- a/src/java/org/lwjgl/input/Cursor.java +++ b/src/java/org/lwjgl/input/Cursor.java @@ -77,6 +77,7 @@ public class Cursor { if (!initialized) { initialize(); } + yHotspot = height - 1 - yHotspot; assert Mouse.isCreated(); assert width*height*numImages <= images.remaining(): "width*height*numImages > images.remaining()"; assert delays == null || numImages <= delays.remaining(): "delays != null && numImages > delays.remaining()"; @@ -84,7 +85,7 @@ public class Cursor { assert yHotspot < height && yHotspot >= 0: "yHotspot > height || yHotspot < 0"; IntBuffer images_copy = ByteBuffer.allocateDirect(images.remaining()*4).order(ByteOrder.nativeOrder()).asIntBuffer(); flipImages(width, height, numImages, images, images_copy); - nativeHandle = nCreateCursor(width, height, xHotspot, height - yHotspot, numImages, images_copy, 0, delays, delays != null ? delays.position() : 0); + nativeHandle = nCreateCursor(width, height, xHotspot, yHotspot, numImages, images_copy, 0, delays, delays != null ? delays.position() : 0); } private static void initialize() { diff --git a/src/native/linux/org_lwjgl_input_Mouse.cpp b/src/native/linux/org_lwjgl_input_Mouse.cpp index 26b4a976..f5638317 100644 --- a/src/native/linux/org_lwjgl_input_Mouse.cpp +++ b/src/native/linux/org_lwjgl_input_Mouse.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include "org_lwjgl_input_Mouse.h" #include "extxcursor.h" @@ -92,11 +91,14 @@ static void setCursorPos(int x, int y) { current_y = cap(y, 0, getWindowHeight() - 1); } -static void centerCursor() { +static void transformCursorPos(int x, int y) { // transform to OpenGL coordinate system center - int x = getWindowWidth()/2; - int y = (int)ceil(getWindowHeight()/2.0f); + y = getWindowHeight() - 1 - y; setCursorPos(x, y); +} + +static void centerCursor() { + transformCursorPos(getWindowWidth()/2, getWindowHeight()/2); last_x = current_x; last_y = current_y; } diff --git a/src/native/win32/org_lwjgl_input_Mouse.cpp b/src/native/win32/org_lwjgl_input_Mouse.cpp index 0de461a6..fe5e66db 100644 --- a/src/native/win32/org_lwjgl_input_Mouse.cpp +++ b/src/native/win32/org_lwjgl_input_Mouse.cpp @@ -41,7 +41,6 @@ #define WIN32_LEAN_AND_MEAN #include "org_lwjgl_input_Mouse.h" #include -#include #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0300 #include "Window.h" @@ -175,7 +174,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor GetWindowRect(hwnd, &windowRect); getScreenClientRect(&clientRect, &windowRect); cursorPos.x = (clientRect.left + clientRect.right)/2; - cursorPos.y = (int)ceil((clientRect.top + clientRect.bottom)/2.0f); + cursorPos.y = clientRect.bottom - 1 - (clientRect.bottom - clientRect.top)/2; SetCursorPos(cursorPos.x, cursorPos.y); ShowCursor(TRUE); usingNativeCursor = true;