Several issues with OIS in linux

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
underworldguardian
Gnoblar
Posts: 12
Joined: Thu Nov 13, 2014 3:08 pm

Several issues with OIS in linux

Post by underworldguardian »

Hi,

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
The keyboard initially works fine but then after 31 seconds, it stops working and only works again when I kill the OIS input manager and recreate it (I even tried to find a solution for the problem by recreating the input manager every 20 seconds, but then my application behaves weird if a key is pressed during recreation).

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;
	}
}
Furthermore I experienced a problem that if I do not use "pl.insert(std::make_pair(std::string("x11_keyboard_grab"),std::string("false")));" in my code, the mouse is not able to move the ogre window. This could be resolved by minimizing and restoring the window, but now that I kill the input manager every time the window is out of sight, this work around does not work anymore.

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:
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: Several issues with OIS in linux

Post by dark_sylinc »

I have never experienced what you describe.
Telling which OS you were using and a lot of detail about it would greatly; since every Linux distro is a world of its own.
underworldguardian
Gnoblar
Posts: 12
Joined: Thu Nov 13, 2014 3:08 pm

Re: Several issues with OIS in linux

Post by underworldguardian »

You are right, linux distros are usually very different. I am experiencing that problem on a Linux mint Linux Mint 17 Qiana. I have compiled OGRE from source that I received from hg clone https://bitbucket.org/sinbad/ogre/ -u v1-9 (it might have changed since, I am not sure) and I installed the libois-1.3.0 and libois-dev libraries.

Furthermore I installed the following dependencies:

Code: Select all

sudo apt-get install build-essential automake libtool # compiler and configuration tools
sudo apt-get install libfreetype6-dev libfreeimage-dev libzzip-dev libxrandr-dev libxaw7-dev freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev nvidia-cg-dev # required dependencies
CEGUI I compiled as well from source. But I think the CEGUI component does not matter in this context. What else do you need?

Edit: Here it is!
Last edited by underworldguardian on Sun Feb 22, 2015 9:29 am, edited 1 time in total.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Several issues with OIS in linux

Post by scrawl »

The easiest solution would be to switch to an input library that is actually still being maintained, such as SDL2 or SFML.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Several issues with OIS in linux

Post by xrgo »

I had problems with OIS on ubuntu, sometimes it disabled the repeat keys on the whole OS.
That's my recommendation too, I recently changed to SDL2, because I need joystick hotplug, no problem so far...
good luck!
underworldguardian
Gnoblar
Posts: 12
Joined: Thu Nov 13, 2014 3:08 pm

Re: Several issues with OIS in linux

Post by underworldguardian »

I tried to post before but it said that it still has to be accepted to be published.

Are SDL2 or SFML both plattform independent? Are there any tutorials for OGRE already? I saw that it is not maintained anymore and was already asking myself why it is still the default library for OGRE, which is nicely maintained.

Thanks for helping me out!

Edit: Weird, this post worked, so the other might be gone. I will write the other one tomorrow again about my OS configuration.
hydexon
Gremlin
Posts: 164
Joined: Sun Apr 14, 2013 8:51 pm
x 10

Re: Several issues with OIS in linux

Post by hydexon »

underworldguardian wrote:I tried to post before but it said that it still has to be accepted to be published.

Are SDL2 or SFML both plattform independent? Are there any tutorials for OGRE already? I saw that it is not maintained anymore and was already asking myself why it is still the default library for OGRE, which is nicely maintained.

Thanks for helping me out!

Edit: Weird, this post worked, so the other might be gone. I will write the other one tomorrow again about my OS configuration.
* Both SDL2 and SFML are platform independient, they aren't OGRE tutorials yet but there but in this folderin the OGRE Repository for the new (2.1 branch) you can find the files SDLInputHandler.h and SDLInputHandler.cpp which is they are good and wraps OGRE with SDL2. I heard some people can used SFML2 with OGRE 2 but they are explicitly to use OpenGL instead of DirectX.

Also: DEATH TO OIS.
underworldguardian
Gnoblar
Posts: 12
Joined: Thu Nov 13, 2014 3:08 pm

Re: Several issues with OIS in linux

Post by underworldguardian »

Thank you guys for your help! I think it will be the best for me to switch to SDL2 from OIS. Is it already possible to abandon ogre 1.9 and go to ogre 2.1 for my development or is this a bit too early? The question is if I will be able to work with it, compile and run it? Otherwise I just switch to SDL2 in my existing ogre 1.9 based framework.
Post Reply