Example #1
0
//-------------------------------------------------------------------------------------
void OgreBase::createFrameListener(void)
{

    
    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 ));

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

    

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

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

    OgreBites::InputContext inputContext;
    inputContext.mMouse = mMouse; 
    inputContext.mKeyboard = mKeyboard;
    mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, inputContext, 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);
}
Example #2
0
  void go(void)
  {
    // OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
    mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
    mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


    // 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
    if (!mRoot->restoreConfig()) {
      if (!mRoot->showConfigDialog()) return;
    }
    mWindow = mRoot->initialise(true, "Hello Professor : Copyleft Dae-Hyun Lee");

    // ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
	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()));
	mInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));

	mESCListener = new ESCListener(mKeyboard);
    mRoot->addFrameListener(mESCListener);

	mSceneMgr = mRoot->createSceneManager(ST_GENERIC);

    mCamera = mSceneMgr->createCamera("camera");
    mCamera->setPosition(0.0f, 200.0f, 300.0f);
    mCamera->lookAt(0.0f, 100.0f, 0.00f);
    mCamera->setNearClipDistance(5.0f);

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

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

    mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

    Entity* daehyunEntity = mSceneMgr->createEntity("Daehyun", "DustinBody.mesh");

    SceneNode* daehyunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    daehyunNode->attachObject(daehyunEntity);

    mRoot->startRendering();

    mInputManager->destroyInputObject(mKeyboard);
    OIS::InputManager::destroyInputSystem(mInputManager);

    delete mRoot;
  }
void InputController::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() ) );
 
        // Create inputsystem
        mInputSystem = OIS::InputManager::createInputSystem( paramList );
 
        // If possible create a buffered keyboard
        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0) {
        //if( mInputSystem->numKeyboards() > 0 ) {
        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
        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISMouse) > 0) {
        //if( mInputSystem->numMice() > 0 ) {
        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
        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0) {
        //if( mInputSystem->numJoySticks() > 0 ) {
        if (mInputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0) {
            //mJoysticks.resize( mInputSystem->numJoySticks() );
            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 );
            }
        }
    }
}
// -------------------------------------------------------------------------
void OgreBulletApplication::createFrameListener(void)
{
    mFrameListener = 0;

#if (OGRE_VERSION <  ((1 << 16) | (3 << 8) | 0))

    mInput = PlatformManager::getSingleton().createInputReader();
    //mInput->initialise(mWindow, false, false);

    mInputSystem = new EventProcessor();
    mInputSystem->initialise (mWindow);
    mInputSystem->startProcessingEvents();
    mInput = mInputSystem->getInputReader();


#else

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

    #if defined OIS_WIN32_PLATFORM
        mWindow->getCustomAttribute("WINDOW", &windowHnd);
    #elif defined OIS_LINUX_PLATFORM
        //mWindow->getCustomAttribute( "GLXWINDOW", &windowHnd );
		mWindow->getCustomAttribute( "WINDOW", &windowHnd );
    #endif    

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

    // Uncomment these two lines to allow users to switch keyboards via the language bar
    //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") ));

    mInputSystem  = InputManager::createInputSystem( pl );

    //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
    mInput = static_cast<Keyboard*>(mInputSystem->createInputObject( OISKeyboard, true ));
    mMouse = static_cast<Mouse*>(mInputSystem->createInputObject( OISMouse, true ));

    unsigned int width, height, depth;
    int left, top;
    mWindow->getMetrics(width, height, depth, left, top);

    const OIS::MouseState &ms = mMouse->getMouseState();
    ms.width = width;
    ms.height = height;

#endif //OGRE_VERSION not Eihort

    switchListener (*(mBulletListeners->begin()));
    mRoot->addFrameListener(this);

}
Example #5
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);
	}
	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();
	}
Example #7
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
Example #8
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_NONEXCLUSIVE")));
        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("false")));
        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);
    }
Example #9
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);
	}
Example #10
0
    OIS::InputManager* InputSystem::createInputSystem(Ogre::Root* p_root)
    {
        std::clog << "Initializing input system..." << std::endl;
        OIS::ParamList paramList;
        size_t windowHandle = 0;
        std::ostringstream windowHandleStr;
        p_root->getRenderTarget("main_window")->getCustomAttribute("WINDOW", &windowHandle);
        windowHandleStr << windowHandle;
        paramList.insert(std::make_pair(std::string("WINDOW"), windowHandleStr.str()));

        return OIS::InputManager::createInputSystem(paramList);
    }
Example #11
0
void App::initOIS()
{
    size_t windowHnd = 0;
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    std::ostringstream windowHndStr;
	windowHndStr << windowHnd;
	OIS::ParamList pl;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(pl);
    mKeyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
	mKeyboard->setEventCallback(this);
}
Example #12
0
	void OISServer::initialize(const ion_intptr windowhandle)
	{
		// TODO: resolve this ( a 64bit-issue)
		std::stringstream wnd;
		wnd << windowhandle;

		OIS::ParamList pl;
		pl.insert(std::make_pair(std::string("WINDOW"), wnd.str()));
		m_pInternaldata->m_pInputmanager=OIS::InputManager::createInputSystem(pl);

		enumerateDevices();
	}
Example #13
0
void InputManager::init( const device::IDevicePtr& device )
{
    if( !m_pInputSystem )
    {
        // Setup basic variables
        OIS::ParamList paramList;
        size_t windowHnd = 0;
        std::ostringstream windowHndStr;

        // Fill parameter list
        windowHndStr << (unsigned int) device->getWindowID();
        paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );

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

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

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

            // Get window size
            int left, top, width, height;
            device->getWindowRect(left,top,width,height);

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

        // If possible create all joysticks in buffered mode
        int joystickNum = m_pInputSystem->getNumberOfDevices(OIS::OISJoyStick);
        if(  joystickNum> 0 )
        {
            m_pJoysticks.resize( joystickNum );

            m_joystickIter    = m_pJoysticks.begin();
            m_joystickIterEnd = m_pJoysticks.end();
            for(; m_joystickIter != m_joystickIterEnd; ++m_joystickIter ) {
                (*m_joystickIter) = static_cast<OIS::JoyStick*>( m_pInputSystem->createInputObject( OIS::OISJoyStick, true ) );
                (*m_joystickIter)->setEventCallback( this );
            }
        }
    }
}
Example #14
0
InputHandler::InputHandler(Ogre::RenderWindow *renderWindow) : mRenderWindow(renderWindow) {
	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()));

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

	mCurrentKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false /* not buffered */ ));
}
CEGuiDemoFrameListener::CEGuiDemoFrameListener(CEGuiBaseApplication* baseApp, Ogre::RenderWindow* window, Ogre::Camera* camera, bool useBufferedInputKeys, bool useBufferedInputMouse)
{
    // OIS setup
    OIS::ParamList paramList;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;

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

    // fill param list
    windowHndStr << (unsigned int)windowHnd;
    paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

    // create input system
    d_inputManager = OIS::InputManager::createInputSystem(paramList);

    // create buffered keyboard
    //if (d_inputManager->getNumberOfDevices(OIS::OISKeyboard) > 0)
    if (d_inputManager->numKeyboards() > 0)
    {
        d_keyboard = static_cast<OIS::Keyboard*>(d_inputManager->createInputObject(OIS::OISKeyboard, true));
        d_keyboard->setEventCallback(this);
    }

    // create buffered mouse
    //if (d_inputManager->getNumberOfDevices(OIS::OISMouse) > 0)
    if (d_inputManager->numMice() > 0)
    {
        d_mouse = static_cast<OIS::Mouse*>(d_inputManager->createInputObject(OIS::OISMouse, true));
        d_mouse->setEventCallback(this);

        unsigned int width, height, depth;
        int left, top;

        window->getMetrics(width, height, depth, left, top);
        const OIS::MouseState& mouseState = d_mouse->getMouseState();
        mouseState.width = width;
        mouseState.height = height;
    }

    // store inputs we want to make use of
    d_camera = camera;
    d_window = window;

    // we've not quit yet.
    d_quit = false;

    // setup base app ptr
    d_baseApp = baseApp;
}
Example #16
0
    /**
     * @brief initialiseOIS initialises OIS
     * @return Always true.
     */
    bool initialiseOIS()
    {
        OIS::ParamList pl;
        size_t windowHandle = 0;

        renderSystem->getAutoCreatedWindow()->getCustomAttribute("WINDOW", &windowHandle);

        pl.insert(std::make_pair(std::string("WINDOW"), boost::lexical_cast<std::string>(windowHandle)));
    #if defined OIS_WIN32_PLATFORM
        //pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_BACKGROUND" )));
        //pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_EXCLUSIVE")));
        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("true")));
//        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("true")));
        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
        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));

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

        return true;
    }
Example #17
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);
}
Example #18
0
InputSystem::OISListener::OISListener(): mOIS(0), mMouse(0), mKeyboard(0)
{
	OIS_EXCEPTION_BEGIN
	ocInfo << "Initing OIS";

	mMgr = InputMgr::GetSingletonPtr();

	OIS::ParamList pl;

    // let the OIS know what window we have so that it can capture its events
	GfxSystem::WindowHandle hWnd = GfxSystem::GfxWindow::GetSingleton()._GetWindowHandle();
	pl.insert(OIS::ParamList::value_type("WINDOW", StringConverter::ToString(hWnd)));

	// let the standard mouse cursor be
	pl.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_BACKGROUND"));
	pl.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_NONEXCLUSIVE"));
	pl.insert(OIS::ParamList::value_type("x11_mouse_grab", "false"));
	pl.insert(OIS::ParamList::value_type("x11_mouse_hide", "true"));
	pl.insert(OIS::ParamList::value_type("x11_keyboard_grab", "false"));
	pl.insert(OIS::ParamList::value_type("XAutoRepeatOn", "true"));

	mOIS = OIS::InputManager::createInputSystem(pl);
	ocInfo << "OIS created";

	RecreateDevices();
	OIS_EXCEPTION_END
}
Example #19
0
	/**
	 * @internal
	 * @brief Initializes the class so it becomes valid.
	 *
	 * @return true if the initialization was ok | false otherwise
	 */
	bool InputManager::init()
	{
		// Check if the class is already initialized
		if ( isValid() )
			return true;
		
		// Variables to init OIS
		OIS::ParamList      paramList;
		size_t              windowHnd = 0;
		std::ostringstream  windowHndStr;
		
		// Fill params depending on the OS
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		{
			//paramList.insert( std::make_pair(std::string( "w32_mouse" ), std::string( "DISCL_BACKGROUND" ) ) );
			//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" )));
			paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
			
			
			// TODO: try -> Uncomment these two lines to allow users to switch keyboards via the language bar
			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") ));
		}
#else
		{	
			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
		
		// Get window handle
		windowHnd = GraphicsManager::getSingleton().getMainWindow().getWindowHandle();
		
		// Insert window handle in parameters
		windowHndStr << (unsigned int) windowHnd;
		//paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );   
		paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(windowHnd)));

		
		// Create OIS input manager
		m_pOISInputManager = OIS::InputManager::createInputSystem( paramList );
		
		// Init mouse and keyboard
		m_mouse.init( m_pOISInputManager );
		m_keyboard.init( m_pOISInputManager );
		
		// The class is now initialized
		m_bIsValid = true;
		
		return true;
	}
Example #20
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 );

		}
	}
Example #21
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);
}
Example #22
0
void ofxJoypad::setup(){
	ofAddListener(ofEvents().update, this, &ofxJoypad::update);
	OIS::ParamList pl;
	pl.insert(std::make_pair(std::string("WINDOW"), ""));

	try
	{
		//This never returns null.. it will raise an exception on errors
		inputManager = InputManager::createInputSystem(pl);

		inputManager->enableAddOnFactory(InputManager::AddOn_All);

		int numSticks = inputManager->getNumberOfDevices(OISJoyStick);
		for( int i = 0; i < numSticks; ++i )
		{
			JoyStick* joy= (JoyStick*)inputManager->createInputObject( OISJoyStick, true );
			joy->setEventCallback( this );
			stringstream msg;
			msg << "\n\nCreating Joystick " << i
			<< "\n\tName: " << joy->vendor()
			<< "\n\tAxes: " << joy->getNumberOfComponents(OIS_Axis)
			<< "\n\tSliders: " << joy->getNumberOfComponents(OIS_Slider)
			<< "\n\tPOV/HATs: " << joy->getNumberOfComponents(OIS_POV)
			<< "\n\tButtons: " << joy->getNumberOfComponents(OIS_Button)
			<< "\n\tVector3: " << joy->getNumberOfComponents(OIS_Vector3);
			ofLog(OF_LOG_NOTICE, msg.str());
			ofxPad pad;
			for(int i=0;i<joy->getNumberOfComponents(OIS_Axis);i++){
				pad.axisValAbs.push_back(0);
			}
			for(int i=0;i<joy->getNumberOfComponents(OIS_Button);i++){
				pad.btnsVal.push_back(false);
			}
			pad.joystick = joy;
			joysticks.push_back(pad);
		}
		if(numSticks==0){
			stringstream msg;
			msg << "NO JOYSTICKS CONNECTED" << std::endl;
			ofLog(OF_LOG_ERROR, msg.str());
		}
	}
	catch(OIS::Exception &ex)
	{
		stringstream msg;
		msg << "\nException raised on joystick creation: " << ex.eText << std::endl;
		ofLog(OF_LOG_ERROR, msg.str());
	}
};
Example #23
0
bool gkWindowAndroid::setupInput(const gkUserDefs& prefs)
{
	// OIS
	try
	{
#if 0
		size_t handle = getWindowHandle();
		if (handle == 0) 
		{
			gkPrintf("Window handle is null.");
			return false;
		}
#else
		size_t handle = 0;
#endif
		OIS::ParamList params;

		params.insert(std::make_pair("WINDOW", Ogre::StringConverter::toString(handle)));

		m_input = OIS::InputManager::createInputSystem(params);
		m_input->enableAddOnFactory(OIS::InputManager::AddOn_All);

		m_ikeyboard = (OIS::Keyboard*)m_input->createInputObject(OIS::OISKeyboard, true);  GK_ASSERT(m_ikeyboard);
		m_ikeyboard->setEventCallback(this);

		// TODO: Option for disabling accelration! Performance...
		try{
			m_iacc = (OIS::JoyStick*)m_input->createInputObject(OIS::OISJoyStick, true);
			m_iacc->setEventCallback(this);
			m_ijoysticks.push_back(m_iacc);

			gkJoystick* gkjs = new gkJoystick(0,0);
			m_joysticks.push_back(gkjs);
		} catch (OIS::Exception&){
			m_iacc=0;
		}

		m_itouch = (OIS::MultiTouch*)m_input->createInputObject(OIS::OISMultiTouch, true); GK_ASSERT(m_itouch);
		m_itouch->setEventCallback(this);

	}
	catch (OIS::Exception& e)
	{
		gkPrintf("%s", e.what());
		return false;
	}

	return true;
}
Example #24
0
void InputListener::startOIS()
{
  Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
  OIS::ParamList pl;
  size_t windowHnd = 0;
  std::ostringstream windowHndStr;
  this->_WormsApp->getWindow()->getCustomAttribute("WINDOW", &windowHnd);
  windowHndStr << windowHnd;
  pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
  this->_InputManager = OIS::InputManager::createInputSystem(pl);
  this->_Mouse = static_cast<OIS::Mouse*>(this->_InputManager->createInputObject( OIS::OISMouse, true));
  this->_Keyboard = static_cast<OIS::Keyboard*>(this->_InputManager->createInputObject( OIS::OISKeyboard, true));
  _Mouse->setEventCallback(this);
  _Keyboard->setEventCallback(this);
}
	MyFrameListener(RenderWindow* win, Ogre::Camera* Cam ){

		size_t windowHnd = 0;
		std::stringstream windowsHndStr;
		win->getCustomAttribute("WINDOW", &windowHnd);
		windowsHndStr << windowHnd;

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

		_man = OIS::InputManager::createInputSystem(pl);
		_key = static_cast<OIS::Keyboard*>(_man->createInputObject(OIS::OISKeyboard,false));
		_mouse = static_cast<OIS::Mouse*>(_man->createInputObject(OIS::OISMouse,false));
		_cam = Cam;
	}
Example #26
0
void Input::Initialize(Input::NativeHandle window, bool bExclusive)
{
	if (!g_OisInitCount++)
	{
		for (int i =0; i < MAX_KEY_STATES; ++i)
		{
			g_PreviousFrameKeyStates[i] = 0;
		}

		g_PreviousFrameMouseButtonState = false;

		HELIUM_ASSERT(!g_InputSystem);

		// Setup basic variables
		OIS::ParamList paramList;

#if HELIUM_OS_LINUX
		size_t windowHnd = reinterpret_cast<size_t>( window );
#else
		size_t windowHnd = *reinterpret_cast<size_t*>( window );
#endif
		std::ostringstream windowHndStr;
 
		// Fill parameter list
		windowHndStr << windowHnd;
		paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );
 
		if (!bExclusive)
		{
#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
		g_InputSystem = OIS::InputManager::createInputSystem( paramList );
		HELIUM_ASSERT(g_InputSystem);

		g_Keyboard = static_cast<OIS::Keyboard*>(g_InputSystem->createInputObject( OIS::OISKeyboard, false ));
		HELIUM_ASSERT(g_Keyboard);

		g_Mouse = static_cast<OIS::Mouse*>(g_InputSystem->createInputObject( OIS::OISMouse, false ));
		HELIUM_ASSERT(g_Mouse);
	}
}
Example #27
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()));

		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);
	}
void llm::InputListener::startOIS( Ogre::RenderWindow *window ) {
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");

	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()));

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

	m_pMouse = static_cast<OIS::Mouse*>(m_pInputManager->createInputObject( OIS::OISMouse, true ));
	m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputManager->createInputObject( OIS::OISKeyboard, true ));
}
MyFrameListener::MyFrameListener(Ogre::RenderWindow* win, Ogre::Camera* cam, Ogre::Viewport* viewport, Ogre::SceneNode* node, Ogre::Entity* ent){
    /* OIS будет инициализирован, используя список параметров, нам также нужен хендл
     * окна в форме строки для списка параметров; создаём три переменные для хранения данных:
     */
    OIS::ParamList parameters;
    unsigned int windowHandle = 0;
    std::ostringstream windowHandleString;

    // Получаем хендл окна рендера и преобразуем его в строку:
    win->getCustomAttribute("WINDOW", &windowHandle);
    windowHandleString << windowHandle;

    // Добавляем строку, содержащую хендл окна, в список параметров, используя ключ "WINDOW":
    parameters.insert( std::make_pair( "WINDOW", windowHandleString.str() ) );

    // Используем список параметров, чтобы создать InputManager:
    _InputManager = OIS::InputManager::createInputSystem(parameters);

    // С помощью менеджера ввода создаём клавиатуру:
    _Keyboard = static_cast<OIS::Keyboard*>( _InputManager->createInputObject(OIS::OISKeyboard, false) );

    // Мышь и камера
    _Cam = cam;
    _movementspeed = 50.0f;

    // Инициализируем мышь
    _Mouse = static_cast<OIS::Mouse*>( _InputManager->createInputObject( OIS::OISMouse, false ) );

    // Композиторы
    _viewport = viewport;
    _comp1 = false;
    _comp2 = false;
    _comp3 = false;
    _down1 = false;
    _down2 = false;
    _down3 = false;

    // Скорость перемещения и перемещаемый узел
    _WalkingSpeed = 50.0f;
    _node = node;

    // Извлекаем нужные состояния анимации
    _aniState = ent->getAnimationState("RunTop");
    _aniState->setLoop(false);
    _aniStateTop = ent->getAnimationState("RunBase");
    _aniStateTop->setLoop(false);
}
Example #30
0
	bool InputManager::Init( HWND hwnd, int width, int height )
	{
		OIS::ParamList pl;

		//:: Get stringed wnd handle
		std::ostringstream wnd;
		wnd << (size_t)hwnd;

		//:: Set up initialization params
		pl.insert( std::make_pair( std::string( "WINDOW" ), wnd.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" ) ) );

		//:: Create input manager
		mInputManager = OIS::InputManager::createInputSystem( pl );
		if( mInputManager == 0 )
		{
			HLOGERR( "Failed to initialize input system" );
			return false;
		}
		mInputManager->enableAddOnFactory( OIS::InputManager::AddOn_All );

		//:: Create keyboard device
		mKeyboard = (OIS::Keyboard*)mInputManager->createInputObject( OIS::OISKeyboard, true );
		if( mKeyboard == 0 )
		{
			HLOGERR( "Failed to initialize keyboard input" );
			return false;
		}
		mKeyboard->setEventCallback( this );

		//:: Create mouse device
		mMouse = (OIS::Mouse*)mInputManager->createInputObject( OIS::OISMouse, true );
		if( mMouse == 0 )
		{
			HLOGERR( "Failed to initialize mouse input" );
			return false;
		}
		mMouse->setEventCallback( this );

		const OIS::MouseState& ms = mMouse->getMouseState( );
		ms.width = width;
		ms.height = height;

		return true;
	};