OIS continously locked in case of crash

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
Excizted
Halfling
Posts: 77
Joined: Mon Nov 02, 2009 6:45 pm
Location: Fyn, Denmark

OIS continously locked in case of crash

Post by Excizted »

Hi fellow Ogre people.

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.

Anyone got any ideas how to get around this?

Thanks! :)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: OIS continously locked in case of crash

Post by CABAListic »

There are several.

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.
User avatar
Excizted
Halfling
Posts: 77
Joined: Mon Nov 02, 2009 6:45 pm
Location: Fyn, Denmark

Re: OIS continously locked in case of crash

Post by Excizted »

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?
dermont
Bugbear
Posts: 812
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: OIS continously locked in case of crash

Post by dermont »

CABAListic wrote:There are several.

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 think "AllowDeactivateGrabs" was removed from Xorg some time ago. You could try using a workaround such as:
http://bugs.freedesktop.org/show_bug.cgi?id=21652
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: OIS continously locked in case of crash

Post by CABAListic »

That would explain why I didn't get it to work again. A damn shame.
User avatar
Excizted
Halfling
Posts: 77
Joined: Mon Nov 02, 2009 6:45 pm
Location: Fyn, Denmark

Re: OIS continously locked in case of crash

Post by Excizted »

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.

I really hope there is a way by now?!
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OIS continously locked in case of crash

Post by jacmoe »

Neither NetBeans, nor X or OIS has anything to do with Ogre ? :P

Did you visit the OIS forum to see if there's any other people having the same issue?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Excizted
Halfling
Posts: 77
Joined: Mon Nov 02, 2009 6:45 pm
Location: Fyn, Denmark

Re: OIS continously locked in case of crash

Post by Excizted »

jacmoe wrote:Neither NetBeans, nor X or OIS has anything to do with Ogre ? :P

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? :D
Still hope someone here would know of it - I'll try the OIS forum too, but haven't had luck previously there.
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

Re: OIS continously locked in case of crash

Post by stoneCold »

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 ?

Here's the relevant part of my code:

Code: Select all

#if defined OIS_WIN32_PLATFORM
	pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
	pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
	pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
	pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
	pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
	pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
	pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
	pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
Cheers
my tweets | www.fuse-software.com | home of vektrix (Flash GUI for Ogre3D) and caspin (ActionScript 3 Virtual Machine Wrapper)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: OIS continously locked in case of crash

Post by CABAListic »

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 ;)
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

Re: OIS continously locked in case of crash

Post by stoneCold »

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

Code: Select all

if(mouseX < 5) mouseX = 10;
else if(mouseX > winWidth - 5) mouseX = winWidth - 10;

// similar for "Y"

setOSmousePos(mouseX, mouseY);
... works well for me at least.
(Obviously you'll just use this during debugging and disable it for release builds :wink:)

Cheers
my tweets | www.fuse-software.com | home of vektrix (Flash GUI for Ogre3D) and caspin (ActionScript 3 Virtual Machine Wrapper)
Blackzafiro
Gnoblar
Posts: 7
Joined: Sun Jan 12, 2014 7:48 pm

Re: OIS continously locked in case of crash

Post by Blackzafiro »

Excizted wrote: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?
Ctrl-alt-tab just worked for me to ungrab the mouse, but haven't tried during debug.
Post Reply