コード例 #1
0
ファイル: OgreWiiApp.cpp プロジェクト: mcleanjusten/wiimpp
void OgreWiiApp::setupInputSystem()
{
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;
    OIS::ParamList pl;
    RenderWindow *win = mRoot->getAutoCreatedWindow();

    win->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    mInputManager = OIS::InputManager::createInputSystem(pl);
    int nJoys = mInputManager->numJoySticks();
    try
    {
        mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
        mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
        for (int i=0; i < nJoys; ++i)
        {
          OIS::JoyStick* joy = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, true));
          mJoys[String(joy->vendor())] = joy;
        }
    }
    catch (const OIS::Exception &e)
    {
        throw new Exception(42, e.eText, "Application::setupInputSystem");
    }

}
コード例 #2
0
// Init
void OisFramework::init(OisFrameworkInitHelper* initHelper)
{
	// If initHelper is nil, stop
	if (!initHelper)
		return;
	// Shut down the previous init
	shutdown();
	// Param list
	OIS::ParamList pl;
	// Set window handler
	pl.insert(std::make_pair(std::string("WINDOW"), utils::t2str(initHelper->getWindowHnd())));
	// If the input need to be non-exclusive add some settings
	if (!initHelper->isInputExlusive())
	{
#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
	}
	// Create the input system
	mInputManager = OIS::InputManager::createInputSystem(pl);
	// Create Keyboard
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
	if (mKeyboard)
		mKeyboard->setEventCallback(this);
	// Create Mouse
	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
	if (mMouse)
		mMouse->setEventCallback(this);
	// Create joysticks
	for (int i = 0; i < mInputManager->getNumberOfDevices(OIS::OISJoyStick); ++i)
	{
		OIS::JoyStick* joystick = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, true));
		if (joystick)
		{
			joystick->setEventCallback(this);
			mJoySticks.push_back(joystick);
		}
	}
}
コード例 #3
0
	DInputReceiver::DInputReceiver( OIS::InputManager* inputMgr, DInputEventQueue* targetQueue ) : 
		mTargetQueue(targetQueue)
	{
		mKeyboard = (OIS::Keyboard*)inputMgr->createInputObject(OIS::OISKeyboard, true);
		mKeyboard->setEventCallback(this);
		mMouse = (OIS::Mouse*)inputMgr->createInputObject(OIS::OISMouse, true);
		mMouse->setEventCallback(this);
		
		uint16 devCount = inputMgr->getNumberOfDevices(OIS::OISJoyStick);
		for(uint16 i = 0; i < devCount; ++i)
		{
			OIS::JoyStick* tmp;
			tmp = (OIS::JoyStick*)inputMgr->createInputObject(OIS::OISJoyStick, true);
			tmp->setEventCallback(this);
			mJoyStickIndexMap[tmp] = i;
			mJoySticks.push_back(tmp);
		}
	}
コード例 #4
0
ファイル: joy.cpp プロジェクト: dustyco/sfmlframework
bool App::loop (int w, int h, double t)
{
	joystick->capture();
	
	cout << "============== Event ==============" << endl;
	cout << js.mButtons.size() << " buttons" << endl;
	cout << js.mAxes.size() << " axes" << endl;
	
	return true;
}
コード例 #5
0
ファイル: joy.cpp プロジェクト: dustyco/sfmlframework
bool App::setup ()
{
	// Set up the input manager
	input_manager = OIS::InputManager::createInputSystem(window.getSystemHandle());
	
	// Joystick
	cout << input_manager->getNumberOfDevices(OIS::OISJoyStick) << " joysticks" << endl;
	OIS::DeviceList::iterator it = input_manager->listFreeDevices().begin();
	OIS::DeviceList::iterator end = input_manager->listFreeDevices().end();
	for (; it!=end; it++) {
		cout << it->first << ", " << it->second << endl;
	}
	
	joystick = static_cast<OIS::JoyStick*>(input_manager->createInputObject(OIS::OISJoyStick, true));
	joystick->setEventCallback(this);
	
	return true;
}