prior to 1st mouse movement, InputManager returns (0,0) for cursor position
See original GitHub issueAfter my JME application starts but before I move my mouse, inputManager.getCursorPosition() always returns (0,0), even if the mouse cursor is nowhere near that corner of the screen. Meanwhile, LWJGL’s Mouse.getX() and Mouse.getY() return a more reasonable position.
As soon as my mouse moves, inputManager.getCursorPosition() starts returning reasonable positions that agree with LWJGL.
I see the same behavior with both 3.1.0-stable and 3.2.0-stable, so if this is a bug, it’s not a new one.
Here is my test app:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.math.Vector2f;
import org.lwjgl.input.Mouse;
public class Main extends SimpleApplication {
BitmapText bitmapText;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setEnabled(false);
inputManager.setCursorVisible(true);
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
bitmapText = new BitmapText(guiFont, false);
bitmapText.setLocalTranslation(0, cam.getHeight(), 0);
bitmapText.setSize(guiFont.getCharSet().getRenderedSize());
guiNode.attachChild(bitmapText);
}
@Override
public void simpleUpdate(float tpf) {
float x = Mouse.getX();
float y = Mouse.getY();
Vector2f pos = inputManager.getCursorPosition();
String message = String.format(
"inputManager says %s lwjgl says (%.1f, %.1f)",
pos, x, y);
bitmapText.setText(message);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to detect mouse movement as an input in Unity
Calling Input.mousePosition returns us the current position as Vector3 . Note that the z component of the returned value is always 0 ....
Read more >Mouse Delta Input - Unity Forum
I.e. you get the accumulated mouse motion in the frame. And on the beginning of the next frame, it automatically resets to (0,0)....
Read more >Mouse | Stride
InputManager.AbsoluteMousePosition returns the mouse pointer position in absolute X and Y coordinates (the actual screen size in pixels).
Read more >How to convert the mouse position to world space in Unity
Learn how to convert the mouse position on the screen to a real position in the game world in Unityp.s. if you're using...
Read more >Get Mouse position in Unity(both Old and New Input system)
In this tutorial, we will see how to get mouse position in Unity using both the old Input system and the new Unity...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My PR would solve this for LWJGL 3.
I looked at LWJGL3, but I don’t understand it well enough to code a fix for it.