本文整理汇总了C++中ParamList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ParamList::insert方法的具体用法?C++ ParamList::insert怎么用?C++ ParamList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParamList
的用法示例。
在下文中一共展示了ParamList::insert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: windowResized
InputModule::InputModule()
{
ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
ENGINE->getWindow()->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
// needed in Linux to make debugging possible
#if 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
input = InputManager::createInputSystem(pl);
key = static_cast<Keyboard*> (
input->createInputObject(OISKeyboard, true));
mouse = static_cast<Mouse*> (input->createInputObject(OISMouse, true));
mouse->setEventCallback(this);
key->setEventCallback(this);
windowResized(ENGINE->getWindow());
Ogre::WindowEventUtilities::addWindowEventListener(ENGINE->getWindow(), this);
buildKeyMap();
menuMode = false;
}
示例2: Init
bool EditorFrameListener::Init(Ogre::RenderWindow* window)
{
/*GUI = GUISystem::GetInstance()->GetGui();
GUI->hidePointer();*/
using namespace OIS;
ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow = window;
window->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << (unsigned)windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = InputManager::createInputSystem( pl );
//Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
mKeyboard = static_cast<Keyboard*>(mInputManager->createInputObject( OISKeyboard, true ));
mMouse = static_cast<Mouse*>(mInputManager->createInputObject( OISMouse, true ));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
windowResized(mWindow);
return true;
}
示例3: setupOIS
void App::setupOIS()
{
using namespace OIS;
size_t windowHandle = 0;
std::stringstream windowHandleStr;
// Get the window handle.
mWindow->getCustomAttribute("WINDOW", &windowHandle);
// Convert to a string.
windowHandleStr << windowHandle;
// Create the input system using the parameter list.
ParamList pl;
pl.insert(std::make_pair(std::string("WINDOW"), windowHandleStr.str()));
inputMgr = InputManager::createInputSystem(pl);
// Create input objects.
keyboard = static_cast<Keyboard*>(inputMgr->createInputObject(OISKeyboard, true));
mouse = static_cast<Mouse*>(inputMgr->createInputObject(OISMouse, true));
// Register for events.
mouse->setEventCallback(this);
keyboard->setEventCallback(this);
// Set initial mouse clipping size.
windowResized(mWindow);
}
示例4: DisplayFrameListener
DisplayFrameListener(Ogre::RenderWindow* win):
m_Window(win),
m_InputManager(0),
m_Keyboard(0),
m_Timer(0)
{
using namespace OIS;
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing 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()));
m_InputManager = InputManager::createInputSystem(pl);
m_Keyboard = static_cast<Keyboard*>(m_InputManager->createInputObject(OIS::OISKeyboard, true));
m_Keyboard->setEventCallback(this);
//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(m_Window, this);
}
示例5: MainFrameListener
MainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr) : mCamera(cam),/* mTranslateVector(Vector3::ZERO),*/ mWindow(win), mStatsOn(true), mNumScreenShots(0),
mMoveScale(0.0f), mRotScale(0.0f), mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR),
mAniso(1), mSceneDetailIndex(0), mMoveSpeed(100), mRotateSpeed(36), mDebugOverlay(0),
mInputManager(0), mMouse(0), mKeyboard(0)/*, mJoy(0)*/ {
using namespace OIS;
mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
LogManager::getSingletonPtr()->logMessage("*** Initializing 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()));
mInputManager = InputManager::createInputSystem( pl );
//Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
mKeyboard = static_cast<Keyboard*>(mInputManager->createInputObject( OISKeyboard, true ));
mMouse = static_cast<Mouse*>(mInputManager->createInputObject( OISMouse, true ));
//Set initial mouse clipping size
windowResized(mWindow);
showDebugOverlay(true);
//Register as a Window listener
WindowEventUtilities::addWindowEventListener(mWindow, this);
// Populate the camera and scene manager containers
mCamNode = cam->getParentSceneNode();
mSceneMgr = sceneMgr;
// set the rotation and move speed
mRotate = 0.13;
mMove = 250;
// continue rendering
mContinue = true;
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
mDirection = Vector3::ZERO;
}
示例6:
// 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;
}
}
示例7: startOIS
void InputListener::startOIS ()
{
LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
LogManager::getSingletonPtr()->logMessage("*** Step 1 ***");
windows->getCustomAttribute("GXLWINDOW", &windowHnd);
LogManager::getSingletonPtr()->logMessage("*** Step 3 ***");
windowHndStr << windowHnd;
LogManager::getSingletonPtr()->logMessage("*** Step 4 ***");
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
LogManager::getSingletonPtr()->logMessage("*** Step 5 ***");
inputManager = InputManager::createInputSystem(pl);
mMouse = static_cast<Mouse*>(inputManager->createInputObject(OISMouse, true));
mKeyboard = static_cast<Keyboard*>(inputManager->createInputObject(OISKeyboard, true));
windowResized(windows);
WindowEventUtilities::addWindowEventListener(windows, this);
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
}
示例8: Initialize
void InputSystem::Initialize()
{
//init input manager
ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
GSYS->GetWindow()->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << (unsigned int)windowHnd;
pl.insert(make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = InputManager::createInputSystem(pl);
//create all devices
mKeyboard = static_cast<Keyboard*>(mInputManager->createInputObject(OISKeyboard, true));
mMouse = static_cast<Mouse*>(mInputManager->createInputObject(OISMouse, true));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
//set mouse clip area
const MouseState &ms = mMouse->getMouseState();
int w = GSYS->GetWindow()->getWidth();
int h = GSYS->GetWindow()->getHeight();
ms.width = w;
ms.height = h;
}
示例9: doStartup
void doStartup()
{
ParamList pl;
#if defined OIS_WIN32_PLATFORM
//Create a capture window for Input Grabbing
hWnd = CreateDialog( 0, MAKEINTRESOURCE(IDD_DIALOG1), 0,(DLGPROC)DlgProc);
if( hWnd == NULL )
{
std::cout << "Failed to create Win32 Window Dialog!" << std::endl;
exit(1);
}
ShowWindow(hWnd, SW_SHOW);
std::ostringstream wnd;
wnd << (size_t)hWnd;
pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));
//Default mode is foreground exclusive..but, we want to show mouse - so nonexclusive
// 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")));
#elif defined OIS_LINUX_PLATFORM
//Connects to default X window
if( !(xDisp = XOpenDisplay(0)) )
OIS_EXCEPT(E_General, "Error opening X!");
//Create a window
xWin = XCreateSimpleWindow(xDisp,DefaultRootWindow(xDisp), 0,0, 100,100, 0, 0, 0);
//bind our connection to that window
XMapWindow(xDisp, xWin);
//Select what events we want to listen to locally
XSelectInput(xDisp, xWin, StructureNotifyMask);
XEvent evtent;
do
{
XNextEvent(xDisp, &evtent);
} while(evtent.type != MapNotify);
std::ostringstream wnd;
wnd << xWin;
pl.insert(std::make_pair(std::string("WINDOW"), wnd.str()));
//For this demo, show mouse and do not grab (confine to window)
// 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")));
#elif defined OIS_APPLE_PLATFORM
// create the window rect in global coords
::Rect windowRect;
windowRect.left = 0;
windowRect.top = 0;
windowRect.right = 300;
windowRect.bottom = 300;
// set the default attributes for the window
WindowAttributes windowAttrs = kWindowStandardDocumentAttributes
| kWindowStandardHandlerAttribute
| kWindowInWindowMenuAttribute
| kWindowHideOnFullScreenAttribute;
// Create the window
CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWin);
// Color the window background black
SetThemeWindowBackground (mWin, kThemeBrushBlack, true);
// Set the title of our window
CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, "OIS Input", kCFStringEncodingASCII );
SetWindowTitleWithCFString( mWin, titleRef );
// Center our window on the screen
RepositionWindow( mWin, NULL, kWindowCenterOnMainScreen );
// Install the event handler for the window
InstallStandardEventHandler(GetWindowEventTarget(mWin));
// This will give our window focus, and not lock it to the terminal
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType( &psn, kProcessTransformToForegroundApplication );
SetFrontProcess(&psn);
// Display and select our window
ShowWindow(mWin);
SelectWindow(mWin);
std::ostringstream wnd;
wnd << (unsigned int)mWin; //cast to int so it gets encoded correctly (else it gets stored as a hex string)
std::cout << "WindowRef: " << mWin << " WindowRef as int: " << wnd.str() << "\n";
pl.insert(std::make_pair(std::string("WINDOW"), wnd.str()));
#endif
// dont grab the input
#ifndef WIN32
pl.insert(OIS::ParamList::value_type("x11_mouse_hide", "false"));
pl.insert(OIS::ParamList::value_type("XAutoRepeatOn", "false"));
pl.insert(OIS::ParamList::value_type("x11_mouse_grab", "false"));
pl.insert(OIS::ParamList::value_type("x11_keyboard_grab", "false"));
#else
pl.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_FOREGROUND"));
//.........这里部分代码省略.........
示例10: assert
OISDriver::OISDriver(Ogre::RenderWindow *window, bool exclusive)
{
assert(window);
size_t windowHnd;
window->getCustomAttribute("WINDOW", &windowHnd);
std::ostringstream windowHndStr;
ParamList pl;
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
// Set non-exclusive mouse and keyboard input if the user requested
// it.
if(!exclusive)
{
#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
}
#ifdef __APPLE_CC__
// Give the application window focus to receive input events
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
#endif
inputMgr = InputManager::createInputSystem( pl );
// Create all devices
keyboard = static_cast<Keyboard*>(inputMgr->createInputObject
( OISKeyboard, true ));
mouse = static_cast<Mouse*>(inputMgr->createInputObject
( OISMouse, true ));
// Set mouse region
const MouseState &ms = mouse->getMouseState();
ms.width = window->getWidth();
ms.height = window->getHeight();
// Set up the input listener
listener = new OISListener(*this);
keyboard-> setEventCallback(listener);
mouse-> setEventCallback(listener);
}
示例11: initialize
int initialize()
{
ostringstream wnd;
#if defined OIS_WIN32_PLATFORM
//Create a capture window for Input Grabbing
_hWnd = CreateDialog( 0, MAKEINTRESOURCE(IDD_DIALOG1), 0,(DLGPROC)DlgProc);
if( _hWnd == NULL )
OIS_EXCEPT(E_General, "Failed to create Win32 Window Dialog!");
ShowWindow(_hWnd, SW_SHOW);
wnd << (size_t)_hWnd;
#elif defined OIS_LINUX_PLATFORM
//Connects to default X window
if( !(_pXDisp = XOpenDisplay(0)) )
OIS_EXCEPT(E_General, "Error opening X!");
//Create a window
_xWin = XCreateSimpleWindow(_pXDisp,DefaultRootWindow(_pXDisp), 0,0, 100,100, 0, 0, 0);
//bind our connection to that window
XMapWindow(_pXDisp, _xWin);
//Select what events we want to listen to locally
XSelectInput(_pXDisp, _xWin, StructureNotifyMask);
//Wait for Window to show up
XEvent event;
do { XNextEvent(_pXDisp, &event); } while(event.type != MapNotify);
wnd << _xWin;
#endif
// Create OIS input manager
ParamList pl;
pl.insert(make_pair(string("WINDOW"), wnd.str()));
_pInputMgr = InputManager::createInputSystem(pl);
cout << _pInputMgr->inputSystemName() << " created." << endl;
// Create the event handler.
_pEventHdlr = new EventHandler(this);
// Create a simple keyboard
_pKeyboard = (Keyboard*)_pInputMgr->createInputObject( OISKeyboard, true );
_pKeyboard->setEventCallback( _pEventHdlr );
// Create the joystick manager.
_pJoystickMgr = new JoystickManager(_pInputMgr, _pEventHdlr);
if( !_pJoystickMgr->wasFFDetected() )
{
cout << "No Force Feedback device detected." << endl;
_nStatus = 1;
return _nStatus;
}
// Create force feedback effect manager.
_pEffectMgr = new EffectManager(_pJoystickMgr, _nEffectUpdateFreq);
// Initialize the event handler.
_pEventHdlr->initialize(_pJoystickMgr, _pEffectMgr);
_bIsInitialized = true;
return _nStatus;
}
示例12: updatePadList
void ofxGamepadHandler::updatePadList() {
#ifdef USE_OIS
try {
ParamList pl;
#if defined OIS_WIN32_PLATFORM
if(hWnd == 0)
{
HWND windowHandle = FindWindow(NULL, L"gamepadExampleApp");
std::ostringstream wnd;
wnd << (size_t)windowHandle;
pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));
}
#endif
InputManager* inputManager=InputManager::createInputSystem(pl);
gamepadList padsOld=gamepads;
std::vector<tempPad> sticks;
//gamepads.clear();
int numPads = inputManager->getNumberOfDevices(OISJoyStick);
for( int i = 0; i < numPads; i++ ) {
JoyStick* js = (JoyStick*)inputManager->createInputObject(OISJoyStick, true );
sticks.push_back(tempPad(js));
}
std::vector<tempPad>::iterator sIt = sticks.begin();
while(sIt!=sticks.end()) {
gamepadList::iterator gIt = padsOld.begin();
while(gIt!=padsOld.end()) {
if((*sIt).stick->vendor() == (*gIt)->name) {
ofPtr<ofxGamepadOIS> p = *gIt;
p->updateJoystick((*sIt).stick);
gamepadsNew.push_back(p);
padsOld.erase(gIt);
(*sIt).handled = true;
break;
}
++gIt;
}
++sIt;
}
sIt = sticks.begin();
while(sIt!=sticks.end()) {
if(!(*sIt).handled)
gamepadsNew.push_back(ofPtr<ofxGamepadOIS>(new ofxGamepadOIS((*sIt).stick)));
++sIt;
}
lock();
if(oisInputManager != NULL) {
oisInputManager->destroyInputSystem(oisInputManager);
}
unlock();
oisInputManager = inputManager;
} catch(OIS::Exception &ex) {
stringstream msg;
msg << "\nException raised on joystick creation: " << ex.eText << std::endl;
ofLog(OF_LOG_ERROR, msg.str());
}
#elif defined(TARGET_LINUX)
//check for joysticks
ofFile file;
for(int i=0; i<32; i++) {
file.open("/dev/input/js"+ofToString(i));
if(file.exists() && find(activeIDs.begin(), activeIDs.end(), i) == activeIDs.end()) {
try {
gamepadsNew.push_back(ofPtr<ofxGamepad>(new ofxGamepadLinux(file.getAbsolutePath())));
activeIDs.push_back(i);
} catch(std::exception& err) {
ofLog(OF_LOG_ERROR, "could not create new gamepad");
}
}
}
#else
ofLog(OF_LOG_ERROR, "ofxGamepad says: sorry, looks like your system is not supported...");
#endif
}