Page 1 of 1

ExampleFrameListener "don't grab mouse/keyboard" patch

Posted: Thu Mar 19, 2009 12:45 pm
by nikki
Hey!

While running under X, the ExampleFrameListener sets up OIS such that it grabs the mouse/keyboard. This is a problem if one wants to do something else while running the application (debug with GDB, look at the current state of the log, whatever). Whenever I hit a breakpoint, it just got stuck and I had to restart X. :roll:

I've made a patch to ExampleFrameListener.h that fixes this problem. You might have to put guards like '#if LINUX' around it, but it's just a propertylist, so I think it wouldn't harm and would just be ignored on other platforms.

Code: Select all

--- ExampleFrameListener1.h	2009-03-19 14:35:20.000000000 -0700
+++ ExampleFrameListener2.h	2009-03-19 14:35:40.000000000 -0700
@@ -105,6 +105,8 @@
 		win->getCustomAttribute("WINDOW", &windowHnd);
 		windowHndStr << windowHnd;
 		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+		pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
+		pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
 
 		mInputManager = OIS::InputManager::createInputSystem( pl );
 

Re: ExampleFrameListener "don't grab mouse/keyboard" patch

Posted: Thu Mar 19, 2009 1:21 pm
by CABAListic
Restart X? I can usually still switch to a console via CTRL+Alt+Fx and kill the app ;) But I agree that mouse grabbing isn't exactly helpful for debugging. Some of the demos, however, have first person cameras which aren't really usable without mouse grabbing. So this should probably be limited to debug builds.

Re: ExampleFrameListener "don't grab mouse/keyboard" patch

Posted: Fri Mar 20, 2009 7:42 am
by nikki
CABAListic wrote:Restart X? I can usually still switch to a console via CTRL+Alt+Fx and kill the app ;)
Damn, didn't think of that. :x
Some of the demos, however, have first person cameras which aren't really usable without mouse grabbing. So this should probably be limited to debug builds.
Yeah, probably.

Re: ExampleFrameListener "don't grab mouse/keyboard" patch

Posted: Fri Mar 20, 2009 10:13 pm
by omniter
My current game engine uses Ogre and OIS, and it has a function for toggling cursor locking and/or visibility. It's not a very elegant solution, but basically you recreate the input system and devices every time, and pass in a different flag. It's instantaneous though, so I use it. You could modify ExampleApplication.h to have this feature, and use a key to toggle it or something. I'm really hoping to get my proposal for Google Summer of Code accepted, because then I could make a new Ogre Sample Browser with this feature added.