void InputBuf::doAllInput(LLParser &outputvia) { while (blockRead()) { while (hasInput()) { doInput(outputvia); } } if (_bp != _buf) { if (_left < 1) extend(); *_bp++ = '\n'; doInput(outputvia); } }
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 (); } }
void SyncPollable::processInput () { stateMutex.lock (); if (processingInput || processingError) { inputDirty = true; } else doInput (); stateMutex.unlock (); }
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); } }
void Engine:: enterMainLoop() { doCapGtimeCalcDt(); m_delayTime = gameTime; while ( ! quit ) { doCapGtimeCalcDt(); doScripts(); doInput(); doUpdate(); doCollision(); doDelay(); doRender(); } }
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; } } }
/** * @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(); } }
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(); } }
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 (); } }
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; }
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(); }