Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Windows, Linux OK... OSX not so much  (Read 708 times)

madmark

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
    • View Profile
Windows, Linux OK... OSX not so much
« on: January 28, 2010, 10:48:00 AM »

As the title states, I have a program running fine under Windows and Linux (Ubunti 9.10) but OIS does not provide any input events under OSX. Using Ogre 1.6.5 and the following code, directly ripped from Ogre samples with the exception of using buffered input modes.

Code: [Select]
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;

size_t windowHnd = 0;
std::ostringstream windowHndStr;

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

#ifdef WINDOWS
    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")));
#else
    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

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

//Create all devices
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));

windowResized(win);


m_pGUIListener = new CGUIListener(win, pInputHandler);

mMouse->setEventCallback(m_pGUIListener);
mKeyboard->setEventCallback(m_pGUIListener);

Ogre::WindowEventUtilities::addWindowEventListener(win, this);

Looking at the Mac OIS code, it seems the parameter block ignores both the Windows and Linux/X11 parameters and has no analogs, so I just left the Linux stuff in for now (yes I tried it without).

The mouse and the keyboard object look to be sane and do point to my listener object, it just never calls any of the event functions.

The OIS console sample works, as does the Ogre samples so I am assuming there is something I am doing wrong but I just can't seem to find it. Seeing that it works in the other platforms, it must be something Mac specific...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: Windows, Linux OK... OSX not so much
« Reply #1 on: January 28, 2010, 09:40:21 PM »

If your not getting inputs I would make sure:
1) You are pumping the message loop (using Ogre's auto render loop, or calling Ogre's messagePump function)
2) You are calling capture() on your devices each frame.
Logged

madmark

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
    • View Profile
Re: Windows, Linux OK... OSX not so much
« Reply #2 on: January 29, 2010, 04:49:12 AM »

OMG! I've been running this code for 4 years and never had a call to the Ogre message pump in it!

Code: [Select]
Ogre::WindowEventUtilities::messagePump();
Thanks for the kick to the head, I would have NEVER found this in a million years.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: Windows, Linux OK... OSX not so much
« Reply #3 on: February 01, 2010, 07:47:23 PM »

No problem :) The lack of a Message Pump causes very minute, almost unnoticeable problems... glad I could help.
Logged