void PauseMenuMode::Start() { mButtonPressed = -1; // get the last frame rendered glReadBuffer(GL_FRONT); //glPixelStorei(GL_PACK_ALIGNMENT,1); unsigned char *buf = (unsigned char *)malloc(sizeof(char) * 3 * mGameWindow->GetWidth() * mGameWindow->GetHeight()); glReadPixels(0, 0, mGameWindow->GetWidth(), mGameWindow->GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, buf); // bind it to a texture glGenTextures(1, &mBackgroundTexture); glBindTexture(GL_TEXTURE_2D, mBackgroundTexture); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, mGameWindow->GetWidth(), mGameWindow->GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, buf); free(buf); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); mNextMode = NULL; InputManager *im = mGameWindow->GetInputManager(); im->AddKeyEvent(&mResume, SDLK_ESCAPE); im->AddMouseEvent(&mClick, IM_MOUSE_LEFT_BUTTON); im->ResetAllInputEvents(); mGameWindow->SetOrthographicProjection(); }
void Character::update(InputManager& inputManager, b2World* world) { #ifdef __WIN32__ if (inputManager.isKeyPressed(SDLK_UP)) { jump(); } if (inputManager.isKeyPressed(SDLK_DOWN)) { slide(); } if (inputManager.isKeyReleased(SDLK_UP)) { fall(); } if (inputManager.isKeyReleased(SDLK_DOWN)) { stopSlide(); } #endif #ifdef __ANDROID__ if (inputManager.isKeyPressed(SDL_FINGERDOWN)) { jump(); } #endif }
void CommandMapper::buildCommandMapping() { ConfigurationManager* cfgMgr = ConfigurationManager::getSingletonPtr(); InputManager* inputMgr = InputManager::getSingletonPtr(); // First get the movement commands const NameValuePairList& commands = cfgMgr->getSettings("Movement keys"); for (NameValuePairList::const_iterator it = commands.begin(); it != commands.end(); it++) { // Split the path at the ',' character StringVector keys = Ogre::StringUtil::split(it->second, ","); for (size_t i = 0; i < keys.size(); i++) { mMovementCommands[inputMgr->getScanCode(keys[i])] = getMovement(it->first); LOG_MESSAGE(Logger::UI, Ogre::String("Key ") + keys[i] + " (" + StringConverter::toString(inputMgr->getScanCode(keys[i])) + ") is assigned to movement " + it->first +" (" + StringConverter::toString(getMovement(it->first))+")"); } } buildCommandMap(mKeyGlobalActions, cfgMgr->getSettings("Action keys")); buildCommandMap(mKeyMovementControlState, cfgMgr->getSettings("MovementController keys")); buildCommandMap(mKeyFreeflightControlState, cfgMgr->getSettings("FreeflightController keys")); buildCommandMap(mKeyDialogControlState, cfgMgr->getSettings("DialogController keys")); buildCommandMap(mKeyCombatControlState, cfgMgr->getSettings("CombatController keys")); buildCommandMap(mKeyCutsceneControlState, cfgMgr->getSettings("CutsceneController keys")); }
bool UIInputComponent::isButtonPressed(int width, int height){ InputManager* input = InputManager::getInstance(); if (input->isMouseDown(MOUSE_LEFT)){ //get mouse position int x, y; x = input->getMouseX(); y = input->getMouseY(); //mouse is left of button if (x < uiObjectRef->posX) return false; //mouse is right of the button else if (x > uiObjectRef->posX + width) return false; //mouse above the button else if (y < uiObjectRef->posY) return false; //mouse below the button else if (y > uiObjectRef->posY + height) return false; else{ return true; } } return false; }
/************************************************************************* * Application::go() ************************************************************************* * This function starts the program doing it's thing. * * Returns: EXIT_SUCCESS if the program finished successfully, or some * error code if it didn't. *************************************************************************/ int Application::go() { // Set working directory to executable's directory setCurrentWorkingDirectory(); // Load config.ini. loadConfigIni(); // Initialise Ogre. if (!initOgre()) return EXIT_FAILURE; createScene(); // Create the Input Manager InputManager *inputManager = InputManager::getSingletonPtr(); inputManager->initialise(ogrePtrs.window); // Create the Main Menu game state states.push_back(new MainMenuState(ogrePtrs, inputManager)); // Set it as the active state activeState = states.back(); activeState->enter(); // Start main program loop. mainLoop(); // Program finished successfully. return EXIT_SUCCESS; }
void PauseMenuMode::Update(float timeElapsed) { if (mResume.IsPressed()) mNextMode = mWorldMode; if (mClick.IsPressed()) { InputManager *im = mGameWindow->GetInputManager(); int mouseX = im->GetMouseX(); int mouseY = im->GetMouseY(); mButtonPressed = -1; for (int i = 0; i < NUM_PAUSE_BUTTONS; ++i) { if (mButtons[i].IsIn(mouseX, mouseY)) { mButtonPressed = i; } } } else { if (mButtonPressed == BTN_RESUME) { mNextMode = mWorldMode; } else if (mButtonPressed == BTN_OPTIONS) { // TODO: add options menu } else if (mButtonPressed == BTN_QUIT) { mNextMode = mMainMenuMode; } mButtonPressed = -1; } }
void Player::Update(ALLEGRO_EVENT ev, InputManager input) { input.Update(); pAnimation.IsActive() = true; if(input.IsKeyDown(ALLEGRO_KEY_DOWN)) { direction = Direction::Down; position.second += moveSpeed; } else if(input.IsKeyDown(ALLEGRO_KEY_UP)) { direction = Direction::Up; position.second -= moveSpeed; } else if(input.IsKeyDown(ALLEGRO_KEY_LEFT)) { direction = Direction::Left; position.first -= moveSpeed; } else if(input.IsKeyDown(ALLEGRO_KEY_RIGHT)) { direction = Direction::Right; position.first += moveSpeed; } else pAnimation.IsActive() = false; pAnimation.CurrentFrame().second = direction; pAnimation.Position() = position; ssAnimation.Update(pAnimation); }
void SceneManager::Start() { #ifdef WINDOWS QueryPerformanceFrequency(&m_frequency); QueryPerformanceCounter(&m_t1); #else // Start linux timer here //gettimeofday(&m_t1,NULL); gettimeofday(&m_t1, &m_tZone); gettimeofday(&m_t2, &m_tZone); #endif float lol = 0; InputManager* IM = InputManager::GetInstance(); GraphicsManager* GM = GraphicsManager::GetInstance(); while (m_isRunning) { float dt = GetDeltaTime(); GM->Update(dt); IM->Update(); m_activeScene->Update(dt); m_activeScene->Render(dt); // //setbuf(stdout, NULL); //lol += dt; //if (lol > 0.5f) //{ // printf("FPS: %f | Delta: %f \n" , 1.0f / dt,dt); // lol = 0; //} } }
//----------------------------------------------------------------------------// InputManager* InputManager::createInputSystem( ParamList ¶mList ) { if( g_Singleton ) OIS_EXCEPT( E_Duplicate, "An Input Manager Already Exists" ); InputManager* im = 0; #if defined OIS_WIN32_PLATFORM im = new Win32InputManager(); #elif defined OIS_XBOX_PLATFORM im = new XBoxInputManager(); #elif defined OIS_LINUX_PLATFORM im = new LinuxInputManager(); #else OIS_EXCEPT(E_General, "No platform library.. check build platform defines!"); #endif try { im->_initialize(paramList); } catch(...) { delete im; throw; //rethrow } g_Singleton = im; return im; }
void ChooseMap<al_b,al_f>::showSection(InputManager<ALLEGRO_EVENT,ALLEGRO_KEYBOARD_STATE> &input,Maps<al_b> &m,Player<al_b> &p,bool st){ m.showBackground(); al_draw_text(this->_font30, al_map_rgb(0,0,0), 335, 130, 0, "Escoge un mapa"); for(int i = 0;i < 3;i++){ m.loadMap(3,i); for(int y = 0; y<m.getHeight();y++){ for(int x = 0;x<m.getWidth();x++){ //al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(255,255,255)); switch(m.getPositionMap(x,y)){ case 'p': al_draw_scaled_bitmap(this->_block, 145, 171, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 'j': case 'g': case 'e': al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(255,255,255)); break; case 'c': al_draw_scaled_bitmap(this->_block, 258, 20, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 'd': al_draw_scaled_bitmap(this->_block, 37, 20, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 's': al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(236,236,236)); break; } } } } m.setLevel(input.getX(0)); al_draw_rectangle(80+(250*input.getX(0)), 200, 320+(250*input.getX(0)), 370, al_map_rgb(140,40,40),5); al_draw_filled_rectangle(360, 385, 540, 430, al_map_rgb(20,20,20)); al_draw_text(this->_font20, al_map_rgb(255,255,255), 395, 390, 0, "Seleccionar"); }
//----------------------------------------------------------------------------// InputManager* InputManager::createInputSystem( ParamList ¶mList ) { InputManager* im = 0; #if defined OIS_SDL_PLATFORM im = new SDLInputManager(); #elif defined OIS_WIN32_PLATFORM im = new Win32InputManager(); #elif defined OIS_XBOX_PLATFORM im = new XBoxInputManager(); #elif defined OIS_LINUX_PLATFORM im = new LinuxInputManager(); #elif defined OIS_APPLE_PLATFORM im = new MacInputManager(); #else OIS_EXCEPT(E_General, "No platform library.. check build platform defines!"); #endif try { im->_initialize(paramList); } catch(...) { delete im; throw; //rethrow } return im; }
void MainLoop(void) { InputManager* inputMgr = new InputManager(); GSceneManager* sceneMgr = new GSceneManager(inputMgr); DAssetsManager* dataMgr = new DAssetsManager(sceneMgr); dataMgr->loadAssetGroup(0); PPhysicsManager* physicsMgr = new PPhysicsManager(sceneMgr); GRendering* renderer = new GRendering(sceneMgr); glfwSwapInterval(0); do{ // Erfasse Eingaben inputMgr->captureInput(); // Physikberechnungen ausführen physicsMgr->performPhysics(); renderer->draw(); // Swap buffers glfwSwapBuffers(); countFPS(); } // Check if the ESC key was pressed or the window was closed while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS && glfwGetWindowParam( GLFW_OPENED ) ); }
void QuaternionTest::Update(float deltaTime) { quat y1 = quat(vec3(0.0, 0.0, 0.0)); quat y2 = quat(vec3(0.0, M_PI, 0.0)); quat x1 = quat(vec3(-M_PI, 0.0, 0.0)); quat x2 = quat(vec3(0.0, 0.0, 0.0)); InputManager* inputManager = InputManager::GetInstance(); if (inputManager->IsLeftClicked()) { _counterY += inputManager->GetMouseDX() * deltaTime; if (_counterY > 2.0) _counterY -= 2.0; if (_counterY < 0.0) _counterY += 2.0; //std::cout << "_counterY: " << _counterY << "\n"; _counterX += inputManager->GetMouseDY() * deltaTime * 0.1; if (_counterX > 0.5) _counterX = 0.5; if (_counterX < -0.5) _counterX = -0.5; //_orientation = mix(y1, y2, _counterY) * mix(x1, x2, _counterX); } }
void Selection::selectUnity(sf::RenderWindow *win,InputManager &input) { sf::IntRect mouse(input.mPositionX(),input.mPositionY(),10,10); if(input.mouseButtons(sf::Mouse::Left)) { for(int sLoop = 0; sLoop < count; sLoop++) { if(mouse.intersects(playerSelection[sLoop])) { nSelection = sLoop; } } } if(input.mouseButtons(sf::Mouse::Left)) { if(mouse.intersects(playerSelection[nSelection])) { if(!isSelected) isSelected = true; else isSelected = false; } } if(isSelected) drawSelection(win,SELECT); }
void FirstLevelState::Update(float dt) { map.Update(dt); InputManager input = InputManager::GetInstance(); quitRequested = (input.IsKeyDown(ESCAPE_KEY) || input.IsQuitRequested()); UpdateArray(dt); CheckMovementCollisions(); }
WINTERMOON_BEGIN_NAMESPACE EventListener::EventListener() { Root* root = Root::instance(); InputManager* input = root->inputManager(); input->addListener(this); }
void Map::cursorPosCallback(const InputManager& input) { if (input.getMouse().m_isLeftMouseButtonDown) { glm::ivec2 cursorDelta = input.getMouse().getCursorDelta(); move(cursorDelta, 0); } }
void InputManager::mouseScroll_callback(GLFWwindow* window, double xOffset, double yOffset) { InputManager* inputManager = InputManager::GetInstance(); inputManager->SetMouseScroll(inputManager->GetMouseScroll() + yOffset); std::cout << "yOffset: " << yOffset << "\n"; }
void MainMenu::checkKonami() { InputManager *input = InputManager::getInstance(); if (input->isKeyReleased(konamiCode->at(konamiIndex))) ++konamiIndex; if (konamiIndex == 10) konamiUnlocked = true; }
// Destructor ~MyFrameListener() { _inputManager->destroyInputObject(_keyboard); _inputManager->destroyInputObject(_mouse); _inputManager->destroyInputObject(_joyStick); InputManager::destroyInputSystem(_inputManager); delete _cylEffect; }
void OrbitCamera::AddInputManagerMappings(InputManager &inputManager) { inputManager.AddMapping(Key::MOUSE_LEFT_BUTTON, InputMappingType::STATE, "OrbitCamera_Rotate", KeyModifier::NONE); inputManager.AddMapping(Key::MOUSE_MIDDLE_BUTTON, InputMappingType::STATE, "OrbitCamera_Zoom", KeyModifier::NONE); inputManager.AddMapping(AnalogInput::MOUSE_AXIS_X_RELATIVE, "OrbitCamera_MouseX"); inputManager.AddMapping(AnalogInput::MOUSE_AXIS_Y_RELATIVE, "OrbitCamera_MouseY"); inputManager.AddMapping(AnalogInput::MOUSE_WHEEL_Y_RELATIVE, "OrbitCamera_MouseWheelY"); addedInputMapping = true; }
void Paddle::Update(float deltaTime) { InputManager* pInputManager = InputManager::GetInstance(); ProcessCollision(); // Respond to controlls based on which player this paddle is if (m_player == 0) { if (pInputManager->KeyDown(sf::Keyboard::W)) { m_velocity.y = -200; } else if (pInputManager->KeyDown(sf::Keyboard::S)) { m_velocity.y = 200; } else { m_velocity.y = 0; } } else if (m_player == 1) { if (pInputManager->KeyDown(sf::Keyboard::Up)) { m_velocity.y = -200; } else if (pInputManager->KeyDown(sf::Keyboard::Down)) { m_velocity.y = 200; } else { m_velocity.y = 0; } } else { if (m_pBall->GetPosition().y + (m_pBall->GetRect().height / 2) > m_position.y + (m_rect.height - 20)) { m_velocity.y = 250; } else if (m_pBall->GetPosition().y + (m_pBall->GetRect().height / 2) < m_position.y+20) { m_velocity.y = -250; } else { m_velocity.y = 0; } } m_position += m_velocity*deltaTime; m_rect = sf::FloatRect(m_position, sf::Vector2f(15, 100)); }
void renderStepZoneDMX(int player) { int startColumn = player == 0 ? 0 : 4; if ( gs.isSingles() ) { if ( gs.player[0].centerLeft ) { startColumn = 0; } else if ( gs.player[0].centerRight ) { startColumn = 4; } else { startColumn = 2; // center play } } int endColumn = gs.isDoubles ? 8 : startColumn+4; for ( int i = startColumn; i < endColumn; i++ ) { int x = getColumnOffsetX_DMX(i); int blink = gs.player[player].stepZoneBlinkTimer > 0 ? 0 : 1; // pick the state of the step zone int hitcolor = 0x7F000000; int outlineColor = 0xFFB4B4B4; const int fadeOutLength = 100; if ( blink == 1 ) { static int colors[3] = { makeacol(41, 239, 115, 255), makeacol(239, 101, 190, 255), makeacol(76, 0, 190, 255) }; int stageColor = gs.player[player].stagesLevels[gs.currentStage] % 10; outlineColor = colors[stageColor]; } if ( gs.player[player].laneFlareColors[i] == 2 ) { blink = 2; // currently holding a hold note in this column } int color = getColorOfColumn(i); if ( im.isKeyDown(i) ) { hitcolor = color == 0 ? 0xEECC0000 : 0xEE0000CC; } else if ( im.getReleaseLength(i) <= fadeOutLength ) { int a = getValueFromRange(0xFF, 0x7F, im.getReleaseLength(i) * 100/ fadeOutLength); if ( i ==4 ) { al_trace("%d\r\n", a); } hitcolor = color == 0 ? makeacol32(0xFF, 0, 0, a) : makeacol32(0, 0, 0xFF, a); } renderStepLaneDMX(x, hitcolor, outlineColor); masked_blit(m_stepZoneSourceDMX[color], rm.m_backbuf, blink*34, 0, x, (gs.player[player].isColumnReversed(i) ? DMX_STEP_ZONE_REV_Y-34 : DMX_STEP_ZONE_Y), 34, 38); } }
void Camera::KeyboardWASD(InputManager &input, float factor) { //Unreal Tournament style keyboard setup if(input.KeyCheck(KEY_W)) Move(-factor); if(input.KeyCheck(KEY_S)) Move(factor); if(input.KeyCheck(KEY_A)) Strafe(factor); if(input.KeyCheck(KEY_D)) Strafe(-factor); }
// Callback that handles mouse motion interaction void InputManager::mouseMotion_callback(GLFWwindow* window, double x, double y) { InputManager* inputManager = InputManager::GetInstance(); inputManager->SetMousePosX(x); inputManager->SetMousePosY(gHeight - y); //cout << "MousePos: (" << inputManager->GetMousePosX() << ", " << inputManager->GetMousePosY() << ")\n"; return; }
/* * Update the position of the DebugCamera based on user input. * @param dt The deltaTime value this frame. */ void DebugCamera::Update(float dt) { InputManager* pManager = InputManager::Instance(); // Current speed float moveSpeed = m_moveSpeed * dt; float rotSpeed = m_rotationSpeed * dt; // Speed up when shift is pressed if (pManager->IsKeyDown(VK_SHIFT)) { moveSpeed *= 5; } // Movement if (pManager->IsKeyDown('W')) { MoveRelative(0, 0, moveSpeed); } if (pManager->IsKeyDown('S')) { MoveRelative(0, 0, -moveSpeed); } if (pManager->IsKeyDown('A')) { MoveRelative(-moveSpeed, 0, 0); } if (pManager->IsKeyDown('D')) { MoveRelative(moveSpeed, 0, 0); } if (pManager->IsKeyDown('X')) { MoveAbsolute(0, -moveSpeed, 0); } if (pManager->IsKeyDown(' ')) { MoveAbsolute(0, moveSpeed, 0); } if (pManager->IsKeyDown('Q')) { Rotate(0.0f, -rotSpeed); } if (pManager->IsKeyDown('E')) { Rotate(0.0f, rotSpeed); } // Handle rotation if (pManager->IsMouseDown(MouseButton::LMB)) { POINT prevMousePos = pManager->GetPreviousMousePos(), currMousePos = pManager->GetCurrentMousePos(); float xDiff = (currMousePos.x - prevMousePos.x) * 0.005f; float yDiff = (currMousePos.y - prevMousePos.y) * 0.005f; Rotate(yDiff, xDiff); } }
InitializePhysX(); } void Game::InitializeKinect() { InputManager* inputManager = InputManager::GetInstance(); inputManager->InitializeKinect(mWindow->getWidth(),mWindow->getHeight()); //inputManager->FillGestureReader(L"C:\\Users\\Adam\\Desktop\\Test.gbd");
TapGesture::TapGesture(InputManager& manager, DeviceId device, DeviceVariant variant) : InputGesture(manager, device), firstDownTime_(0) { actionButton_.buttonId = InvalidDeviceButtonId; state_ = manager_.GetAllocator().New<InputState>(manager.GetAllocator(), 1); GAINPUT_ASSERT(state_); previousState_ = manager_.GetAllocator().New<InputState>(manager.GetAllocator(), 1); GAINPUT_ASSERT(previousState_); }
/* Static callbacks for IM */ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ) { VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); InputManager *im = (InputManager*)param; input_item_t *p_item = static_cast<input_item_t *>(newval.p_address); IMEvent *event = new IMEvent( IMEvent::ItemChanged, p_item ); im->postUniqueEvent( im, event ); return VLC_SUCCESS; }
void Camera::KeyboardNumpad(InputManager &input, float factor) { //Use the numberpad to replace the mouse if(input.KeyCheck(KEY_NUMPAD4)) LookRight(-factor); if(input.KeyCheck(KEY_NUMPAD6)) LookRight(factor); if(input.KeyCheck(KEY_NUMPAD8)) LookUp(factor); if(input.KeyCheck(KEY_NUMPAD2)) LookUp(-factor); if(input.KeyCheck(KEY_NUMPAD7)) Roll(factor); if(input.KeyCheck(KEY_NUMPAD9)) Roll(-factor); }