mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 22:45:50 +00:00
Added Mouse.setCursorPosition(x, y)
This commit is contained in:
parent
f3d3ce7ce5
commit
61ddd625df
6 changed files with 42 additions and 4 deletions
|
|
@ -152,10 +152,6 @@ public class Mouse {
|
|||
*
|
||||
* NOTE: The native cursor is not constrained to the window, but
|
||||
* relative events will not be generated if the cursor is outside.
|
||||
* The initial position of the cursor is the middle of the window,
|
||||
* that is, {window_width/2, window_height/2}.
|
||||
* The cursor will be moved to this origin when a
|
||||
* native cursor is set and the previous cursor is null.
|
||||
*
|
||||
* @param cursor the native cursor object to bind. May be null.
|
||||
* @return The previous Cursor object set, or null.
|
||||
|
|
@ -177,6 +173,21 @@ public class Mouse {
|
|||
return oldCursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of the native cursor. This method is only valid when
|
||||
* the cursor is not grabbed and native cursors are supported.
|
||||
*
|
||||
* @param x The x coordinate of the new cursor position in OpenGL coordinates relative
|
||||
* to the window origin.
|
||||
* @param y The y coordinate of the new cursor position in OpenGL coordinates relative
|
||||
* to the window origin.
|
||||
*/
|
||||
public static void setCursorPosition(int x, int y) {
|
||||
if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0)
|
||||
throw new IllegalStateException("Mouse doesn't support native cursors");
|
||||
Display.getImplementation().setCursorPosition(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
|
|
@ -200,6 +211,7 @@ public class Mouse {
|
|||
x = width / 2;
|
||||
y = height / 2;
|
||||
readBuffer.clear();
|
||||
setCursorPosition(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ public interface DisplayImplementation {
|
|||
*/
|
||||
int getNativeCursorCapabilities();
|
||||
|
||||
/** Method to set the native cursor position */
|
||||
void setCursorPosition(int x, int y);
|
||||
|
||||
/** Method to set the native cursor */
|
||||
void setNativeCursor(Object handle) throws LWJGLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -268,6 +268,13 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
private static native int nReadMouse(IntBuffer buffer, int buffer_position);
|
||||
|
||||
public void setCursorPosition(int x, int y) {
|
||||
lockAWT();
|
||||
nSetCursorPosition(x, y);
|
||||
unlockAWT();
|
||||
}
|
||||
private native void nSetCursorPosition(int x, int y);
|
||||
|
||||
public void grabMouse(boolean grab) {
|
||||
lockAWT();
|
||||
nGrabMouse(grab);
|
||||
|
|
|
|||
|
|
@ -306,6 +306,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void setCursorPosition(int x, int y) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setNativeCursor(Object handle) throws LWJGLException {
|
||||
Cursor awt_cursor = (Cursor)handle;
|
||||
frame.setCursor(awt_cursor);
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ final class Win32Display implements DisplayImplementation {
|
|||
return Cursor.CURSOR_ONE_BIT_TRANSPARENCY;
|
||||
}
|
||||
|
||||
public native void setCursorPosition(int x, int y);
|
||||
public native void setNativeCursor(Object handle) throws LWJGLException;
|
||||
public native int getMinCursorSize();
|
||||
public native int getMaxCursorSize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue