Ejemplo n.º 1
0
bool Kernel::createWindow ( uint width, uint height ) {
    Ogre::NameValuePairList lParams;
    lParams["FSAA"] = "false";
    lParams["vsync"] = "false";
    OGREWIndow = OGRERoot->createRenderWindow ( "CyberEg{o.o}rg 3D", width, height, false, &lParams );

    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    OGRESceneMgr = OGRERoot->createSceneManager ( "OctreeSceneManager" );

    OIS::ParamList pl;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;

    OGREWIndow->getCustomAttribute ( "WINDOW", &windowHnd );
    windowHndStr << windowHnd;
    pl.insert ( std::make_pair ( std::string ( "WINDOW" ), windowHndStr.str() ) );
    pl.insert ( std::make_pair ( std::string ( "x11_keyboard_grab" ), "false" ) );
    pl.insert ( std::make_pair ( std::string ( "x11_mouse_grab" ), "false" ) );
    //pl.insert ( std::make_pair ( std::string ( "x11_mouse_hide" ), "false" ) );


    OISInputManager     = OIS::InputManager::createInputSystem ( pl );
    OISKeyboard         = static_cast<OIS::Keyboard *> ( OISInputManager->createInputObject ( OIS::OISKeyboard, true ) );
    OISMouse            = static_cast<OIS::Mouse *> ( OISInputManager->createInputObject ( OIS::OISMouse, true ) );

    updateWindow();

    OGRESceneMgr->setAmbientLight ( Ogre::ColourValue ( 0.5f, 0.5f, 0.5f ) );

    OISKeyboard->setEventCallback ( this );
    OISMouse->setEventCallback ( this );
}
Ejemplo n.º 2
0
    void DiInputManager::createInput(DiWndHandle wndhandle, DiWndViewHandle viewhandle)
    {
        std::ostringstream windowHndStr;
        windowHndStr << (ulong)wndhandle;

        OIS::ParamList pl;
        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
        pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_FOREGROUND"));
        pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_NONEXCLUSIVE"));
        
#if (DEMI_PLATFORM == DEMI_PLATFORM_IOS)
        // Pass the view to OIS so the contentScalingFactor can be used
        std::ostringstream viewHandleStr;
        viewHandleStr << (ulong)viewhandle;
        pl.insert(std::make_pair("VIEW", viewHandleStr.str()));
#endif

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

#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        mMultiTouch = static_cast<OIS::MultiTouch*>(mInputManager->createInputObject(OIS::OISMultiTouch, true));
        mMultiTouch->setEventCallback(this);
        
        mAccelerometer = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, true));
        
#elif DEMI_PLATFORM == DEMI_PLATFORM_WIN32 || DEMI_PLATFORM == DEMI_PLATFORM_OSX
        mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
        mKeyboard->setEventCallback(this);
        
        mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
        mMouse->setEventCallback(this);
#endif
    }
Ejemplo n.º 3
0
MyFrameListener::MyFrameListener(RenderWindow* win, Camera* cam, SceneManager *sm){

  OIS::ParamList param; size_t windowHandle;  ostringstream wHandleStr;

  _camera = cam;
  _sceneManager = sm; _win = win;
  _juego = new Juego(sm);
  _turno = 1;
  _estado = 1;
  
  
  srand((unsigned)time(NULL));   // Semilla aleatorios
  _win->getCustomAttribute("WINDOW", &windowHandle);
  wHandleStr << windowHandle;
  param.insert(make_pair("WINDOW", wHandleStr.str()));
  param.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
  param.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
  
  _inputManager = OIS::InputManager::createInputSystem(param);
  _keyboard = static_cast<OIS::Keyboard*>
    (_inputManager->createInputObject(OIS::OISKeyboard, false));
  _mouse = static_cast<OIS::Mouse*>
    (_inputManager->createInputObject(OIS::OISMouse, false));
  _mouse->getMouseState().width = _win->getWidth();
  _mouse->getMouseState().height = _win->getHeight();

  _mouse->capture();

  _raySceneQuery = _sceneManager->createRayQuery(Ray());

}
Ejemplo n.º 4
0
/*
 *
 * Constructor Frame Listener
 */
MyFrameListener::MyFrameListener(Ogre::RenderWindow* win) {

  _idSelectedShip = -1;
  _mode = MODE_STARTED;


  OIS::ParamList param;
  size_t windowHandle;  std::ostringstream wHandleStr;
  _win = win;
  _cam = Ogre::Root::getSingleton().
         getSceneManager("mainSM")->getCamera("MainCamera");
  _btnIzqPulsado = false;

  _rayScnQuery = Ogre::Root::getSingleton().
                 getSceneManager("mainSM")->createRayQuery(Ogre::Ray(), 0);

  _rayScnQueryDD = Ogre::Root::getSingleton().
                   getSceneManager("mainSM")->createRayQuery(Ogre::Ray(), 0);

  win->getCustomAttribute("WINDOW", &windowHandle);

  wHandleStr << windowHandle;
  param.insert(std::make_pair("WINDOW", wHandleStr.str()));
    param.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
    param.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
    param.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
    param.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
  
  _inputManager = OIS::InputManager::createInputSystem(param);

  _keyboard = static_cast<OIS::Keyboard*>
              (_inputManager->createInputObject(OIS::OISKeyboard, true));
  _mouse = static_cast<OIS::Mouse*> (_inputManager->
                                     createInputObject(OIS::OISMouse, false));


  _mouse->getMouseState().width = win->getWidth();
  _mouse->getMouseState().height = win->getHeight();


  mPlatform = new MyGUI::OgrePlatform();
  mPlatform->initialise(win, Ogre::Root::getSingleton().
                        getSceneManager("mainSM"));
  mGUI = new MyGUI::Gui();
  mGUI->initialise();
  _guiHandler =new GuiInputHandler();


  //  

  _gui = new GuiShip();
  _gui->createScene();
  _gui->enable();
    
  std::function<void(string)> f_button = std::bind(&MyFrameListener::guiButtonPressed, this, std::placeholders::_1);
  _gui->setCallback(f_button);
  _points = 0;


}
Ejemplo n.º 5
0
void Sample::setupInput()
{
    size_t winHWND = 0;
    mWindow->getCustomAttribute( "WINDOW", &winHWND );

    OIS::ParamList paramList; 
    std::ostringstream windowHndStr;
    windowHndStr << winHWND;

    paramList.insert(std::make_pair( std::string("WINDOW"), windowHndStr.str()));
    paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
    paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));

    // Create input system
    mInputSystem = OIS::InputManager::createInputSystem( paramList );

    // If possible create a buffered mouse
    if( mInputSystem->getNumberOfDevices(OIS::OISMouse) > 0 ) {
        mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) );
        mMouse->setEventCallback( this );

        const OIS::MouseState &mouseState = mMouse->getMouseState();
        mouseState.width  = mWindow->getWidth();
        mouseState.height = mWindow->getHeight();
    }

    // If possible create a buffered keyboard
    if( mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0 ) {
        mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) );
        mKeyboard->setEventCallback( this );
    }
}
Ejemplo n.º 6
0
void GameCore::initializeEventListeners()
{
    //compiled from ogre framework
    OIS::ParamList pl;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;

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




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

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



    mouse->setEventCallback(this);
    keyboard->setEventCallback(this);

    windowResized(renderWindow);
    Ogre::WindowEventUtilities::addWindowEventListener(renderWindow, this);


}
Ejemplo n.º 7
0
void OISManager::initialize() {
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
	OIS::ParamList pl;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;

	Client::getInstance().getOgreManager().getWindow()->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    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")));


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

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

	mouse->setEventCallback(this);
	keyboard->setEventCallback(this);
	
	// unsigned int width, height, depth;
 //    int left, top;
 //    Client::getInstance().getOgreManager().getWindow()->getMetrics(width, height, depth, left, top);
	windowResized(
		Client::getInstance().getOgreManager().getWindow());
    Ogre::WindowEventUtilities::addWindowEventListener(
    	Client::getInstance().getOgreManager().getWindow(), this);
 
    
    DEBUG("!!!!!!!!!!! OIS INITIATE DONE !!!!!!!!!!!");
}
Ejemplo n.º 8
0
void Game::InitializeOIS(bool useBufferedInput)
{
	//Set up logger
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");

	//Initialize OIS
	OIS::ParamList pl;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
 
	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
   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")));

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

	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, useBufferedInput ));
	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, useBufferedInput ));

	mKeyboard->setEventCallback(InputNotifier::GetInstance());
	mMouse->setEventCallback(InputNotifier::GetInstance());

	//Set initial mouse clipping size
	windowResized(mWindow);
}
Ejemplo n.º 9
0
	DInputEventQueue* DInputManager::registerWindow( DRenderWindow* wind, bool isExclusive )
	{
		EventContextMap::iterator i = mEventContextMap.find(wind);
		if (i != mEventContextMap.end())
		{
			return i->second.eventQueue;
		}
		// create a new OIS::InputManager
		OIS::ParamList pl;
		std::ostringstream wnd;
		wnd << (size_t)wind->getWindowHandle();
		pl.insert(std::make_pair(mPlatform, wnd.str()));
		if (!isExclusive)
		{
			// 非独占模式下鼠标可移出窗口之外
			pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_FOREGROUND"));    
			pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_NONEXCLUSIVE"));
		}

		// since no NULL will be returned, we do not check.
		// (OIS will throw exception)
		OIS::InputManager* mgr = OIS::InputManager::createInputSystem(pl);
		mgr->enableAddOnFactory(OIS::InputManager::AddOn_All);

		// since the ois's mouse event depend on its window size, so we must act
		// when the window size changed.
		wind->signalResized.connect(
			DBind(&DInputManager::onWindowResized, this, _1));

		DInputEventQueue* queue = new DInputEventQueue();
		DInputReceiver*	receiver = new DInputReceiver(mgr, queue);
		receiver->setWindowSize(wind->getWidth(), wind->getHeight());
		mEventContextMap.insert(std::make_pair(wind, EventContext(mgr, receiver, queue)));
		return queue;
	}
Ejemplo n.º 10
0
scInputManager::scInputManager( u32 handle, u32 width, u32 height, bool isExclusive /*= false*/ )
	: mInputMgr(0), mKeyboard(0), mMouse(0), mGuiInput(0),
	mKeyPressedLuaState(0), mKeyReleasedLuaState(0),
	mMouseMovedLuaState(0), mMousePressedLuaState(0), mMouseReleasedLuaState(0)
{
	OIS::ParamList pl;
    std::ostringstream windowHndStr;
    windowHndStr << handle;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

	// 鼠标键盘非独占模式
	if (!isExclusive)
	{
		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")));
	}

	mInputMgr = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputMgr->createInputObject(OIS::OISKeyboard, true));
	mMouse = static_cast<OIS::Mouse*>(mInputMgr->createInputObject(OIS::OISMouse, true));

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

	const OIS::MouseState &ms = mMouse->getMouseState();
	ms.width = width;
	ms.height = height;
}
Ejemplo n.º 11
0
	void InputManager::init(Ogre::RenderWindow* renderWindow, bool isNexclusive)
	{
		if (!mInputManager)
		{
			mRenderWindow = renderWindow;
			mIsNexclusive = isNexclusive;

			OIS::ParamList pl;
			size_t windowHnd = 0;
			std::ostringstream windowHndStr;

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

			if (!isNexclusive)
			{	
				// Under the non-exclusive mode mouse out of the window outside
				pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_FOREGROUND"));
				pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_NONEXCLUSIVE"));
				
				//::ShowCursor(false);
			}

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

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

			
			updateMouseExtents(mRenderWindow->getWidth(), mRenderWindow->getHeight());
		}		
	}
Ejemplo n.º 12
0
	bool Input::Start(Ogre::RenderWindow * win, bool exclusive)
	{
		window = win;
		OIS::ParamList pl;
		size_t windowHnd=0;
		std::ostringstream windowHndStr;
		window->getCustomAttribute("WINDOW", &windowHnd);
		windowHndStr << windowHnd;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
		if(!exclusive)
		{
			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")));
		}
		manager = OIS::InputManager::createInputSystem(pl);
		keyboard = static_cast<OIS::Keyboard*>(manager->createInputObject(OIS::OISKeyboard, true));
		mouse = static_cast<OIS::Mouse*>(manager->createInputObject(OIS::OISMouse, true));
		keyboard->setBuffered(true);
		mouse->setBuffered(true);
		keyboard->setEventCallback(this);
		mouse->setEventCallback(this);
		Ogre::WindowEventUtilities::addWindowEventListener(window, this);
		windowResized(window);
		running = true;
		return true;
	}
Ejemplo n.º 13
0
GameFrameListener::GameFrameListener( Ogre::RenderWindow* win ):
    m_Window( win ),

    m_InputManager( 0 ),
    m_Keyboard( 0 )
{
    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() ) );

#if defined __WIN32__
    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" ) ) );
#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" ) ) );
#endif

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

    m_Keyboard = static_cast< OIS::Keyboard* >( m_InputManager->createInputObject( OIS::OISKeyboard, true ) );
    m_Keyboard->setEventCallback( this );

    m_Mouse = static_cast< OIS::Mouse* >( m_InputManager->createInputObject( OIS::OISMouse, true ) );
    m_Mouse->setEventCallback( this );
    windowResized( m_Window );

    //Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener( m_Window, this );
}
Ejemplo n.º 14
0
void HrInputManager::CreateInputSystem()
{
	OIS::ParamList pl;
	size_t winHandle = 0;
	std::ostringstream winHandleStr;

	const HrWindowModulePtr& pWindowComponet = HrDirector::Instance()->GetWindowModule();
	size_t nWinHandle = (size_t)(pWindowComponet->GetWindowHWnd());
	winHandleStr << nWinHandle;

	pl.insert(std::make_pair("WINDOW", winHandleStr.str()));
	if (true)
	{
		pl.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND"));
		pl.insert(std::make_pair("w32_mouse", "DISCL_NONEXCLUSIVE"));
		pl.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND"));
		pl.insert(std::make_pair("w32_keyboard", "DISCL_NONEXCLUSIVE"));
	}

	m_pInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(m_pInputManager->createInputObject(OIS::OISKeyboard, true));
	mMouse = static_cast<OIS::Mouse*>(m_pInputManager->createInputObject(OIS::OISMouse, true));

	mMouse->getMouseState().width = pWindowComponet->GetWindowWidth();
	mMouse->getMouseState().height = pWindowComponet->GetWindowHeight();
	
	mKeyboard->setEventCallback(&m_inputEventListener);
	mMouse->setEventCallback(&m_inputEventListener);
}
Ejemplo n.º 15
0
void 
	TutorialApplication::initInput()
{
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
	OIS::ParamList pl;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;

	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	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")));

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

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

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

	//Set initial mouse clipping size
	windowResized(mWindow);
}
Ejemplo n.º 16
0
void Client::InitializeWindow() {
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
	OIS::ParamList pl;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;

	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
#ifdef DEBUG
	pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
	pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
#endif

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

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

	// Register for callback
	mKeyboard->setEventCallback(this);
	mMouse->setEventCallback(this);
	//mMouse->setBuffered(true);

	// Set initial mouse clipping size
	windowResized(mWindow);

	// Register as a Window listener
	Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

	// Register as Frame Listener
	mOgreRoot->addFrameListener(this);
}
Ejemplo n.º 17
0
void PCInputManager::load()
{
	// Create input system
	OIS::ParamList paramList;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
	Framework::instance()->getRenderWindow()->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	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")));
	m_inputManager = OIS::InputManager::createInputSystem(paramList);

	// Create mouse an keyboard input objects
	m_inputMouse = static_cast<OIS::Mouse*>(m_inputManager->createInputObject(OIS::OISMouse, true));
	m_inputKeyboard = static_cast<OIS::Keyboard*>(m_inputManager->createInputObject(OIS::OISKeyboard, true));

	// Clamp the mouse to the window
	unsigned int width, height, depth;
	int top, left;
	Framework::instance()->getRenderWindow()->getMetrics(width, height, depth, left, top);
	const OIS::MouseState &ms = m_inputMouse->getMouseState();
	ms.width = width;
	ms.height = height;

	m_inputKeyboard->setEventCallback(&m_listener);
	m_inputMouse->setEventCallback(&m_listener);

	m_inputData = new PCInputState;
}
Ejemplo n.º 18
0
void GameManager::init(void)
{

#if !defined(_DEBUG)
	mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
	mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif
	
	
	if (!mRoot->restoreConfig()) {
		if (!mRoot->showConfigDialog()) return;
	}
	
	mWindow = mRoot->initialise(true, CLIENT_DESCRIPTION " : Copyleft by Dae-Hyun Lee");

	mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "main");

	Ogre::OverlaySystem* mOverlaySystem = new Ogre::OverlaySystem();
	mSceneMgr->addRenderQueueListener(mOverlaySystem);
	
	mCamera = mSceneMgr->createCamera("main");

	mViewport = mWindow->addViewport(mCamera);
	mViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f));
	mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));

	mMapCamera = mSceneMgr->createCamera("MapCamera");
	mMapViewport = mWindow->addViewport(mMapCamera, 1, 0.79, 0.01, 0.2, 0.2);
	mMapViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f));
	mMapCamera->setAspectRatio(Real(mMapViewport->getActualWidth()) / Real(mMapViewport->getActualHeight()));
	mMapViewport->setOverlaysEnabled(false);
	mMapViewport->setShadowsEnabled(false);

	ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
	ResourceGroupManager::getSingleton().addResourceLocation("./", "FileSystem");
	ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
	OIS::ParamList pl;
	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	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")));
	mInputManager = OIS::InputManager::createInputSystem(pl);

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

	mKeyboard->setEventCallback(this);
	mMouse->setEventCallback(this);
		
	mRoot->addFrameListener(this);
}
Ejemplo n.º 19
0
//-------------------------------------------------------------------------------------
void BaseApplication::createFrameListener(void)
{

    mCamNode = mCamera -> getParentSceneNode();
    Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
    OIS::ParamList pl;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;

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

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

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

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

    //Set initial mouse clipping size
    windowResized(mWindow);

    //Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

    mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, mMouse, this);
    mTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    mTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    mTrayMgr->hideCursor();

    // create a params panel for displaying sample details
    Ogre::StringVector items;
    items.push_back("cam.pX");
    items.push_back("cam.pY");
    items.push_back("cam.pZ");
    items.push_back("");
    items.push_back("cam.oW");
    items.push_back("cam.oX");
    items.push_back("cam.oY");
    items.push_back("cam.oZ");
    items.push_back("");
    items.push_back("Filtering");
    items.push_back("Poly Mode");

    mDetailsPanel = mTrayMgr->createParamsPanel(OgreBites::TL_NONE, "DetailsPanel", 200, items);
    mDetailsPanel->setParamValue(9, "Bilinear");
    mDetailsPanel->setParamValue(10, "Solid");
    mDetailsPanel->hide();

    mRoot->addFrameListener(this);
    mDirection = Ogre::Vector3::ZERO;
    mMove = 250;
}
Ejemplo n.º 20
0
//------------------------------------------------------------------------------
Input::Input(unsigned long windowHandle)
	: mInputManager(0)
	, mKeyboard(0)
	, mMouse(0)
{
	std::ostringstream windowHndStr;
	OIS::ParamList pl;

	// Use OS mouse.
	windowHndStr << windowHandle;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

//#if DANGINE_PLATFORM == DANGINE_PLATFORM_WIN32
	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 DANGINE_PLATFORM == DANGINE_PLATFORM_LINUX
	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")));
#elif DANGINE_PLATFORM == DANGINE_PLATFORM_APPLE
	pl.insert(std::make_pair(
		std::string("osx_mouse_grab"),
		std::string("false")));
	pl.insert(std::make_pair(
		std::string("osx_mouse_hide"),
		std::string("false")));
#endif*/

	mInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(
		OIS::OISKeyboard, true));
	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(
		OIS::OISMouse, true));

	mKeyboard->setEventCallback(this);
	mMouse->setEventCallback(this);
}
Ejemplo n.º 21
0
    void
    setupInputManager() {
        const std::string HANDLE_NAME = "WINDOW";
        size_t windowHandle = 0;
        m_graphics.renderWindow->getCustomAttribute(HANDLE_NAME, &windowHandle);
        OIS::ParamList parameters;
        parameters.insert(std::make_pair(
            HANDLE_NAME,
            boost::lexical_cast<std::string>(windowHandle)
        ));
#if defined OIS_WIN32_PLATFORM
        parameters.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
        parameters.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_EXCLUSIVE")));
        parameters.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
        parameters.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
        parameters.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
        parameters.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("true")));
        parameters.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
        parameters.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
        m_input.inputManager = OIS::InputManager::createInputSystem(parameters);
        m_input.keyboard.init(m_input.inputManager);
        m_input.mouse.init(m_input.inputManager);
    }
Ejemplo n.º 22
0
void InputManager::initialise( Ogre::RenderWindow *renderWindow ) {
    if( !mInputSystem ) {
        // Setup basic variables
        OIS::ParamList paramList;    
        size_t windowHnd = 0;
        std::ostringstream windowHndStr;

        // Get window handle
        renderWindow->getCustomAttribute( "WINDOW", &windowHnd );

        // Fill parameter list
        windowHndStr << (unsigned int) windowHnd;
        paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );
		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")));
        // Create inputsystem
        mInputSystem = OIS::InputManager::createInputSystem( paramList );

        // If possible create a buffered keyboard
		if( mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0 ) {
            mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) );
            mKeyboard->setEventCallback( this );
        }

        // If possible create a buffered mouse
        if( mInputSystem->getNumberOfDevices(OIS::OISMouse) > 0 ) {
            mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) );
            mMouse->setEventCallback( this );

            // Get window size
            unsigned int width, height, depth;
            int left, top;
            renderWindow->getMetrics( width, height, depth, left, top );

            // Set mouse region
            this->setWindowExtents( width, height );
        }

        // If possible create all joysticks in buffered mode
        if( mInputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0 ) {
            mJoysticks.resize( mInputSystem->getNumberOfDevices(OIS::OISJoyStick) );

            itJoystick    = mJoysticks.begin();
            itJoystickEnd = mJoysticks.end();
            for(; itJoystick != itJoystickEnd; ++itJoystick ) {
                (*itJoystick) = static_cast<OIS::JoyStick*>( mInputSystem->createInputObject( OIS::OISJoyStick, true ) );
                (*itJoystick)->setEventCallback( this );
            }
        }
    }
}
Ejemplo n.º 23
0
	OISListener::OISListener(size_t handle,OISSubsystem* sys,bool grabMouse)
	{
		mSubsystem = sys;

		std::ostringstream windowHndStr;
		windowHndStr << handle;

		OIS::ParamList pl;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

		if(!grabMouse)
		{
		#ifdef 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
		}

		mInputManager = OIS::InputManager::createInputSystem(pl);
		mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
		mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
		mKeyboard->setEventCallback(this);
		mMouse->setEventCallback(this);
		const OIS::MouseState &ms = mMouse->getMouseState();
		ms.width = 800;
		ms.height = 600;
		setMousePosition(ms.width/2,ms.height/2);
	}
Ejemplo n.º 24
0
bool Game::initializeOIS() {
	//get the window handle;
	size_t windowHandle = 0;
	m_pWindow->getCustomAttribute("WINDOW", &windowHandle);

	std::ostringstream windowHandleStr;
	windowHandleStr << windowHandle;
	// create the input system
	OIS::ParamList pl;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHandleStr.str()));
#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
	m_pInputManager = OIS::InputManager::createInputSystem(pl);
	// create the keyboard
	m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputManager->createInputObject(OIS::OISKeyboard, m_BufferedKeys));
	m_pKeyboard->setEventCallback(this);

	// create the mouse
	m_pMouse = static_cast<OIS::Mouse*>(m_pInputManager->createInputObject( OIS::OISMouse, m_BufferedMouse));
	m_pMouse->setEventCallback(this);
	// tell OIS the range of mouse movement
	OISSetWindowSize();

	return true;
}//Game::initializeOIS
Ejemplo n.º 25
0
	InputHandlerOIS::InputHandlerOIS(unsigned int hWnd)
		:mInputManager(nullptr), mMouse(nullptr), mKeyboard(nullptr), mLastMouseUpdateFrame(0), mTimestampClockOffset(0)
	{
		mMouseSampleAccumulator[0] = 0;
		mMouseSampleAccumulator[1] = 0;
		mTotalMouseSamplingTime[0] = 1.0f / 125.0f; // Use 125Hz as initial pooling rate for mice
		mTotalMouseSamplingTime[1] = 1.0f / 125.0f;
		mTotalMouseNumSamples[0] = 1;
		mTotalMouseNumSamples[1] = 1;
		mMouseSmoothedAxis[0] = 0.0f;
		mMouseSmoothedAxis[1] = 0.0f;
		mMouseZeroTime[0] = 0.0f;
		mMouseZeroTime[1] = 0.0f;

		OIS::ParamList pl;
		std::ostringstream windowHndStr;
		windowHndStr << hWnd;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

#if defined BS_PLATFORM == BS_PLATFORM_WIN32
		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 BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_APPLE
		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);

		if (mInputManager->getNumberOfDevices(OIS::OISKeyboard) > 0)
		{
			mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
			mKeyboard->setEventCallback(this);
		}

		if (mInputManager->getNumberOfDevices(OIS::OISMouse) > 0)
		{
			mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
			mMouse->setEventCallback(this);
		}

		UINT32 numGamepads = mInputManager->getNumberOfDevices(OIS::OISJoyStick);
		for (UINT32 i = 0; i < numGamepads; i++)
		{
			mGamepads.push_back(GamepadData());
			GamepadData& gamepadData = mGamepads.back();

			gamepadData.gamepad = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, true));
			gamepadData.listener = bs_new<GamepadEventListener>(this, i);

			gamepadData.gamepad->setEventCallback(gamepadData.listener);
		}

		// OIS reports times since system start but we use time since program start
		mTimestampClockOffset = gTime().getStartTimeMs();
	}
Ejemplo n.º 26
0
void Input::initOis(
		OIS::KeyListener *pKeyListener,
		OIS::MouseListener *pMouseListener
	) {
	int64_t hWnd = 0;

	RenderEngine::Instance().m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);

    OIS::ParamList paramList;

    paramList.insert(
    		OIS::ParamList::value_type(
    		    "WINDOW", Ogre::StringConverter::toString(static_cast<int>(hWnd))));

  // TODO(lubosz): Only on debug
#ifdef WIN32
    /*
	paramList.insert(
    OIS::ParamList::value_type("w32_mouse", "DISCL_FOREGROUND"));
	paramList.insert(
    OIS::ParamList::value_type("w32_mouse", "DISCL_NONEXCLUSIVE"));
*/
#else
  paramList.insert(
    OIS::ParamList::value_type("x11_mouse_grab", "false"));
  paramList.insert(
    OIS::ParamList::value_type("x11_keyboard_grab", "false"));
#endif

    m_pInputMgr = OIS::InputManager::createInputSystem(paramList);

    m_pKeyboard = static_cast<OIS::Keyboard*>(
    		m_pInputMgr->createInputObject(OIS::OISKeyboard, true)
	);
    m_pMouse = static_cast<OIS::Mouse*>(
    		m_pInputMgr->createInputObject(OIS::OISMouse, true)
	);

    m_pMouse->getMouseState().height =
    		RenderEngine::Instance().m_pRenderWnd->getHeight();
    m_pMouse->getMouseState().width  =
    		RenderEngine::Instance().m_pRenderWnd->getWidth();

//    m_pMouse->getMouseState().clear();
//    OIS::MouseState::clear();


    m_pKeyboard->setEventCallback(pKeyListener);
    m_pMouse->setEventCallback(pMouseListener);
}
Ejemplo n.º 27
0
	void InputManager::initialise( Ogre::RenderWindow *renderWindow ) {
		if( !mInputSystem ) {
		    // Setup basic variables
		    OIS::ParamList paramList;
		    size_t windowHnd = 0;
		    std::ostringstream windowHndStr;

		    // Get window handle
	#if defined OIS_WIN32_PLATFORM
		    renderWindow->getCustomAttribute( "WINDOW", &windowHnd );
	#elif defined OIS_LINUX_PLATFORM
		    renderWindow->getCustomAttribute( "WINDOW", &windowHnd );
	#endif

		    // Fill parameter list
		    windowHndStr << windowHnd;
		    paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );


#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

		    // Create inputsystem
		    mInputSystem = OIS::InputManager::createInputSystem( paramList );

			mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) );
			mKeyboard->setEventCallback( this );

			mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) );
			mMouse->setEventCallback( this );

			// Get window size
			unsigned int width, height, depth;
			int left, top;
			renderWindow->getMetrics( width, height, depth, left, top );

			// Set mouse region
			this->setWindowExtents( width, height );

		}
	}
Ejemplo n.º 28
0
	void InputManager::createInput(size_t _handle)
	{
		std::ostringstream windowHndStr;
		windowHndStr << _handle;

		OIS::ParamList pl;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

#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

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

		mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
		mKeyboard->setEventCallback(this);

		mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
		mMouse->setEventCallback(this);
	}
Ejemplo n.º 29
0
void InputHandler::createSystem(bool exclusive) {
	OIS::ParamList pl;
	pl.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(m_hWnd)));
	if (!exclusive) {
		pl.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_NONEXCLUSIVE"));
		pl.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_FOREGROUND"));
	}

	m_ois = OIS::InputManager::createInputSystem( pl );
	mMouse = static_cast<OIS::Mouse*>(m_ois->createInputObject( OIS::OISMouse, true ));
	mKeyboard = static_cast<OIS::Keyboard*>(m_ois->createInputObject( OIS::OISKeyboard, true));
	mMouse->setEventCallback(this);
	mKeyboard->setEventCallback(this);
}
Ejemplo n.º 30
0
//-------------------------------------------------------------------------------------
bool BaseApplication::configure(void)
{

    // Show the configuration dialog and initialise the system
    // You can skip this and use root.restoreConfig() to load configuration
    // settings if you were sure there are valid ones saved in ogre.cfg
    if(mRoot->showConfigDialog())
    {
        // If returned true, user clicked OK so initialise
        // Here we choose to let the system create a default rendering window by passing 'true'
        mWindow = mRoot->initialise(true, "TutorialApplication Render Window");
        Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
        OIS::ParamList pl;
        size_t windowHnd = 0;
        std::ostringstream windowHndStr;
        mWindow->getCustomAttribute("WINDOW", &windowHnd);
        windowHndStr << windowHnd;
        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
        mInputManager = OIS::InputManager::createInputSystem( pl );
        mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
        mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));

        return true;
    }
    else
    {
        return false;
    }
}