Пример #1
0
	void Root::startRendering()
	{
		if( initialized == false ){
			Logger::getSingleton().log(Logger::WARNING, "Trying to start render loop while motor is not initialized");
			return;
		}
		Logger::getSingleton().log(Logger::INFO, "Motor renderloop started");

        running = true;
		sf::Event Event;
		//FPS counting
		int frameCount = 0;
		float frameTime = 0;
		timer->getElapsedTime(); //t=0
		while(running && window->isOpen() ){
			while(window->pollEvent(Event)) {
				switch( Event.type ){
				case sf::Event::KeyPressed:
					keyDown( Event.key.code , true ); break;
				case sf::Event::KeyReleased:
					keyDown( Event.key.code , false ); break;
				case sf::Event::MouseMoved:
					mouseMoved( Event.mouseMove.x, Event.mouseMove.y );
					//mRenderer->SetMousePosition( Event.motion.x, Event.motion.y );
					break;
				case sf::Event::MouseWheelMoved:
					mouseWheelMoved( Event.mouseWheel.delta );
					break;
				case sf::Event::MouseButtonPressed:
					mouseDown( (MOUSEBUTTON)Event.mouseButton.button, true, Event.mouseButton.x, Event.mouseButton.y );
					break;
				case sf::Event::MouseButtonReleased:
					mouseDown( (MOUSEBUTTON)Event.mouseButton.button, false, Event.mouseButton.x, Event.mouseButton.y );
					break;
				case sf::Event::Closed:
					running = false;
					break;
				default:
					break;
				}
			}

            float elapsedTime = timer->getElapsedTime();
			++frameCount;
			frameTime += elapsedTime;
			if( frameTime > 1.0f ){
				Logger::getSingleton() << Logger::INFO << "FPS: " << (float)frameCount/frameTime;
				Logger::getSingleton() << "\t(frametime " << frameTime/(float)frameCount << ")" << endLog;
				frameCount = 0;
				frameTime = 0;
			}

			//Call frame listeners
			for( std::vector<FrameListener*>::iterator it = frameListeners.begin(); it != frameListeners.end(); ++it ){
				(*it)->onFrame( elapsedTime );
			}

			if( renderOneFrame() == false ) break;
		}
	}
Пример #2
0
		void CameraControl::checkSliderKeys(bool* keysDown) {
			if (!comboSlider) return;

			if (keyDown(Qt::Key_Up)) {
				sliderStepSize = sliderStepSize*10.0;
				QToolTip::showText(comboSlider->mapToGlobal(QPoint()), QString("Step size: %1").arg(sliderStepSize));
				*keysDown = true;
				keyStatus[Qt::Key_Up] = false; // only apply once
			} 
			
			if (keyDown(Qt::Key_Down)) {
				sliderStepSize = sliderStepSize/10.0;
				QToolTip::showText(comboSlider->mapToGlobal(QPoint()), QString("Step size: %1").arg(sliderStepSize));


				*keysDown = true;
				keyStatus[Qt::Key_Down] = false; // only apply once
			}
			
			if (keyDown(Qt::Key_Left)) {
				comboSlider->setValue(comboSlider->getValue()-sliderStepSize);
				QToolTip::showText(comboSlider->mapToGlobal(QPoint()), QString(""));
				*keysDown = true;
			} 
			
			if (keyDown(Qt::Key_Right)) {
				comboSlider->setValue(comboSlider->getValue()+sliderStepSize);
				QToolTip::showText(comboSlider->mapToGlobal(QPoint()), QString(""));
				*keysDown = true;
			} 
			
		}
Пример #3
0
void cGameStateScore::processEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
  m_event = GO_NO_WHERE;
  
  if(keyDown(VK_SPACE))
    m_event = GO_MAIN;

  if(keyDown('S'))
    m_event = GO_NO_WHERE;
}
Пример #4
0
void Keyboard::update()
{
	struct input_event e;

	while(read(fd, &e, sizeof(struct input_event)) == sizeof(struct input_event))
	{
		if(e.type == 1 && e.value == 1) keyDown(e.code);
		if(e.type == 1 && e.value == 2) keyDown(e.code); //Key repeated
		if(e.type == 1 && e.value == 0) keyUp(e.code);
	}
}
void GameClient::processKeys(){
#define keyDown(X) (glfwGetKey(X)==GLFW_PRESS)
    if (keyDown('A'))     mainPlayer->sideStep(0.1);
    if (keyDown('D'))     mainPlayer->sideStep(-0.1);
    if (keyDown('W'))     mainPlayer->forward(0.1);
    if (keyDown('S'))     mainPlayer->forward(-0.1);
    if (keyDown('Q'))     gameRunning = false;
#undef keyDown

    if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT)==GLFW_PRESS)
        mainPlayer->shoot();
}
Пример #6
0
// Update
void key_manager::update(){
  // Pressing them keys
  // You haven't won
  if(!switch_flicked){
    // Got a correct letter
    if((key_queue.size() > 0) && (!joystick_enabled && key[key_queue.at(0).getValue()] && keyIsPressed == false) || (joystick_enabled && joy[0].button[key_queue.at(0).getValue()].b && buttonIsPressed == false)){
      // Nice sound
      play_sample( sounds[1],255,125,1000,0);
      key_queue.erase( key_queue.begin());

      // Add key to queue
      if( joystick_enabled){
        key_data newKey(random(0,3));
        key_queue.push_back(newKey);
      }
      else{
        key_data newKey(random(KEY_LEFT, KEY_DOWN));
        key_queue.push_back(newKey);
      }

      // Increase speed
      if( stair::scrollSpeed < stair::maxScrollSpeed)
        stair::scrollSpeed += 0.8;
    }
    else if( (keyDown() && keyIsPressed == false) || (buttonDown() && buttonIsPressed == false)){
      if(stair::scrollSpeed > 0)
        stair::scrollSpeed /= 4;
      play_sample(sounds[0],255,125,1000,0);
    }
  }
  // Stop
  else{
    stair::scrollSpeed = 0;
  }

  // Prevents held keys
  if(!joystick_enabled){
    keyIsPressed = keyDown();
  }
  if(joystick_enabled){
    buttonIsPressed = buttonDown();
  }

  // Slow stairs down
  if( stair::scrollSpeed > 0.01)
    stair::scrollSpeed -= 0.02;
  else{
    stair::scrollSpeed = 0;
  }
}
Пример #7
0
    bool frameStarted(const FrameEvent &evt)
    {
        //Entrada pelo teclado
        if(mKeyboard)
           mKeyboard->capture();

        if(mMouse)
           mMouse->capture();

        //Inicia Variavel para controle de velocidade
        Real move = mWalkSpeed * evt.timeSinceLastFrame;

        //Anima a Cena
        mAnimationState->addTime(evt.timeSinceLastFrame);

        //Move o Robo
        SceneNode *node = mEntity->getParentSceneNode();
        if(!keyDown())
        {
            mDirection = Vector3::ZERO;

            mAnimationState = mEntity->getAnimationState("Idle");
            mAnimationState->setLoop(true);
            mAnimationState->setEnabled(true);
        }
        node->translate(mDirection * move);
        return mContinue;
    }
Пример #8
0
void mainLoop() {
    //The first time you run TackFPS it will return a trash value, so get it out of the way now
    TackFPS(true);

    //Pre-emptively call the resize and draw functions to get the cycle going
    reshape(miWidth, miHeight);

    bool running = true;
    sf::Event event;
    while(running) {
        draw();
        while(window.pollEvent(event)) {
            switch(event.type) {
                case sf::Event::Closed: running = false; break;
                case sf::Event::Resized: reshape(event.size.width, event.size.height); break;
                case sf::Event::KeyPressed: keyDown(event.key.code); break;// TODO codes
                case sf::Event::MouseMoved: mouseDrag(event.mouseMove.x, event.mouseMove.y); break;
                case sf::Event::MouseButtonPressed: mousePress(event.mouseButton.button, 1, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::MouseButtonReleased: mousePress(event.mouseButton.button, 0, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::TextEntered: charTyped(event.text.unicode); break;
                default: cout << "unhandled event:" << event.type << endl; break;
            }
        }
        window.display();
    }
}
Пример #9
0
void EventEngine::run(Control &c)
{
	for (bool redraw = true;;)
	{
		if (redraw)
		{
			_graphics.resetColors();
			_graphics.clearScreen();
			_graphics.setCursorVisibility(false);
			for (size_t p = 0; p < 3; p++) {
				c.draw(_graphics, 0, 0, p);
			}
			redraw = false;
			Control * focused = Control::getFocus();
			if (dynamic_cast<TextBox *>(focused) != NULL) {
				static_cast<TextBox *>(focused)->moveCurser(_graphics);
			}
		}

		INPUT_RECORD record;
		DWORD count;
		ReadConsoleInput(_console, &record, 1, &count);
		switch (record.EventType)
		{
		case KEY_EVENT:
		{
			auto f = Control::getFocus();
			if (f != nullptr && record.Event.KeyEvent.bKeyDown)
			{
				auto code = record.Event.KeyEvent.wVirtualKeyCode;
				auto chr = record.Event.KeyEvent.uChar.AsciiChar;
				if (code == VK_TAB) {
					if (!Panel::getMsgOpen()){
						moveFocus(c, f);
					}
				}
				else
					f->keyDown(code, chr);
				redraw = true;
			}
			break;
		}
		case MOUSE_EVENT:
		{
			auto button = record.Event.MouseEvent.dwButtonState;
			auto coord = record.Event.MouseEvent.dwMousePosition;
			auto x = coord.X;
			auto y = coord.Y;
			if (button == FROM_LEFT_1ST_BUTTON_PRESSED || button == RIGHTMOST_BUTTON_PRESSED)
			{
				c.mousePressed(x, y, button == FROM_LEFT_1ST_BUTTON_PRESSED);
				redraw = true;
			}
			break;
		}
		default:
			break;
		}
	}
}
Пример #10
0
/* Allows _new_ mappings to be made at runtime */
static bool checkQwertyKeys()
{
	KEY_CODE qKey;
	UDWORD tableEntry;
	bool aquired = false;

	/* Are we trying to make a new map marker? */
	if (keyDown(KEY_LALT))
	{
		/* Did we press a key */
		qKey = getQwertyKey();
		if (qKey)
		{
			tableEntry = asciiKeyCodeToTable(qKey);
			/* We're assigning something to the key */
			debug(LOG_NEVER, "Assigning keymapping to tableEntry: %i", tableEntry);
			if (qwertyKeyMappings[tableEntry].psMapping)
			{
				/* Get rid of the old mapping on this key if there was one */
				keyRemoveMappingPt(qwertyKeyMappings[tableEntry].psMapping);
			}
			/* Now add the new one for this location */
			qwertyKeyMappings[tableEntry].psMapping =
			    keyAddMapping(KEYMAP_ALWAYS, KEY_LSHIFT, qKey, KEYMAP_PRESSED, kf_JumpToMapMarker, "Jump to new map marker");
			aquired = true;

			/* Store away the position and view angle */
			qwertyKeyMappings[tableEntry].xPos = player.p.x;
			qwertyKeyMappings[tableEntry].yPos = player.p.z;
			qwertyKeyMappings[tableEntry].spin = player.r.y;
		}
	}
	return aquired;
}
cGameStateObject* cGameStateIntro::update(double timeDifference, Camera &cam, CGameData &data, CGraphics &con){
  m_event = EVENT_GO_NO_WHERE;
  
  //initialize data first time this state is called
  static bool bFirstTime = true;
  if(bFirstTime == true){
 
    CAudioManager *pAudio = CAudioManager::Instance();
    if(pAudio->IsPlaying(0) == false)    //nature sounds
      pAudio->PlaySoundClip(0, 1);
    if(pAudio->IsPlaying(13) == false)    //birds
      pAudio->PlaySoundClip(13, 1);

    bFirstTime = false;
  }

  //keystrokes
  if(::GetActiveWindow() == data.m_hWnd && keyDown(VK_SPACE))
    m_event = EVENT_GO_MAIN;

  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
Пример #12
0
Файл: tile.cpp Проект: kyak/Tile
void Tile::keyPressEvent(QKeyEvent *event)
{
   if (event->key() == Qt::Key_Escape || event->key() == Qt::Key_Q) {
       Quit();
   } else if (event->key() == Qt::Key_S) {
       Shuffle();
   } else if (event->key() == Qt::Key_R) {
       Reset();
   } else if (event->key() == Qt::Key_H) {
       Help();
   } else if (event->key() == Qt::Key_O) {
       Solve();
   } else if (event->key() == Qt::Key_Up) {
       //focusNextChild();
       //qDebug() << qApp->focusWidget();
       QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget());
       if (button) {
          keyUp(button);
       }
   } else if (event->key() == Qt::Key_Down) {
       //focusPreviousChild();
       //qDebug() << qApp->focusWidget();
       QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget());
       if (button) {
           keyDown(button);
       }
   } else if( event->key() == Qt::Key_Return ) {
       QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget());
       if (button) {
           button->click();
       }
   } else {
       return;
   }
}
Пример #13
0
//***************************************************************
//                         U P D A T E
//***************************************************************
CGameStateObject* CGameStatePlay2::Update(double timeDifference,  CGameData &data, CConfigData &cfg, CGraphics &con){
  m_event = EVENT_GO_NO_WHERE;
  CLog *pLog = CLog::Instance();

  static bool bStop = false;
  
  //perform this code only once
  //****************************
  static bool bFirstTime = true;
  if(bFirstTime == true){
    bFirstTime = false;

    //data.LoadGameLevel("assets\\data\\level1.dat"); //missing sprite data
    //data.AddGraphicDataToLevelData(con);            //update graphic data
  }

  
  m_mouse.SetHandle(data.m_hWnd);//needed for mouse

  if(::GetActiveWindow() == data.m_hWnd && keyDown(VK_SPACE))//quit this mode
    m_event = EVENT_GO_CONTROL;
  
  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
Пример #14
0
/**
 * @brief FilterWidget::FilterWidget
 * @param parent
 */
FilterWidget::FilterWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FilterWidget)
{
    ui->setupUi(this);
    ui->lineEdit->setShowMagnifier(true);
    ui->lineEdit->addAdditionalStyleSheet("QLineEdit { border: 1px solid rgba(0, 0, 0, 100); border-radius: 10px; }");
    ui->lineEdit->setType(MyLineEdit::TypeClear);
    ui->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);

    m_list = new QListWidget();
    m_list->setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
    m_list->setAttribute(Qt::WA_ShowWithoutActivating);

    m_activeWidget = WidgetMovies;

    QPalette palette = m_list->palette();
    palette.setColor(QPalette::Highlight, palette.color(QPalette::Highlight));
    palette.setColor(QPalette::HighlightedText, palette.color(QPalette::HighlightedText));
    m_list->setPalette(palette);
    m_list->setStyleSheet(QString("background-color: transparent; border: 1px solid rgba(255, 255, 255, 200); border-radius: 5px;"));
    m_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(onFilterTextChanged(QString)));
    connect(ui->lineEdit, SIGNAL(keyDown()), this, SLOT(onKeyDown()));
    connect(ui->lineEdit, SIGNAL(keyUp()), this, SLOT(onKeyUp()));
    connect(ui->lineEdit, SIGNAL(focusOut()), m_list, SLOT(hide()));
    connect(ui->lineEdit, SIGNAL(focusIn()), this, SLOT(setupFilters()));
    connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(addSelectedFilter()));
    connect(ui->lineEdit, SIGNAL(backspaceInFront()), this, SLOT(removeLastFilter()));
    connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(addFilterFromItem(QListWidgetItem*)));

    initFilters();
}
Пример #15
0
		void CInputEventsTranslator::activateKeyboardTranslation()
		{
			Messages::MessageType keyDown("KEYBOARD_KEYDOWN");
			Messages::MessageType keyUp("KEYBOARD_KEYUP");
			Messages::MessageType updateKeyboard("UPDATE_KEYBOARD");


			DynamicObjectManager *dom = DynamicObjectManager::getInstancePtr();
			shared_ptr< Gnoll::DynamicObject::DynamicObject > keyboardConfig = dom->load("keyboardConfig");

			/**
			 * How often will the keyboard module get updated (millisecond)
			 */
			unsigned long int period = 300;
			shared_ptr< Gnoll::DynamicObject::Integer > periodFromConfig = keyboardConfig->getAttribute< Gnoll::DynamicObject::Integer >("period");
			period = *periodFromConfig;

			CMessageModule* messageModule = CMessageModule::getInstancePtr();
			Messages::Messenger* messageManager = messageModule->getMessageManager();


			keyboardEventsTranslator = shared_ptr<Messages::Listener> ( new CKeyboardEventsTranslator() );
			keyboardEventsTrigger = shared_ptr<Messages::Listener> ( new CKeyboardEventsTrigger(static_pointer_cast<CKeyboardEventsTranslator>(keyboardEventsTranslator) ));
			keyboardStateTranslator = shared_ptr<Messages::Listener> ( new CKeyboardStateTranslator() );

			try
			{
				/**
				 * Continuous keyboard messages
				 */
				messageManager->addListener ( keyboardEventsTranslator, keyDown );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTranslator listener installed" );

				messageManager->addListener ( keyboardEventsTranslator, keyUp );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTranslator listener installed" );

				messageManager->addListener ( keyboardEventsTrigger, updateKeyboard );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTrigger listener installed" );

				/**
				 * State based keyboard messages
				 */
				messageManager->addListener ( keyboardStateTranslator, keyDown );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardStateTranslator listener installed" );

				messageManager->addListener ( keyboardStateTranslator, keyUp );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardStateTranslator listener installed" );
			}
			catch(...)
			{
				throw;
			}

			CTimeModule* timeModule = CTimeModule::getInstancePtr();
			m_periodData = shared_ptr<boost::any> (new boost::any(period)) ;
			shared_ptr<CMessage>  message (new CMessage(updateKeyboard, m_periodData ));

			timeModule->addPeriodicEvent(0, message, period);
		}
Пример #16
0
void CGame::input()
{
	m_Keyboard->GetDeviceState(sizeof(m_Keys), (LPVOID)&m_Keys);

    //check for escape key (to exit program)
    if (keyDown(DIK_ESCAPE))
        PostMessage(m_Window, WM_DESTROY, 0, 0);

	//move bitmap
	if (keyDown(DIK_W))
		m_Bitmap.move(0, -1);
	if (keyDown(DIK_S))
		m_Bitmap.move(0, 1);
	if (keyDown(DIK_A))
		m_Bitmap.move(-1, 0);
	if (keyDown(DIK_D))
		m_Bitmap.move(1, 0);

	//scale bitmap
	if (keyDown(DIK_Q))
		m_Bitmap.scale(1);

	if (keyDown(DIK_E))
		m_Bitmap.scale(-1);
}
Пример #17
0
BOOL MainScene3D::UpdateGL(GLvoid)
{
	if (keyDown(key_f1))
	{

	}

	return TRUE;
}
Пример #18
0
cGameStateObject* cGameStateFireControl::update(double timeDifference){
  m_event = EVENT_GO_NO_WHERE;

  //loads mouse position into global variable.
  POINT pt;
  POINT *ppt = &pt;
  ::GetCursorPos(ppt);
  RECT rct;
  ::GetWindowRect(g_hWnd, &rct);
  g_Global.g_mouse.x = pt.x - rct.left;
  g_Global.g_mouse.y = pt.y - rct.top;
  
  CGameData *pData = CGameData::Instance();
  pData->Update(timeDifference);
  CAudioManager *pAudio = CAudioManager::Instance();

  static double timeDiffTotal = 0;
  timeDiffTotal += timeDifference;
  if(timeDiffTotal > .1){
    timeDiffTotal = 0;

    if(keyDown(VK_SPACE) && ::GetActiveWindow() == g_hWnd){
      CTorpedo torpedo(pData->m_Player.m_heading, pData->m_Player.m_heading, pData->m_Player.m_posX, pData->m_Player.m_posY);
      pData->m_torpedos.push_back(torpedo);
      //there are 2 torpedo sounds...play 1..if busy play 2
      if(pAudio->IsPlaying(SOUND_TORPEDO1) == false)
        pAudio->PlaySoundClip(SOUND_TORPEDO1, 0);
      else{
        if(pAudio->IsPlaying(SOUND_TORPEDO2) == false)
          pAudio->PlaySoundClip(SOUND_TORPEDO2, 0);
      }
    }
  
    //process short cut buttons
    if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130 
      && g_Global.g_bLeftMouseDown == true && ::GetActiveWindow() == g_hWnd){
      if(g_Global.g_mouse.x > 10 && g_Global.g_mouse.x < 110)
        m_event = EVENT_GO_SONAR;
      else if(g_Global.g_mouse.x > 120 && g_Global.g_mouse.x < 220)
        m_event = EVENT_GO_RADAR;
      else if(g_Global.g_mouse.x > 230 && g_Global.g_mouse.x < 330)
        m_event = EVENT_GO_CONTROL;
      else if(g_Global.g_mouse.x > 804 && g_Global.g_mouse.x < 904)
        m_event = EVENT_GO_STATUS;
      else if(g_Global.g_mouse.x > 914 && g_Global.g_mouse.x < 1014)
        m_event = EVENT_GO_CHART;
    }      
  }

  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
Пример #19
0
void PageComponent::base_keyDown( unsigned char inASCII ){
    for( int i=0; i<mComponents.size(); i++ ) {
        PageComponent *c = *( mComponents.getElement( i ) );
    
        if( c->isVisible() && c->isActive() ) {
            c->base_keyDown( inASCII );
            }
        }

    keyDown( inASCII );
    }
Пример #20
0
void InputControlListener::sendKey(EEventDescriptor event, pp_uint16 vk, pp_uint16 sc, pp_uint16 chr)
{
	PPScreen* screen = tracker.screen;

	if (event == eKeyDown || eKeyUp)
	{
		// Send keydown to simulate note key press	
		pp_uint16 vksc[3] = {vk, sc, chr};

		PPEvent keyDown(event, &vksc, sizeof(vksc));
		screen->raiseEvent(&keyDown);
	}
	else if (event == eKeyChar)
	{
		// Send keydown to simulate note key press	
		pp_uint16 vksc[2] = {vk, sc};

		PPEvent keyDown(event, &vksc, sizeof(vksc));
		screen->raiseEvent(&keyDown);
	}
}
void EventEngine::run(Control &c)
{
	for (bool redraw = true;;)
	{
		if (redraw)
		{
			_graphics.clearScreen();
			_graphics.setCursorVisibility(false);
			for (size_t p = 0; p < 6; ++p)
				c.draw(_graphics, 0, 0, p);
			redraw = false;
			Control::getFocus()->nowInFocus();
		}

		INPUT_RECORD record;
		DWORD count;
		ReadConsoleInput(_console, &record, 1, &count);
		switch (record.EventType)
		{
		case KEY_EVENT:
		{
			auto f = Control::getFocus();
			if ((f != nullptr) && (record.Event.KeyEvent.bKeyDown))
			{
				auto code = record.Event.KeyEvent.wVirtualKeyCode;
				auto chr = record.Event.KeyEvent.uChar.AsciiChar;
				if (code == VK_TAB)
					moveFocus(c, f);
				else {
					f->keyDown(code, chr);
				}
				redraw = true;
			}
			break;
		}
		case MOUSE_EVENT:
		{
			auto button = record.Event.MouseEvent.dwButtonState;
			auto coord = record.Event.MouseEvent.dwMousePosition;
			auto x = coord.X - c.getLeft();
			auto y = coord.Y - c.getTop();
			if (button == FROM_LEFT_1ST_BUTTON_PRESSED || button == RIGHTMOST_BUTTON_PRESSED)
			{
				c.mousePressed(x, y, button == FROM_LEFT_1ST_BUTTON_PRESSED);
				redraw = true;
			}
			break;
		}
		default:
			break;
		}
	}
}
Пример #22
0
cGameStateObject* cGameStateScore::update(){
  m_event = GO_NO_WHERE;

  if(keyDown(VK_RETURN)){
    m_event = GO_MAIN;
  }

  for(int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event)
      return m_TE[i].p_gso;
  }
  return 0;
}
Пример #23
0
/** Check if mouse is over the History console 'window' area */
bool	mouseOverHistoryConsoleBox(void)
{
	int nudgeright = 0;
	if (isSecondaryWindowUp())
	{	// if a build/research/... is up, we need to move text over by this much
		nudgeright = RET_FORMWIDTH;
	}
	// enable below to see the hitbox of the history console window
#if 0
	if (isSecondaryWindowUp())
	{
		iV_Box2(historyConsole.topX + nudgeright, historyConsole.topY, historyConsole.topX + historyConsole.width, (historyConsole.topY + 4 + linePitch * NumDisplayLines), WZCOL_RED, WZCOL_GREEN);

	}
	else
	{
		iV_Box2(historyConsole.topX, historyConsole.topY, historyConsole.topX + historyConsole.width, (historyConsole.topY + 4 + linePitch * NumDisplayLines), WZCOL_GREY, WZCOL_GREY);
	}
#endif
	// check to see if mouse is in the area when console is enabled
	if	(bConsoleDropped &&
	     ((UDWORD)mouseX() > historyConsole.topX + nudgeright)
	     && ((UDWORD)mouseY() > historyConsole.topY)
	     && ((UDWORD)mouseX() < historyConsole.topX + historyConsole.width)
	     && ((UDWORD)mouseY() < (historyConsole.topY + 4 + linePitch * NumDisplayLines)))
	{
		if (mousePressed(MOUSE_WUP))
		{
			updatepos--;
		}
		else if (mousePressed(MOUSE_WDN))
		{
			updatepos++;
		}
		if (keyDown(KEY_LCTRL))
		{
			showBackgroundColor = true;
		}
		else
		{
			showBackgroundColor = false;
		}
		return (true);
	}
	else
	{
		return (false);
	}
}
Пример #24
0
Файл: tile.cpp Проект: kyak/Tile
void Tile::keyDown(QPushButton *button)
{
    int id = button->property("id").toInt();
    QPushButton *button_down;
    if (id > 12) {
        button_down = idtoButton(id-12);
    } else {
        button_down = idtoButton(id+4);
    }
    if (button_down->isHidden()) {
        keyDown(button_down);
    } else {
        button_down->setFocus();
    }
}
Пример #25
0
cGameStateObject* cGameStateHistory::update(double timeDifference){
  m_event = EVENT_GO_NO_WHERE;

  if(keyDown(VK_SPACE) && ::GetActiveWindow() == g_hWnd){
    m_event = EVENT_GO_MAIN;
    ::ShowCursor(true);
  }

  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
Пример #26
0
void processEvent(sf::Event& event) {
    switch(event.type) {
        case sf::Event::Closed: {
            window->close();
            break;
        }
        case sf::Event::KeyPressed: {
            keyDown(event.key.code);
            break;
        }
        case sf::Event::KeyReleased: {
            keyUp(event.key.code);
            break;
        }
    }
}
Пример #27
0
bool Node::treeKeyDown( KeyEvent event )
{
    if(!mIsVisible) return false;

    // test children first, from top to bottom
    NodeList nodes(mChildren);
    NodeList::reverse_iterator itr;
    bool handled = false;
    for(itr=nodes.rbegin(); itr!=nodes.rend()&&!handled; ++itr)
        handled = (*itr)->treeKeyDown(event);

    // if not handled, test this node
    if(!handled) handled = keyDown(event);

    return handled;
}
Пример #28
0
void processEvents()
{
	static int lastMouseX = 0;
	static int lastMouseY = 0;
	SDL_Event event;
	SDL_Surface *screen;
	int videoFlags = DEFAULT_FLAGS;

	/* route all events to specific event handlers */
	while (SDL_PollEvent(&event))
	{
		switch (event.type)
		{
		case SDL_QUIT:
			quit();
			break;
		case SDL_VIDEORESIZE:
			screen = SDL_SetVideoMode(
				event.resize.w, 
				event.resize.h,
				DEFAULT_DEPTH,
				videoFlags
				);
			eventReshape(screen->w, screen->h);
			break;
		case SDL_KEYDOWN:
			keyDown(event.key.keysym.sym);
			break;
		case SDL_KEYUP:
			keyUp(event.key.keysym.sym);
			break;
		case SDL_MOUSEBUTTONDOWN:
			mouseDown(event.button.button, 1, lastMouseX, lastMouseY);
			break;
		case SDL_MOUSEBUTTONUP:
			mouseDown(event.button.button, 0, lastMouseX, lastMouseY);
			break;
		case SDL_MOUSEMOTION:
			lastMouseX = event.motion.x;
			lastMouseY = event.motion.y;
			mouseMove(lastMouseX, lastMouseY);
			break;
		default:
			break;
		}
	}
}
Пример #29
0
void ArrowLineEdit::keyPressEvent( QKeyEvent * e )
{
    switch(e->key()){
    case Key_Up:
	keyUp(e);
	return;
    case Key_Down:
	keyDown(e);
	return;
    case Key_Enter:
    case Key_Return:
	keyEnter(e);
	return;
    default:
	QLineEdit::keyPressEvent(e);
    }
}
Пример #30
0
void Tile::keyPressEvent(QKeyEvent *event)
{
   if (event->key() == Qt::Key_Escape || event->key() == Qt::Key_Q) {
       Quit();
   } else if (event->key() == Qt::Key_Up) {
       //focusNextChild();
       //qDebug() << qApp->focusWidget();
       QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget());
       keyUp(button);
   } else if (event->key() == Qt::Key_Down) {
       //focusPreviousChild();
       //qDebug() << qApp->focusWidget();
       QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget());
       keyDown(button);
   } else {
       return;
   }
}