Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Problems building or running the engine, queries about how to use features etc.
Post Reply
mrmclovin
Gnome
Posts: 324
Joined: Sun May 11, 2008 9:27 pm
x 20

Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by mrmclovin »

Hello,

I have a problem recieving keyboard and mouse updates from OIS on my Mac OSX build. I'm using the same source code as on my Windows machine (where everything works), and everything compiles and runs. I have set breakpoints in OIS::Keyboard::capture() and it hits, but still I don't receive anything to the mouseMoved() callback functions.

Also another thing, if I Cmd+Tab away rom my render window and can't tab it back, instead I have to focus it back from Mission Control ... Maybe it's something with the window management as well? (Using Ogres auto created window here...)

Using:
OSX 10.8
Ogre 1.9
64-bit build
Cocoa

Code: Select all

		OIS::ParamList			pl;
		size_t					winHnd = 0;
		std::stringstream		strWinHnd;

		win->getCustomAttribute("WINDOW", &winHnd);
		strWinHnd << winHnd;
		pl.insert(std::make_pair(std::string("WINDOW"), strWinHnd.str()));

		mMgr = OIS::InputManager::createInputSystem(pl);

		// create input devices
		// (buffered)
		mMouse = createMouse(true);
		mKeyboard = createKeyboard(true);

		// set callback
		mMouse->setEventCallback(this);
		mKeyboard->setEventCallback(this);

		int mWidth = win->getWidth();
		int mHeight = win->getHeight();

		const OIS::MouseState &ms = mMouse->getMouseState();
		ms.width = (int)mWidth;

Code: Select all

			Ogre::WindowEventUtilities::messagePump();
			inputMgr->captureInput();
Any help appreciated. Thanks.
retrogam3r
Gnoblar
Posts: 9
Joined: Wed Feb 05, 2014 1:38 am

Re: Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by retrogam3r »

Hello,

Did you manage to fix the problem? I am having same problem with Ogre 1.9, it just doesn't seem to capture any keyboard and mouse input
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by masterfalcon »

How have you implemented rendering and input updates?
retrogam3r
Gnoblar
Posts: 9
Joined: Wed Feb 05, 2014 1:38 am

Re: Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by retrogam3r »

Hello,

Thanks for replying :). I am setting up rendering and input capture using event listeners. I have posted slightly modified tutorial framework code for your reference.

Code: Select all

	inputManager = OIS::InputManager::createInputSystem(parameterList);

	keyboard	= static_cast<OIS::Keyboard*>(inputManager->createInputObject( OIS::OISKeyboard, true ));
	mouse		= static_cast<OIS::Mouse*>(inputManager->createInputObject( OIS::OISMouse, true ));

	inputContext.mKeyboard	= keyboard;
	inputContext.mMouse		= mouse;

    mouse->setEventCallback(this);
    keyboard->setEventCallback(this);
After setting that up I am firing up

Code: Select all

 root->startRendering();
and capturing update event in frameRenderingQueued and for inputs I am using OIS input events. On windows it works fine, although on OSX I am not receiving any event callbacks with the same code.
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by masterfalcon »

retrogam3r wrote: root->startRendering();
That's the problem. As with iOS, Cocoa on OS X requires you to use either a NSTimer or CVDisplayLink to drive rendering. The while loop in startRendering prevents Ogre's Cocoa view from receiving events such as mouse, window resize, etc.
retrogam3r
Gnoblar
Posts: 9
Joined: Wed Feb 05, 2014 1:38 am

Re: Keyboard/Mouse/Window not responding on OSX / OIS 64-bit

Post by retrogam3r »

I see it makes total sense, and I came across another similar post like this where you suggested alternative to use NSTimer as used in sample browser, I should have searched harder before posting :( , But anyways now thats clear I will create a delegate class and fire CADisplayLink function with a callback to renderoneframe.

Thank you
Post Reply