When you move your mouse all the way to the left - it hits the left edge of the screen and stops - even if the user keeps moving his mouse to the left.
In
Java, there doesn't appear to be any way to detect that the user keeps moving his mouse "left".
Basically, if the current mouse coords are 50,100 and I move my mouse 10 feet to the left on my desk Java will still only report the position as 0,100.
My problem is, not only do I have to detect that the user moved the mouse to location -32535235,100 I also have to detect that position accurately.
In order to accomplish this, I'm doing the following:
1) Use robot class to forcefully move the cursor to the center of the screen.
2) Detect relative mouse movements and some Point which keeps track of the total movement
3) Repeat - go back to step 1
The code I'm using is basically straight out of a Java game development book "Developing Games in Java". This technique appears to work well for reporting simple changes in the relative x,y movement. It does not appear to be accurate in reporting actual x,y coordinates.
So my
test case is this:
1) Start the application.
2) Move the mouse 1 foot to the left (left side of desk) - record the X location
3) Move the mouse 2 feet to the right (right side of desk)- record the X location.
4) Finally, move the mouse back to the left side of the desk and ensure it is the same (or very close) to the location recorded in step 2.
Currently when I do this, it's way off by hundreds of pixels.
Is there a simple error in the code that I'm missing? Any ideas on how I can accomplish this?
Here's the code:
[ August 14, 2007: Message edited by: Jonathan Janisch ]