From 6f1f14facbcc926f0fea1583e3a2444662eb13e9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 12 Apr 2004 07:13:36 +0000 Subject: [PATCH] Reverted the relative coordinate 'bug' - that's the required behaviour when Window.update is calling Mouse.poll. Consider the case where we call Window.update twice before checking getD*: with the old behaviour, only the deltas between the updates are reported, not those before the first update --- src/java/org/lwjgl/input/Mouse.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/java/org/lwjgl/input/Mouse.java b/src/java/org/lwjgl/input/Mouse.java index 6e9d74db..9028284d 100644 --- a/src/java/org/lwjgl/input/Mouse.java +++ b/src/java/org/lwjgl/input/Mouse.java @@ -348,9 +348,9 @@ public class Mouse { // set absolute position x += poll_dx; y += poll_dy; - dx = poll_dx; - dy = poll_dy; - dwheel = poll_dwheel; + dx += poll_dx; + dy += poll_dy; + dwheel += poll_dwheel; // if window has been created, clamp to edges if (Window.isCreated()) { @@ -502,21 +502,27 @@ public class Mouse { * @return Movement on the x axis since last time getDX() was called */ public static int getDX() { - return dx; + int result = dx; + dx = 0; + return result; } /** * @return Movement on the y axis since last time getDY() was called */ public static int getDY() { - return dy; + int result = dy; + dy = 0; + return result; } /** * @return Movement of the wheel since last time getDWheel() was called */ public static int getDWheel() { - return dwheel; + int result = dwheel; + dwheel = 0; + return result; } /** @@ -564,4 +570,4 @@ public class Mouse { } } } -} \ No newline at end of file +}