I am developing a 3D virtual creature simulator in OGRE similar to the 3DVCE byGraham Lee (http://3dvce.wikia.com/wiki/Main_Page). That one was also written in the OGRE engine but unfortunately, the source is missing to the world.
So here is my problem:
My simulator should be a multiplattform application that runs on windows and linux. Currently I am trying to achieve non-exclusive keyboard and mouse input and windowed mode as it is usual for simulators. I am using CEGUI, OIS with OGRE. Up to now I am developing it mainly in linux and I am facing a problem there. When I use non-exclusive input with the keyboard, the keyboard stops working after a while.
It only happens when i set x11_keyboard_grab as "false" which is what I need for the non-exclusive input. I use the following parameter list for the non-exclusive input settings.
Code: Select all
pl.insert(
OIS::ParamList::value_type("WINDOW",
Ogre::StringConverter::toString(hWnd)));
//The mouse should never be bound to the window
#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
What I do for the moment is to kill the input manager when my window is not visible and recreating it when the window gets visible again. Further I comment out the "pl.insert(std::make_pair(std::string("x11_keyboard_grab"),std::string("false")));" line. By that I get a pretty non-exclusive input for the keyboard.
Code: Select all
void CEGUIInputHandler::initializeInputHandler() {
if (mInputManager == NULL) {
BOOST_LOG_SEV(mBoostLogger, boost::log::trivial::info)<< "initializing OIS input handler...";
mInputManager = OIS::InputManager::createInputSystem(pl);
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(
OIS::OISMouse, true));
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(
OIS::OISKeyboard, true));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
}
}
void CEGUIInputHandler::destroyInputHandler() {
if (mInputManager != NULL) {
BOOST_LOG_SEV(mBoostLogger, boost::log::trivial::info)<< "destroying OIS input handler...";
mInputManager->destroyInputObject(mKeyboard);
mInputManager->destroyInputObject(mMouse);
mKeyboard = NULL;
mMouse = NULL;
OIS::InputManager::destroyInputSystem(mInputManager);
mInputManager = NULL;
}
}
So what I wrong here? Does anybody have any advice? Do these parameters work well for other linux users?
The first error I am experiencing was experienced before by somebody else on ogre and OIS forum, but the problem could not be resolved there: