本文整理汇总了C++中ois::Keyboard类的典型用法代码示例。如果您正苦于以下问题:C++ Keyboard类的具体用法?C++ Keyboard怎么用?C++ Keyboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Keyboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: capture
void InputHandler::capture()
{
if (keyboard == 0 && mouse == 0)
{
try {
keyboard = static_cast<OIS::Keyboard*>
(ois->createInputObject(OIS::OISKeyboard, true));
keyboard->setEventCallback(this);
mouse = static_cast<OIS::Mouse*>
(ois->createInputObject(OIS::OISMouse, true));
mouse->setEventCallback(this);
cout << "[libclois-lane] Keyboard and mouse acquired!" << endl;
} catch (OIS::Exception &e) {
cout << "[libclois-lane] " << e.eText << endl;
}
}
else
{
try {
keyboard->capture();
mouse->capture();
} catch (OIS::Exception &e) {
cout << "[libclois-lane] " << e.eText << endl;
keyboard = 0;
mouse = 0;
}
}
}
示例2: handleInput
void PendulumTest::handleInput(opal::real elapsedRealTime,
const SimulationEngine& engine)
{
OIS::Keyboard* keyboard = engine.getKeyboard();
// This variable can be used to keep keys from repeating too fast.
static Ogre::Real toggleTimer = 0;
if (toggleTimer >= 0)
{
toggleTimer -= elapsedRealTime;
}
// Toggle GUI.
if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
{
Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
getByName("Verve/TrialNumber");
if (debugOverlay->isVisible())
{
debugOverlay->hide();
mAgentDebugger->setDisplayEnabled(false);
}
else
{
debugOverlay->show();
mAgentDebugger->setDisplayEnabled(true);
}
toggleTimer = 0.5;
}
}
示例3: processInputs
bool OgreAppLogic::processInputs(Ogre::Real deltaTime)
{
OIS::Keyboard *keyboard = mApplication->getKeyboard();
if(keyboard->isKeyDown(OIS::KC_ESCAPE))
{
return false;
}
return true;
}
示例4: frameStarted
bool frameStarted(const Ogre::FrameEvent& evt)
{
if (mExit)
return false;
if (mWindow->isClosed())
return false;
mKeyboard->capture();
mMouse->capture();
if (mKeyboard->isKeyDown(OIS::KC_A) || mKeyboard->isKeyDown(OIS::KC_LEFT))
mCamera->moveRelative(Ogre::Vector3(-evt.timeSinceLastFrame*20, 0, 0));
if (mKeyboard->isKeyDown(OIS::KC_D) || mKeyboard->isKeyDown(OIS::KC_RIGHT))
mCamera->moveRelative(Ogre::Vector3(evt.timeSinceLastFrame*20, 0, 0));
if (mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_UP))
mCamera->moveRelative(Ogre::Vector3(0, 0, -evt.timeSinceLastFrame*20));
if (mKeyboard->isKeyDown(OIS::KC_S) || mKeyboard->isKeyDown(OIS::KC_DOWN))
mCamera->moveRelative(Ogre::Vector3(0, 0, evt.timeSinceLastFrame*20));
mGUI->injectFrameEntered(evt.timeSinceLastFrame);
return true;
}
示例5: OnUpdate
void SimplePlayerComponent::OnUpdate(double time_diff) {
OIS::Keyboard* k = InputManager::Get()->GetKeyboard();
if(mWASDEnabled || mArrowsEnabled) {
Ogre::Vector3 move(Ogre::Vector3::ZERO);
if((mWASDEnabled && k->isKeyDown(OIS::KC_W)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_UP))) {
move.z -= 1.0;
}
if((mWASDEnabled && k->isKeyDown(OIS::KC_S)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_DOWN))) {
move.z += 1.0;
}
if((mWASDEnabled && k->isKeyDown(OIS::KC_A)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_LEFT))) {
move.x -= 1.0;
}
if((mWASDEnabled && k->isKeyDown(OIS::KC_D)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_RIGHT))) {
move.x += 1.0;
}
if(move.length() > 0) {
move.normalise(); // do not move too fast :P
move = GetNode()->GetRotation() * move;
GetNode()->SetPosition(GetNode()->GetPosition() + move * time_diff * mMoveSpeed);
}
}
}
示例6: NewImGuiFrame
void GUIManager::NewImGuiFrame(float dt)
{
// Update screen size
int left, top, width, height;
gEnv->mainCamera->getViewport()->getActualDimensions(left, top, width, height); // output params
// Read keyboard modifiers inputs
OIS::Keyboard* kb = App::GetInputEngine()->GetOisKeyboard();
bool ctrl = kb->isKeyDown(OIS::KC_LCONTROL);
bool shift = kb->isKeyDown(OIS::KC_LSHIFT);
bool alt = kb->isKeyDown(OIS::KC_LMENU);
// Call IMGUI
m_imgui.NewFrame(dt, static_cast<float>(width), static_cast<float>(height), ctrl, alt, shift);
}
示例7: work
ret_code RTSState::work(const TimeDuration &elapsed)
{
injectCameraEvents();
OIS::Keyboard *keys = OgreContextManager::get()->getInputManager()->getKeyboard();
if (keys->isKeyDown(OIS::KeyCode::KC_F))
{
const TypeUnite *type = nullptr;
if (m_selectedUnitsCommands.availableBuilds().size() > 0)
{
type = *m_selectedUnitsCommands.availableBuilds().begin();
if(type != nullptr)
m_selectedUnitsCommands.addBuild(type, 1);
}
}
return ret_code::CONTINUE;
}
示例8: frameStarted
// frame listener
bool frameStarted(const FrameEvent &evt)
{
mKeyboard->capture();
// update physics simulation
dynamicsWorld->stepSimulation(evt.timeSinceLastFrame,50);
return mContinue;
}
示例9: frameStarted
bool frameStarted(const FrameEvent &evt)
{
// Fill Here ----------------------------------------------
if (mKeyboard->isKeyDown(OIS::KC_1))
mProfessorNode->setScale(1.0f, 1.0f, 1.0f);
else if (mKeyboard->isKeyDown(OIS::KC_2))
mProfessorNode->setScale(2.0f, 1.0f, 1.0f);
else if (mKeyboard->isKeyDown(OIS::KC_3))
mProfessorNode->setScale(3.0f, 1.0f, 1.0f);
else if (mKeyboard->isKeyDown(OIS::KC_E))
mProfessorNode->scale(1.01f, 1.0f, 1.0f);
else if (mKeyboard->isKeyDown(OIS::KC_I))
// 닌자 노드의 상속 노드를 설정
mNinjaNode->setInheritScale(!mNinjaNode->getInheritScale());
// --------------------------------------------------------
return true;
}
示例10: setupInputSystem
void 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);
try
{
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mKeyboard->setEventCallback(this);
//mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false));
//mJoy = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, false));
}
catch (const OIS::Exception &e)
{
throw new Exception(42, e.eText, "Application::setupInputSystem");
}
}
示例11: getInput
void GameState::getInput() {
if(!isPaused){
OIS::Keyboard* keyboard = OgreFramework::getSingletonPtr()->m_pKeyboard;
if (keyboard->isKeyDown(OIS::KC_Q)) {
physics->rotate(0, Ogre::Degree(3).valueRadians());
}
if (keyboard->isKeyDown(OIS::KC_E)) {
physics->rotate(0, Ogre::Degree(-3).valueRadians());
}
Ogre::Vector3 dir = PenguinNode->getOrientation() * Ogre::Vector3::UNIT_Z;
if (keyboard->isKeyDown(OIS::KC_W) || keyboard->isKeyDown(OIS::KC_UP)) {
physics->translate(0, 5.0f * dir[0], 0.0f, 5.0f * dir[2]);
}
if (keyboard->isKeyDown(OIS::KC_S) || keyboard->isKeyDown(OIS::KC_DOWN)) {
physics->translate(0, -5.0f * dir[0], 0.0f, -5.0f * dir[2]);
}
if (keyboard->isKeyDown(OIS::KC_A) || keyboard->isKeyDown(OIS::KC_LEFT)) {
physics->translate(0, 5.0f * dir[2], 0.0f, -5.0f * dir[0]);
}
if (keyboard->isKeyDown(OIS::KC_D) || keyboard->isKeyDown(OIS::KC_RIGHT)) {
physics->translate(0, -5.0f * dir[2], 0.0f, 5.0f * dir[0]);
}
if (keyboard->isKeyDown(OIS::KC_SPACE)) {
if(!graphics->getJumping() && physics->has_jumping()){
physics->applyForce(0, 0, 14000, 0);
graphics->playSound(0);
graphics->setJumping(true);
}
}
}
}
示例12: keyPressed
bool RenderState::keyPressed(const OIS::KeyEvent &keyEventRef)
{
OgreFramework* framework = OgreFramework::getSingletonPtr();
OIS::Keyboard* keyboard = framework->_keyboard;
OgreBites::SdkTrayManager* trayMgr = framework->_trayMgr;
OgreBites::SelectMenu* pMenu =
(OgreBites::SelectMenu*)trayMgr->getWidget("DisplayModeSelMenu");
if(_settingsMode == true)
{
if(keyboard->isKeyDown(OIS::KC_S))
{
if(pMenu->getSelectionIndex() + 1 < (int)pMenu->getNumItems())
pMenu->selectItem(pMenu->getSelectionIndex() + 1);
}
if(keyboard->isKeyDown(OIS::KC_W))
{
if(pMenu->getSelectionIndex() - 1 >= 0)
pMenu->selectItem(pMenu->getSelectionIndex() - 1);
}
if(keyboard->isKeyDown(OIS::KC_R))
{
steps = 20;
}
}
if(keyboard->isKeyDown(OIS::KC_ESCAPE))
{
// pushAppState(findByName("PauseState"));
exit();
return true;
}
if(keyboard->isKeyDown(OIS::KC_I))
{
if(_detailsPanel->getTrayLocation() == OgreBites::TL_NONE)
{
framework->_trayMgr->moveWidgetToTray(_detailsPanel,
OgreBites::TL_BOTTOMRIGHT,
0);
_detailsPanel->show();
}
else
{
framework->_trayMgr->removeWidgetFromTray(_detailsPanel);
_detailsPanel->hide();
}
}
if(keyboard->isKeyDown(OIS::KC_TAB))
{
_settingsMode = !_settingsMode;
return true;
}
if(_settingsMode && keyboard->isKeyDown(OIS::KC_RETURN) ||
keyboard->isKeyDown(OIS::KC_NUMPADENTER))
{
}
if(!_settingsMode || (_settingsMode && !keyboard->isKeyDown(OIS::KC_O)))
framework->keyPressed(keyEventRef);
return true;
}
示例13: processInputs
bool OgreAppLogic::processInputs(Ogre::Real deltaTime)
{
const Degree ROT_SCALE = Degree(40.0f);
const Real MOVE_SCALE = 5.0f;
Vector3 translateVector(Vector3::ZERO);
Degree rotX(0);
Degree rotY(0);
OIS::Keyboard *keyboard = mApplication->getKeyboard();
OIS::Mouse *mouse = mApplication->getMouse();
if(keyboard->isKeyDown(OIS::KC_ESCAPE))
{
return false;
}
//////// moves //////
// keyboard moves
if(keyboard->isKeyDown(OIS::KC_A))
translateVector.x = -MOVE_SCALE; // Move camera left
if(keyboard->isKeyDown(OIS::KC_D))
translateVector.x = +MOVE_SCALE; // Move camera RIGHT
if(keyboard->isKeyDown(OIS::KC_UP) || keyboard->isKeyDown(OIS::KC_W) )
translateVector.z = -MOVE_SCALE; // Move camera forward
if(keyboard->isKeyDown(OIS::KC_DOWN) || keyboard->isKeyDown(OIS::KC_S) )
translateVector.z = +MOVE_SCALE; // Move camera backward
if(keyboard->isKeyDown(OIS::KC_PGUP))
translateVector.y = +MOVE_SCALE; // Move camera up
if(keyboard->isKeyDown(OIS::KC_PGDOWN))
translateVector.y = -MOVE_SCALE; // Move camera down
if(keyboard->isKeyDown(OIS::KC_RIGHT))
rotX -= ROT_SCALE; // Turn camera right
if(keyboard->isKeyDown(OIS::KC_LEFT))
rotX += ROT_SCALE; // Turn camea left
rotX *= deltaTime;
rotY *= deltaTime;
translateVector *= deltaTime;
// mouse moves
const OIS::MouseState &ms = mouse->getMouseState();
if (ms.buttonDown(OIS::MB_Right))
{
translateVector.x += ms.X.rel * 0.003f * MOVE_SCALE; // Move camera horizontaly
translateVector.y -= ms.Y.rel * 0.003f * MOVE_SCALE; // Move camera verticaly
}
else
{
rotX += Degree(-ms.X.rel * 0.003f * ROT_SCALE); // Rotate camera horizontaly
rotY += Degree(-ms.Y.rel * 0.003f * ROT_SCALE); // Rotate camera verticaly
}
mCamera->moveRelative(translateVector);
mCamera->yaw(rotX);
mCamera->pitch(rotY);
return true;
}
示例14: frameStarted
bool frameStarted(const Ogre::FrameEvent& evt){
Ogre::Vector3 translate(0,0,0);
_Keyboard->capture();
if(_Keyboard->isKeyDown(OIS::KC_ESCAPE)){
return false;
}
if(_Keyboard->isKeyDown(OIS::KC_W)){
translate += Ogre::Vector3(0,0,-1);
}
if(_Keyboard->isKeyDown(OIS::KC_S)){
translate += Ogre::Vector3(0,0,1);
}
if(_Keyboard->isKeyDown(OIS::KC_A)){
translate += Ogre::Vector3(-1,0,0);
}
if(_Keyboard->isKeyDown(OIS::KC_D)){
translate += Ogre::Vector3(1,0,0);
}
/* Agregadas por mi */
if(_Keyboard->isKeyDown(OIS::KC_UP)){
_nodeRuedaSimple0->pitch(Ogre::Radian(-10));
_nodeRuedaSimple1->pitch(Ogre::Radian(-10));
_nodeRuedaSimple2->pitch(Ogre::Radian(-10));
_nodeRuedaSimple3->pitch(Ogre::Radian(-10));
_nodeRuedaSimple0->translate(0,0,5);
_nodeRuedaSimple1->translate(0,0,5);
_nodeRuedaSimple2->translate(0,0,5);
_nodeRuedaSimple3->translate(0,0,5);
_nodeChasisCarro->translate(0,0,5);
eje->translate(0.0,0.0,5.0);
desplazamiento += 5;
if (desplazamiento >= 6500 && i<25) {
eje->scale(1.1,1.1,1.1);
i++;
}
}
if(_Keyboard->isKeyDown(OIS::KC_RIGHT)){
/* _nodeRuedaSimple00->yaw(Ogre::Radian(5));
_nodeRuedaSimple11->yaw(Ogre::Radian(5));
_nodeRuedaSimple22->yaw(Ogre::Radian(5));
_nodeRuedaSimple33->yaw(Ogre::Radian(5));*/
_nodeRuedaSimple0->translate(-3,0,0);
_nodeRuedaSimple1->translate(-3,0,0);
_nodeRuedaSimple2->translate(-3,0,0);
_nodeRuedaSimple3->translate(-3,0,0);
_nodeChasisCarro->translate(-3,0,0);
}
if(_Keyboard->isKeyDown(OIS::KC_LEFT)){
/* _nodeRuedaSimple00->yaw(Ogre::Radian(-5));
_nodeRuedaSimple11->yaw(Ogre::Radian(-5));
_nodeRuedaSimple22->yaw(Ogre::Radian(-5));
_nodeRuedaSimple33->yaw(Ogre::Radian(-5)); */
_nodeRuedaSimple0->translate(3,0,0);
_nodeRuedaSimple1->translate(3,0,0);
_nodeRuedaSimple2->translate(3,0,0);
_nodeRuedaSimple3->translate(3,0,0);
_nodeChasisCarro->translate(3,0,0);
}
_Cam->moveRelative(translate*evt.timeSinceLastFrame * 600);
_Mouse->capture();
float rotX = _Mouse->getMouseState().X.rel * evt.timeSinceLastFrame* -1;
float rotY = _Mouse->getMouseState().Y.rel * evt.timeSinceLastFrame * -1;
_Cam->yaw(Ogre::Radian(rotX));
_Cam->pitch(Ogre::Radian(rotY));
return true;
}
示例15: WinMain
//.........这里部分代码省略.........
Shader* waterShader = Renderer::GetInstance()->CreateShader();
waterShader->SetSourceFile("Shaders/vert", "Shaders/frag");
Material waterMaterial(waterShader);
Texture2D* waterTexture = Renderer::GetInstance()->CreateTexture2DFromFile("Media/water.jpg");
waterMaterial.SetUniformTexture("waterTexture", waterTexture);
// Water node
Node waterNode;
waterNode.SetMaterial(&waterMaterial);
waterNode.SetMesh(&waterMesh);
Renderer::GetInstance()->GetSceneTree().AddNode(&waterNode);
Renderer::GetInstance()->CameraLookAt(Vector3(0.0f, 0.0f, -3.5f), Vector3::ZERO);
// Create the OIS system if present
#ifdef OIS_AVAILABLE
size_t windowHandle = (size_t)window.GetHandle();
OIS::ParamList paramList;
paramList.insert(pair<string, string>("WINDOW", to_string(windowHandle)));
#if defined OIS_WIN32_PLATFORM
paramList.insert(pair<string, string>("w32_mouse", "DISCL_FOREGROUND"));
paramList.insert(pair<string, string>("w32_mouse", "DISCL_NONEXCLUSIVE"));
#elif defined OIS_LINUX_PLATFORM
paramList.insert(pair<string, string>("x11_mouse_grab", "false"));
paramList.insert(pair<string, string>("x11_mouse_hide", "false"));
#endif
OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(paramList);
OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, false));
OIS::Mouse* mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject(OIS::OISMouse, false));
const OIS::MouseState& ms = mouse->getMouseState();
ms.width = window.GetWidth();
ms.height = window.GetHeight();
#endif
//Renderer::GetInstance()->SetRenderFillMode(RENDER_MODE_WIREFRAME);
float splashForce = 0.1f;
float damping = 0.999f;
float maxHeight = 0.15f;
while (window.IsOpen()) {
WindowEvent windowEvent;
if (window.PollEvents(windowEvent)) {
}
// Poll the mouse if OIS is present
#ifdef OIS_AVAILABLE
keyboard->capture();
if (keyboard->isKeyDown(OIS::KC_ESCAPE)) {
break;
}
mouse->capture();
// If we clicked on the surface, get the point on the water plane and send it to the shader
// for it to compute the ripples
if (mouse->getMouseState().buttonDown(OIS::MB_Left)) {
Vector3 pos = Renderer::GetInstance()->ScreenToWorldPoint(Vector2((float)mouse->getMouseState().X.abs, (float)mouse->getMouseState().Y.abs));