From: <ka...@us...> - 2010-03-26 19:17:59
|
Revision: 3294 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3294&view=rev Author: kappa1 Date: 2010-03-26 19:17:53 +0000 (Fri, 26 Mar 2010) Log Message: ----------- Consistent mouse grab behaviour on all platforms. Mouse will now ungrab at the same place it was grabbed from. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-23 12:43:44 UTC (rev 3293) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-26 19:17:53 UTC (rev 3294) @@ -125,6 +125,9 @@ private static int event_x; private static int event_y; private static long event_nanos; + /** The position of the mouse it was grabbed at */ + private static int grab_x; + private static int grab_y; /** Buffer size in events */ private static final int BUFFER_SIZE = 50; @@ -611,15 +614,27 @@ */ public static void setGrabbed(boolean grab) { synchronized (OpenGLPackageAccess.global_lock) { - isGrabbed = grab; + if (isCreated()) { - implementation.grabMouse(isGrabbed); + if (grab && !isGrabbed) { + // store location mouse was grabbed + grab_x = x; + grab_y = y; + } + else if (!grab && isGrabbed) { + // move mouse back to location it was grabbed before ungrabbing + if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) + implementation.setCursorPosition(grab_x, grab_y); + } + + implementation.grabMouse(grab); // Get latest values from native side poll(); event_x = x; event_y = y; resetMouse(); } + isGrabbed = grab; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-03-26 19:52:47
|
Revision: 3295 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3295&view=rev Author: kappa1 Date: 2010-03-26 19:52:40 +0000 (Fri, 26 Mar 2010) Log Message: ----------- oops, windows mousegrab fixed Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-26 19:17:53 UTC (rev 3294) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-26 19:52:40 UTC (rev 3295) @@ -614,14 +614,15 @@ */ public static void setGrabbed(boolean grab) { synchronized (OpenGLPackageAccess.global_lock) { - + boolean grabbed = isGrabbed; + isGrabbed = grab; if (isCreated()) { - if (grab && !isGrabbed) { + if (grab && !grabbed) { // store location mouse was grabbed grab_x = x; grab_y = y; } - else if (!grab && isGrabbed) { + else if (!grab && grabbed) { // move mouse back to location it was grabbed before ungrabbing if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) implementation.setCursorPosition(grab_x, grab_y); @@ -634,7 +635,6 @@ event_y = y; resetMouse(); } - isGrabbed = grab; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-03-27 16:04:36
|
Revision: 3297 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3297&view=rev Author: kappa1 Date: 2010-03-27 16:04:30 +0000 (Sat, 27 Mar 2010) Log Message: ----------- Further improvement to mouse ungrab position behaviour. Mouse no longer limited to just ungrabbing at the position it was grabbed, now you can can call setCursorPosition(x,y) while mouse is grabbed and ungrab the mouse at any position you like. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-27 01:12:05 UTC (rev 3296) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-03-27 16:04:30 UTC (rev 3297) @@ -204,8 +204,13 @@ throw new IllegalStateException("Mouse is not created"); x = event_x = new_x; y = event_y = new_y; - if (!isGrabbed() && (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) + if (!isGrabbed() && (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) { implementation.setCursorPosition(x, y); + } + else { + grab_x = new_x; + grab_y = new_y; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-04-29 17:37:26
|
Revision: 3337 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3337&view=rev Author: matzon Date: 2010-04-29 17:37:18 +0000 (Thu, 29 Apr 2010) Log Message: ----------- yes, we really should... Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-04-26 21:52:59 UTC (rev 3336) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2010-04-29 17:37:18 UTC (rev 3337) @@ -467,7 +467,7 @@ } /** - * @return Current events delta x. Only valid when the mouse is grabbed. + * @return Current events delta x. */ public static int getEventDX() { synchronized (OpenGLPackageAccess.global_lock) { @@ -476,7 +476,7 @@ } /** - * @return Current events delta y. Only valid when the mouse is grabbed. + * @return Current events delta y. */ public static int getEventDY() { synchronized (OpenGLPackageAccess.global_lock) { @@ -485,7 +485,7 @@ } /** - * @return Current events absolute x. Only valid when the mouse is not grabbed. + * @return Current events absolute x. */ public static int getEventX() { synchronized (OpenGLPackageAccess.global_lock) { @@ -494,7 +494,7 @@ } /** - * @return Current events absolute y. Only valid when the mouse is not grabbed. + * @return Current events absolute y. */ public static int getEventY() { synchronized (OpenGLPackageAccess.global_lock) { @@ -550,7 +550,7 @@ } /** - * @return Movement on the x axis since last time getDX() was called. Only valid when the mouse is grabbed. + * @return Movement on the x axis since last time getDX() was called. */ public static int getDX() { synchronized (OpenGLPackageAccess.global_lock) { @@ -561,7 +561,7 @@ } /** - * @return Movement on the y axis since last time getDY() was called. Only valid when the mouse is grabbed. + * @return Movement on the y axis since last time getDY() was called. */ public static int getDY() { synchronized (OpenGLPackageAccess.global_lock) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2011-06-24 18:31:32
|
Revision: 3550 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3550&view=rev Author: matzon Date: 2011-06-24 18:31:26 +0000 (Fri, 24 Jun 2011) Log Message: ----------- Applying patch from Matthias that adds the "negative mouse coordinates" to Mouse.next() too Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-06-23 11:26:42 UTC (rev 3549) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-06-24 18:31:26 UTC (rev 3550) @@ -128,6 +128,9 @@ /** The position of the mouse it was grabbed at */ private static int grab_x; private static int grab_y; + /** The last absolute mouse event position (before clipping) for delta computation */ + private static int last_event_raw_x; + private static int last_event_raw_y; /** Buffer size in events */ private static final int BUFFER_SIZE = 50; @@ -140,7 +143,7 @@ private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS || LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX; - private static final boolean allowNegativeMouseCoords = getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords"); + private static boolean clipMouseCoordinatesToWindow = !getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords"); /** * Mouse cannot be constructed. @@ -189,6 +192,14 @@ } } + public static boolean isClipMouseCoordinatesToWindow() { + return clipMouseCoordinatesToWindow; + } + + public static void setClipMouseCoordinatesToWindow(boolean clip) { + clipMouseCoordinatesToWindow = clip; + } + /** * Set the position of the cursor. If the cursor is not grabbed, * the native cursor is moved to the new position. @@ -350,7 +361,7 @@ x = poll_coord1; y = poll_coord2; } - if(!allowNegativeMouseCoords) { + if(clipMouseCoordinatesToWindow) { x = Math.min(implementation.getWidth() - 1, Math.max(0, x)); y = Math.min(implementation.getHeight() - 1, Math.max(0, y)); } @@ -429,16 +440,22 @@ event_dy = readBuffer.getInt(); event_x += event_dx; event_y += event_dy; + last_event_raw_x = event_x; + last_event_raw_y = event_y; } else { int new_event_x = readBuffer.getInt(); int new_event_y = readBuffer.getInt(); - event_dx = new_event_x - event_x; - event_dy = new_event_y - event_y; + event_dx = new_event_x - last_event_raw_x; + event_dy = new_event_y - last_event_raw_y; event_x = new_event_x; event_y = new_event_y; + last_event_raw_x = new_event_x; + last_event_raw_y = new_event_y; } - event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); - event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); + if(clipMouseCoordinatesToWindow) { + event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); + event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); + } event_dwheel = readBuffer.getInt(); event_nanos = readBuffer.getLong(); return true; @@ -638,6 +655,8 @@ poll(); event_x = x; event_y = y; + last_event_raw_x = x; + last_event_raw_y = y; resetMouse(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-08-13 18:54:00
|
Revision: 3611 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3611&view=rev Author: kappa1 Date: 2011-08-13 18:53:54 +0000 (Sat, 13 Aug 2011) Log Message: ----------- Fix issue with Mouse getWidth/getHeight values being wrongly clipped when using Display.setParent(), thx to MatthiasM for finding this. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-08-13 17:20:59 UTC (rev 3610) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2011-08-13 18:53:54 UTC (rev 3611) @@ -362,8 +362,8 @@ y = poll_coord2; } if(clipMouseCoordinatesToWindow) { - x = Math.min(implementation.getWidth() - 1, Math.max(0, x)); - y = Math.min(implementation.getHeight() - 1, Math.max(0, y)); + x = Math.min(Display.getWidth() - 1, Math.max(0, x)); + y = Math.min(Display.getHeight() - 1, Math.max(0, y)); } dwheel += poll_dwheel; read(); @@ -453,8 +453,8 @@ last_event_raw_y = new_event_y; } if(clipMouseCoordinatesToWindow) { - event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); - event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); + event_x = Math.min(Display.getWidth() - 1, Math.max(0, event_x)); + event_y = Math.min(Display.getHeight() - 1, Math.max(0, event_y)); } event_dwheel = readBuffer.getInt(); event_nanos = readBuffer.getLong(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2012-05-13 12:11:18
|
Revision: 3771 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3771&view=rev Author: kappa1 Date: 2012-05-13 12:11:12 +0000 (Sun, 13 May 2012) Log Message: ----------- Fix Mouse.getDX() and Mouse.getDY() values when mouse moves outside Display window & clipping is on. Thanks to ra4king for patch. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2012-05-09 12:33:16 UTC (rev 3770) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2012-05-13 12:11:12 UTC (rev 3771) @@ -77,6 +77,12 @@ /** Mouse absolute Y position in pixels */ private static int y; + + /** Mouse absolute X position in pixels without any clipping */ + private static int absolute_x; + + /** Mouse absolute Y position in pixels without any clipping */ + private static int absolute_y; /** Buffer to hold the deltas dx, dy and dwheel */ private static IntBuffer coord_buffer; @@ -355,17 +361,21 @@ dy += poll_coord2; x += poll_coord1; y += poll_coord2; + absolute_x += poll_coord1; + absolute_y += poll_coord2; } else { - dx = poll_coord1 - x; - dy = poll_coord2 - y; - x = poll_coord1; - y = poll_coord2; + dx = poll_coord1 - absolute_x; + dy = poll_coord2 - absolute_y; + absolute_x = x = poll_coord1; + absolute_y = y = poll_coord2; } - if(clipMouseCoordinatesToWindow) { - x = Math.min(Display.getWidth() - 1, Math.max(0, x)); - y = Math.min(Display.getHeight() - 1, Math.max(0, y)); - } - dwheel += poll_dwheel; + + if(clipMouseCoordinatesToWindow) { + x = Math.min(Display.getWidth() - 1, Math.max(0, x)); + y = Math.min(Display.getHeight() - 1, Math.max(0, y)); + } + + dwheel += poll_dwheel; read(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |