Allowing the cursor to exit the jme app

The Problem

I am using a FirstPersonHandler in my game with extends SimpleGame. The main problem with this is that when I run my program, the cursor gets stuck within the bounds of the application's window. If i attempt to move the cursor out of this window, I can't.

The Question

So, I'm wondering if any of you know a fix (or hack) that lets users of your program move the cursor out of the game's window as if it were a normal window. If you know of a solution or can point me in the right direction, please tell me.

I have done the following already:

  • read this:

  • searched on

  • searched on

  • searched on

  • visited the tutorials

  • searched the forum (duh, b/c i'm on it right now)

You're Awesome
Thank you so much in advance. You guys are the best.
Benjamin D. Beasley

You could use an awt canvas (see jmetest.awt.TestCanvas) instead of a direct opengl window. Then the mouse should behave as you want it.



AWT Canvas is the only way I've gotten this to work in the past.  Given the fullscreen config flag in the jME settings, should the logic be changed to create an AWT/windowed game under the covers whenever fullscreen is disabled? Add a focus listener to handle mouse capture&release and pass alt+tab / apple+tab up to the OS?

I've noticed alt-tab works in windows but not linux. I've just gotten used to hitting alt+f9 to minimize the window when I need to check the console or check something in YourKit.

I also noticed restoring a minimized window in Linux in jME2 (haven't tested this in 3 yet) takes much longer than jME1.0.

No, a normal application has to capture the mouse. In a game that does not do this, imagine you control the aiming with the mouse. Playing in windowed mode would break the aiming because your mouse moves out of the window all the time.

I'm not saying make the mouse transient to the application because of the same reason you described.  I realize the AWT/Canvas implementation would cause that and in a first person shooter it would be annoying. 

Maybe have a hot-key to release the mouse in the current implementation.  I think this is only a problem on linux though where the only way to use another app is to minimize the jME one (windowed of full screen) because alt+tab does not work.  I don't know if this is gtk or lwjgl and if jME can do anything about it.

You could (in your own app) add a mapping to a key like F1 and make it disable the flycam (flyCam.setEnabled(false)) or enable drag to rotate (flyCam.setDragToRotate(true)), this will efficively make the cursor visible/invisible in the press of the key.

Thanks for the pro-tip.  That sounds exactly what I need.