I'm using NetBeans to develop my Ogre application under Linux.
When I run my application through NetBeans debugging, in the case of a crash (Segmentation Fault), OIS mouse and keyboard are still locked to the crashed window and it's size.
The only thing I can do is switch TTY and do a killall of NetBeans to close the debugging session.
This is fatal to my debugging, because I can't debug crashes if the game would be crashing.
I tried shutting down OIS in the windowClosed callback from the Ogre Window Utilities, but the Window actually don't get to close.
1. Tell OIS not to capture the input in the first place. Use the param list version of OIS::InputManager::createInputSystem and set the parameters "x11_keyboard_grab" and "x11_mouse_grab" to the value "false". Mouse and keyboard will not be captured exclusively, so they are available in case of a crash. But it also means that the mouse can leave the program window at any time, so this may not be desirable as the default behaviour (just for debug sessions).
2. Debug from the console. Start your program normally (without gdb), then switch to a console and attach the debugger from there. You need to pass the PID of your program as a second argument to gdb, then inside gdb type 'continue' to have the program continue running. Switch back to X and make your program crash, then you can debug in the console. Not particularly great, but it works reliably.
3. There is an X input event which ungrabs the input devices once activated. It is usually bound to CTRL+ALT+KP_DIVIDE (divide on numpad). This is the cleanest and best solution, however, if, like me, your keyboard doesn't have a numpad, then you've got a problem. It is in principle possible to map the input event to another key combination via xmodmap, but even though this worked for me in the past I haven't been able to get it working recently. Maybe you have more luck than me. The input event is called XF86_Ungrab.
It might also be that you need to enable an X server option in xorg.conf to make use of this input event, I'm not sure. It is surprisingly hard to find any good information about it with Google.
Edit: Yes, there's an X.org option in ServerFlags called "AllowDeactivateGrabs" which I think defaults to false, so you'll have to enable that first.
Hi and thanks.
I went ahead to try your keyboard shortcut, but it had no effect.
So I guess I'll have to activate it from the Xorg file, but I have no idea what the option is called or what section it goes under?
3. There is an X input event which ungrabs the input devices once activated. It is usually bound to CTRL+ALT+KP_DIVIDE (divide on numpad). This is the cleanest and best solution, however, if, like me, your keyboard doesn't have a numpad, then you've got a problem. It is in principle possible to map the input event to another key combination via xmodmap, but even though this worked for me in the past I haven't been able to get it working recently. Maybe you have more luck than me. The input event is called XF86_Ungrab.
It might also be that you need to enable an X server option in xorg.conf to make use of this input event, I'm not sure. It is surprisingly hard to find any good information about it with Google.
Edit: Yes, there's an X.org option in ServerFlags called "AllowDeactivateGrabs" which I think defaults to false, so you'll have to enable that first.
I'm just going to revive this thread to hear if anyone has found a way to ungrab the mouse. Maybe a fix is now available?
I'm being very frustrated, being unable to test my FPS game properly while debugging?
The suggested solution with not grabbing in the first place is no good in FPS you can't look around.
The solution with using GDB manually is possible, but would greatly reduce my productivity as I'd have to manually define breakpoints and stuff, rather than just do some clicks in my IDE and mouse over variables to see their values.
jacmoe wrote:Neither NetBeans, nor X or OIS has anything to do with Ogre ?
Did you visit the OIS forum to see if there's any other people having the same issue?
You are probably right about that But I do think the FPS relation has something to do with Ogre?
Still hope someone here would know of it - I'll try the OIS forum too, but haven't had luck previously there.
Excizted wrote:...The suggested solution with not grabbing in the first place is no good in FPS you can't look around...
I'm not sure if I understand what you mean with "is no good in FPS you can't look around" ?!
I've successfully used the "OIS non-exclusive" approach for debugging an Ogre application within Netbeans just one week ago, and all worked perfectly fine for me. Could you explain what troubles you are running into exactly ?
He means that you can't control a first person shooter (FPS) like game if the mouse isn't locked, because mouse look-around is incredibly difficult. Therefore, it's kind of difficult to reproduce a crash you wish to debug
It's not, if you "lock" the mouse to the window manually, i.e. restrict the X/Y position of the mouse to the boundaries of your window inside your code.
Something like...