|
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.
|