question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prior to 1st mouse movement, InputManager returns (0,0) for cursor position

See original GitHub issue

After 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:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tonihelecommented, Jul 24, 2018

My PR would solve this for LWJGL 3.

0reactions
stephengoldcommented, Jan 21, 2018

I looked at LWJGL3, but I don’t understand it well enough to code a fix for it.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found