コード例 #1
0
ファイル: FFConsoleDemo.cpp プロジェクト: azmeuk/OIS
    JoystickManager(InputManager* pInputMgr, EventHandler* pEventHdlr)
	: _pInputMgr(pInputMgr), _nCurrJoyInd(-1), _dMasterGain(0.5), _bAutoCenter(true)

    {
	  _bFFFound = false;
	  for( int nJoyInd = 0; nJoyInd < pInputMgr->getNumberOfDevices(OISJoyStick); ++nJoyInd )
	  {
		//Create the stick
		JoyStick* pJoy = (JoyStick*)pInputMgr->createInputObject( OISJoyStick, true );
		cout << endl << "Created buffered joystick #" << nJoyInd << " '" << pJoy->vendor()
			 << "' (Id=" << pJoy->getID() << ")";

		// Check for FF, and if so, keep the joy and dump FF info
		ForceFeedback* pFFDev = (ForceFeedback*)pJoy->queryInterface(Interface::ForceFeedback );
		if( pFFDev )
		{
		  _bFFFound = true;

		  // Keep the joy to play with it.
		  pJoy->setEventCallback(pEventHdlr);
		  _vecJoys.push_back(pJoy);

		  // Keep also the associated FF device
		  _vecFFDev.push_back(pFFDev);

		  // Dump FF supported effects and other info.
		  cout << endl << " * Number of force feedback axes : "
			   << pFFDev->getFFAxesNumber() << endl;
		  const ForceFeedback::SupportedEffectList &lstFFEffects =
			pFFDev->getSupportedEffects();
		  if (lstFFEffects.size() > 0)
		  {
			cout << " * Supported effects :";
			ForceFeedback::SupportedEffectList::const_iterator itFFEff;
			for(itFFEff = lstFFEffects.begin(); itFFEff != lstFFEffects.end(); ++itFFEff)
			  cout << " " << Effect::getEffectTypeName(itFFEff->second);
			cout << endl << endl;
		  }
		  else
			cout << "Warning: no supported effect found !" << endl;
		}
		else
		{
		  cout << " (no force feedback support detected) => ignored." << endl << endl;
		  _pInputMgr->destroyInputObject(pJoy);
		}
	  }
	}
コード例 #2
0
ファイル: MyFrameListener.cpp プロジェクト: bjerkins/GEDE2014
	// Constructor
	MyFrameListener(RenderWindow* win, Camera* cam, CylindricalEffect *cylEffect, SceneNode* ogreNode)
	{
		_cam = cam;
		_movementspeed = 10.0f;
		_camAngle = -1*Ogre::Math::HALF_PI;
		_ogreNode = ogreNode;
		_walkMagnitude = 0;
		_turnMagnitude = 0;
		_orientation = 0.0f;
		ParamList parameters;
		unsigned int windowHandle = 0;
		std::ostringstream windowHandleString;

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

		parameters.insert(std::make_pair("WINDOW", windowHandleString.str()));

		_inputManager = InputManager::createInputSystem(parameters);

		// cyl effect initialize
		_cylEffect = cylEffect;

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

		// Try to create joystick
		try {
			_joyStick = static_cast<OIS::JoyStick*>(_inputManager->createInputObject( OIS::OISJoyStick, true ));
			_joyStick->setEventCallback(this);
			std::cout << "Successfuly created Joystick";
		}
		catch(...) {
			std::cout << "Failed to initialize Joystick";
			_joyStick = 0;
		}

	}