示例#1
0
void
InputBuf::doAllInput(LLParser &outputvia)
{
    while (blockRead()) {
        while (hasInput()) {
            doInput(outputvia);
        }
    }
    if (_bp != _buf) {
	if (_left < 1) extend();
	*_bp++ = '\n';
	doInput(outputvia);
    }
}
示例#2
0
void
SyncPollable::doError ()
{
    processingError = true;
    errorDirty = false;
    stateMutex.unlock ();

    for (;;) {
	pollable->processError ();

	stateMutex.lock ();
	if (errorDirty == false) {
	    if (inputDirty &&
		processingInput == false)
	    {
		doInput ();
	    }

	    if (outputDirty &&
		processingOutput == false)
	    {
		doOutput ();
	    }

	    if (errorDirty == false) {
		processingError = false;
		return;
	    }
	}

	errorDirty = false;
	stateMutex.unlock ();
    }
}
示例#3
0
void
SyncPollable::processInput ()
{
    stateMutex.lock ();

    if (processingInput ||
	processingError)
    {
	inputDirty = true;
    } else
	doInput ();

    stateMutex.unlock ();
}
示例#4
0
OsStatus MpOss::doInputRs(MpAudioSample* buffer, unsigned size)
{
   int sz = 2 * size * ((mStereoOps) ? 2 : 1);
   if (mStereoOps)
   {
      OsStatus status;
      unsigned j;
      assert (size <= mUsedSamplesPerFrame);

      status = doInput((char*)mResamplerBuffer, sz);
      for (j = 0; j < size; j++)
      {
         buffer[j] = (mResamplerBuffer[2 * j]/2) +
                     (mResamplerBuffer[2 * j + 1]/2);
      }
      return status;
   }
   else
   {
      return doInput((char*)buffer, sz);
   }

}
示例#5
0
void    Engine:: enterMainLoop()  {
    
    doCapGtimeCalcDt();
    m_delayTime = gameTime;
    
    while ( ! quit ) {
        doCapGtimeCalcDt();
        doScripts();
        doInput();
        doUpdate();
        doCollision();
        doDelay();
        doRender();
    }
}
示例#6
0
文件: Pong.cpp 项目: mariano2AA3/SFML
void Pong::input (){
   while (_window.pollEvent(_event)){
      switch (_event.type){
      case sf::Event::Closed:
         _running = false;
         break;

      case sf::Event::KeyPressed:
         doInput();
         break;

      default:
         break;
      }
   }
}
示例#7
0
文件: openal2.cpp 项目: Grokafar/qTox
/**
 * @brief Called on the captureTimer events to capture audio
 */
void OpenAL2::doAudio()
{
    QMutexLocker lock(&audioLock);

    // output section
    if (echoCancelSupported && outputInitialized && !peerSources.isEmpty()) {
        doOutput();
    } else {
        kill_filter_audio(filterer);
        filterer = nullptr;
    }

    // input section
    if (alInDev && inSubscriptions) {
        doInput();
    }
}
示例#8
0
void AIBoardController::tick() {
    if (_board.getState() != Board::BoardState::RUNNING || _board.getTicksRun() % 5 != 0) return;
    if (!_inputQueue.empty()) {
        doInput(_inputQueue.front());
        _inputQueue.pop();
    } else if
        (!_cursorQueue.empty()) {
        CursorMoveAction move = _cursorQueue.front();
        doCursorMove(move.x, move.y);
        _cursorQueue.pop();
    } else if (!_blockMoveQueue.empty()) {
        BlockMoveAction move = _blockMoveQueue.front();
        doBlockMove(move.x, move.y, move.dx, move.dy);
        _blockMoveQueue.pop();
    } else {
        basicVerticalmatchStrat();
    }
}
示例#9
0
void
SyncPollable::doOutput ()
{
    processingOutput = true;
    outputDirty = false;
    stateMutex.unlock ();

    for (;;) {
	pollable->processOutput ();

	stateMutex.lock ();

	if (processingError) {
	    if (errorDirty) {
		processingOutput = false;
		return;
	    }

	    /* If we are processing an error,
	     * then output and input processing threads
	     * have already collapsed into one thread,
	     * and we have to call output handlers
	     * from within input handlers, and vice versa. */

	    if (processingInput == false)
		if (inputDirty)
		    doInput ();
	} else
	    if (errorDirty)
		doError ();

	if (outputDirty == false) {
	    processingOutput = false;
	    return;
	}

	outputDirty = false;
	stateMutex.unlock ();
    }
}
示例#10
0
int MenuBase::showMenu() {
	SDL_Event	event;
	// valgrind reports errors in SDL_PollEvent if event is not initialized
	memset(&event, 0, sizeof(event));

	quiting = false;

	while(!quiting) {
	    int frameStart = SDL_GetTicks();

	    update();

	    if(pNetworkManager != NULL) {
            pNetworkManager->update();
	    }

	    if(quiting) {
            return retVal;
	    }

		draw(screen);

		while(SDL_PollEvent(&event)) {
		    //check the events
			if(doInput(event) == false) {
				break;
			}
		}

		int frameTime = SDL_GetTicks() - frameStart;
        if(settings.video.frameLimit == true) {
            if(frameTime < 32) {
                SDL_Delay(32 - frameTime);
            }
        }
	}

	return retVal;
}
示例#11
0
void WatchCore::run() {
    Serial.println("run");

    while (true) {
        /* This should be 0 most of the time and 1 every now and then when the clock advances a second. */
        time_t delta = now() - last;
        last = now();

        doInput();

        for (WatchMode* mode : modes)
            mode->tick(delta);

        /* Only start the tone on ticks where the delta advances. */
        if (buzzer >= now() && delta > 0)
            tone(BUZZER_PIN, 4000, 500);

        /* Some default settings for the display. */
        display.clearScreen();
        display.setCursor(0,0);
        display.setTextColor(YELLOW);

        /* The mode handles the drawing itself. */
        modes[currentMode]->draw(display);

        if (currentMenu != nullptr) {
            /* Find the maximum length of menu item names. */
            size_t maxWidth = 0;

            for (int i = 0; i < currentMenuLength; ++i) {
                auto len = strlen(currentMenu[i].name);

                if (len > maxWidth)
                    maxWidth = len;
            }

            /* A character is 6 pixels wide. */
            maxWidth *= 6;

            /* Black out the area behind the menu. */
            display.fillRect(0, 0, maxWidth + 5, display.height(), BLACK);

            /* Draw a line on the right side of the menu. */
            display.drawLine(maxWidth + 6, 0, maxWidth + 6, display.height(), WHITE);

            display.setTextSize(1);
            display.setCursor(0, 0);

            int16_t overflow = (currentMenuLength * 8) - display.height() + 4;

            if (overflow > 0) {
                int16_t scroll = overflow * currentMenuItem / currentMenuLength;
                display.drawLine(maxWidth + 4, scroll, maxWidth + 4, display.height() - overflow + scroll, WHITE);

                display.setCursor(0, -scroll);
            }

            for (int i = 0; i < currentMenuLength; ++i) {
                if (i == currentMenuItem)
                    display.setTextColor(BLACK, WHITE);
                else
                    display.setTextColor(WHITE, BLACK);

                display.println(currentMenu[i].name);
            }
        }
        display.update();
    }
}
void U2Panel::keyRel(int key){
    cout<<"Key Released :"<<key<<endl;
	if(aboutDialogShows){
		aboutDialogShows=FALSE;
		repaint();
		return;
	}
	if(themeDialogShows){
		switch(key){
			case 4100:
				themeSelected();
				break;
			case 4114:
				themeIndex+=themeAvilable.count()-1;
				themeIndex=themeIndex%themeAvilable.count();
				break;
			case 4116:
				themeIndex+=1;
				themeIndex=themeIndex%themeAvilable.count();
				break;
			case 4146:
				themeDialogShows=FALSE;
				break;
		}
		repaint();
		return;
	}
	if(selectMode){//选词模式
		cout<<"select mode"<<endl;
	
		//是数字键
		if(key==4100){
			//输入
			doInput();
			num_buf="";
			alpha_buf="";
			cw_page_list.clear();
			cw_list.clear();
			selectMode=FALSE;
		}else if(key>48&&key<58){
			doInputByNum(key);
			num_buf="";
			alpha_buf="";
			cw_page_list.clear();
			cw_list.clear();
			selectMode=FALSE;
		}
		
		
	}else{//非选词模式
		cout<<"not select mode"<<endl;
		if(key>48&&key<58){
			if(!menuShows){
				num_buf+=QString::number(key-48);
				//数字发生变化============================================================
				numBufChanged();
				getCWords();
				CWPaging();
			}
		}else if(key==4100){
			if(!menuShows){
				justTheOne();
				num_buf="";
				alpha_buf="";
				cw_page_list.clear();
				cw_list.clear();
			}else{
				switch(menu_index){
					case 0:
						emit(rejected());
						break;
					case 1:
						doCopy();
						break;
					case 2:
						doPaste();
						break;
					case 3:
						doTheme();
						break;
					case 4:
						doAbout();
						return;
						break;

				}
				menuShows=!menuShows;
			}
		}else if(key==4152){
			if(num_buf==""){
				menuShows=!menuShows;
			}
		}else if(key==4154){
			emit(accepted());
			//接受
		}
	}

	repaint();
}