void InputHandler::StateSwitched(SimulationState old, SimulationState cur) { int height = mMouse->getMouseState().height; int width = mMouse->getMouseState().width; if (old == SIMULATION && cur == SIMULATION_MOUSELOOK || cur == SIMULATION_TOPDOWNVIEW) { destroySystem(); createSystem(true); //capture(); } else if ((cur == SIMULATION) && old == SIMULATION_MOUSELOOK || old == SIMULATION_TOPDOWNVIEW) { destroySystem(); createSystem(false); //capture(); } setWindowExtents(width, height); }
bool CServer::initOIS() { // Cogemos el identificador y las dimensiones de la ventana // de renderizado para el gestor de periféricos de entrada. // Para saber el espacio de actuación del ratón. unsigned int width, height, windowHnd; getWindowExtents(width,height); if((width == -1) || (height == -1)) return false; if((windowHnd = getWindowHnd()) == -1) return false; // Preparamos variables para la inicialización del sistema // de entrada. OIS::ParamList paramList; std::ostringstream windowHndStr; windowHndStr << windowHnd; paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); #if defined NON_EXCLUSIVE_MODE_IN_WINDOW_MODE // Si estamos en modo ventana no queremos ratón y teclado en modo exclusivo, // queremos que las demás aplicaciones puedan usarlo. if(!_renderWindow->isFullScreen()) { #if defined OIS_WIN32_PLATFORM paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" ))); paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE"))); paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND"))); paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE"))); #elif defined OIS_LINUX_PLATFORM paramList.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false"))); paramList.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false"))); paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false"))); paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true"))); #endif } #endif // Creamos el sistema de entrada try { _inputSystem = OIS::InputManager::createInputSystem(paramList); } catch(std::exception e) { return false; } // Si es posible creamos el buffer del teclado. if (_inputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0) { _keyboard = static_cast<OIS::Keyboard*>(_inputSystem->createInputObject(OIS::OISKeyboard, true)); } // Si es posible creamos el buffer del ratón. if (_inputSystem->getNumberOfDevices(OIS::OISMouse) > 0) { _mouse = static_cast<OIS::Mouse*>(_inputSystem->createInputObject(OIS::OISMouse, true)); // Establecemos las dimensiones de la ventana de // renderizado para saber el espacio de actuación // del ratón. setWindowExtents(width, height); } //Si es posible creamos el buffer del joystick (el primero, seteado para un mando) if(_inputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0) { _joystick = static_cast<OIS::JoyStick*>(_inputSystem->createInputObject(OIS::OISJoyStick, true)); } return true; } // initOIS