ExampleFrameListener "don't grab mouse/keyboard" patch

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: Princeton, New Jersey, USA
Contact:

ExampleFrameListener "don't grab mouse/keyboard" patch

Post by nikki » Thu Mar 19, 2009 12:45 pm

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 );
 
0 x

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
Contact:

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

Post by CABAListic » Thu Mar 19, 2009 1:21 pm

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

User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: Princeton, New Jersey, USA
Contact:

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

Post by nikki » Fri Mar 20, 2009 7:42 am

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

User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada

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

Post by omniter » Fri Mar 20, 2009 10:13 pm

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

Post Reply