SimpleApplication captures mouse, no matter what

Hi,



I’ve just started with JME3 and I’m running through tutorials. The thing I noticed is that no matter what my mouse is being captured by the application (even with the very first HelloWorld sample). When I move the mouse, camera starts rotating accordingly and mouse wheel causes it to zoom in and out, even though there is no handling of mouse events in the application (like in the HelloWorld example). I cannot “uncapture” the mouse. On the other hand, the keyboard doesn’t get captured at all (even in the HelloInput sample). It rather stays in jMonkeyPlatform IDE if I start it from there (or whatever app that was running before otherwise). The other consequence is that, because mouse stays captured by the app, in order to exit it, the only thing I can do is to kill it by going to tty console (Alt-Tab task switching doesn’t work either). In HelloInput, mouse button does cause the cube to rotate, but, as I mentioned, no keyboard events are captured. So I’m guessing that’s not expected behaviour.



I’m using x64 Ubuntu 10.10 with 2.6.35-25-generic kernel and

java version “1.6.0_22”

Java™ SE Runtime Environment (build 1.6.0_22-b04)

Java HotSpot™ 64-Bit Server VM (build 17.1-b03, mixed mode)



The only warning I get in any of the examples is:

WARNING: Uniform m_VertexColor is not declared in shader.

Inconsistency detected by ld.so: dl-close.c: 736: _dl_close: Assertion `map->l_init_called’ failed!

Java Result: 127



But I’m guessing that’s completely unrelated.



It seems that mouse and keyboard are initialized correctly every time:

01.02.2011. 05:34:02 com.jme3.input.lwjgl.LwjglMouseInput initialize

INFO: Mouse created.

01.02.2011. 05:34:02 com.jme3.input.lwjgl.LwjglKeyInput initialize

INFO: Keyboard created.



I don’t know if it’s a known issue. I did a search, but haven’t found any info on it. I’m aware JME3 is still in alpha, so could it be a bug or is there something else I’m missing here?



Thanks.

HelloWorld uses a FlyCam thats controlled via mouse, thats why it captures it. To see the mouse, use inputManager.setCursorVisible(true). I am experiencing it sometimes that the keyboard input doesnt arrive in jME3 but otherwise I cannot reproduce this…

1 Like

Yes, thanks for the tip, normen. It did the trick.



Interesting thing though is now when I run it with inputManager.setCursorVisible(true), the keyboard input does arrive (but only when I click inside the window or on the title bar, ie. when window gets focus) and it completely releases the mouse every time when it’s pointing outside the window. However, if the cursor isn’t visible it doesn’t work like that. Mouse is captured immediately and it doesn’t get released at all, no matter how far I try to move it, and clicking doesn’t capture the keyboard.



Nevertheless, I will use visible cursor from now on. That works OK.



Thank you.

Well this is intended behavior, imagine playing a shooter and your mouse moves out of the window all the time :wink:

True, but imagine the frustration while you struggle to move and nothing happens (only to find out later you have some strange lines in the mail you wrote to your boss telling him you’ll be late for work, which look something like wwwwwwwwwwwwwwswsswwawdsawdawdawdasawd) :slight_smile:

Yeah sure, I was just talking about the mouse capturing.

Alright. Shiny! The trouble apparently is compiz. With compiz turned off, everything is OK. Compiz and lwjgl seem not to like each other. I don’t know if it’s compiz in general or just some part of it. Will investigate further (after some sleep).

I’m using Ubuntu 10.10 with Compiz and it seems to work just as when I boot this computer with XP. inputManager.setCursorVisible(true) makes the mouse visible (duh) but it also allows me to move the cursor outside the window where the game stop reacting to it.



flyCam.setEnabled(false) can also be used. It makes the mouse visible and your camera no longer moves with it and the cursor is able to escape the window like any other application.

Are you using Emerald for window decorations or Metacity? I’m using Emerald. Apart from that, I tweaked a lot of Compiz options. Maybe I tweaked too much. :slight_smile: But thanks for the input. That means I broke something while tweaking. Will find out exactly what that is.

I’m using Emerald too. I haven’t really tweaked anything, I have the basic settings with some small changes I think.