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