Mouse cursor starts at 0,0 even when it's not actually there? [SOLVED]

It seems like, before the user has moved the mouse, calls to InputManager.getCursorPosition() return (0,0) at the coordinate even, if that is not the location that the mouse is actually at. What’s the best way to tell the difference between a real 0,0 position and a fake due to the mouse having not yet been moved?

EDIT: Seems to particularly be the case if JMonkeyEngine is in windowed mode and the cursor has not entered the window area yet.

One question is why you need to know this.

If you were reacting to a mouse move event then it would never be an issue.

I am not reacting to a mouse move event. I just want something to follow the cursor, whether or not the mouse has moved yet.

By the way, is there a way to tell if the mouse is not over the window at all?

I read that as:
“I don’t need to know when the mouse moves… I just need to know when the mouse moves.”

Just register a RawInputListener and react to the mouse movement and all of your problems will be solved.

Not through JME.

I edited to clarify: I am not reacting to a mouse move event. I just want something to follow the cursor, whether or not the mouse has moved yet. IE. I don’t want it to go to 0,0 if the mouse cursor isn’t at 0,0.

EDIT: And if it’s not at 0,0, I want to know where it actually is.

Ok, maybe english isn’t your first language… but “something following the cursor” is 100% “reacting to mouse movement”.

No… until the mouse has moved JME doesn’t know where it is.

You might have to resort to some deeper calls.

If you are using LWJGL use the Mouse class, however you have to handle all edge cases yourself then.

Why don’t you initialize your listener, including a boolean value. Initially as you say, the mouse will be 0,0. So while it’s in that position, the value is false, so don’t add your follower. When it stops being 0,0 - change the boolean value to true - and thus your follower will be added.

Other than that, paul is speaking sense. I presume your problem is that your follower is stuck at 0,0 and looks silly until the mouse has actually moved.

You could also check the position of the mouse vs the extremeties of the window, and if they match, remove the follower (or preferably set the cullhint to avoid continually adding and removing a simple node.

Does that help?

What I ended up doing is using some LWJGL calls to get around the behavior. Especially Mouse.isInsideWindow().