void WalletSerializer::loadCurrentVersion(Common::IInputStream& source, const std::string& password) { CryptoNote::CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); generateKey(password, cryptoContext.key); loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext); } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); loadSpentOutputs(source, cryptoContext); loadUnlockTransactionsJobs(source, cryptoContext); loadChange(source, cryptoContext); } if (details && cache) { updateTransactionsBaseStatus(); } }
void WalletSerializer::loadWalletV1(Common::IInputStream& source, const std::string& password) { CryptoNote::CryptoContext cryptoContext; CryptoNote::BinaryInputStreamSerializer encrypted(source); encrypted(cryptoContext.iv, "iv"); generateKey(password, cryptoContext.key); std::string cipher; encrypted(cipher, "data"); std::string plain = decrypt(cipher, cryptoContext); MemoryInputStream decryptedStream(plain.data(), plain.size()); CryptoNote::BinaryInputStreamSerializer serializer(decryptedStream); loadWalletV1Keys(serializer); checkKeys(); subscribeWallets(); bool detailsSaved; serializer(detailsSaved, "has_details"); if (detailsSaved) { loadWalletV1Details(serializer); } }
void timer0_int() { set_timer0 (Timerstartwert_K); // Timer0 Interr. alle 1/100 sek --Down_B; if (-- Presc_B == 0) { Presc_B = Preload_K; if (++Hsec_B == 100) { Hsec_B = 0; if (++Sec_B == 60) { Sec_B = 0; if (++Min_B == 60) { Min_B = 0; if (++Hour_B == 24) { Hour_B = 0; } } } } if(SPIActive == 0){ checkKeys(); } } }
int render::execute() { if (play) updateSounds(); checkBalls(); draw(); SDL_GL_SwapWindow(mainwindow); if (checkKeys() < 0) return -1; return 0; }
void timerCallback() override { if (renderComponent.currentTest == nullptr) return; grabKeyboardFocus(); checkKeys(); renderComponent.currentTest->m_world->Step (1.0f / 60.0f, 6, 2); repaint(); }
// Checks for keyboard and button events, in which it will react to accordingly, then draws the rubik's cube. // Clicking the window close button or ESC key breaks out of the loop in order to unitialize objects before // the program exits. void pollEventsAndDraw() { SDL_Event event; bool running = true; while( running ) { if( SDL_PollEvent(&event) ) { checkKeys(event, running); } drawRubiksCube(); } }
void Controller::Peripheral::checkMove(gdl::Input& input) { if (_joy == NULL && _save == NULL) checkKeys(input); else { SDL_JoystickUpdate(); checkButtons(); if (checkAxes() == false) checkHat(); } }
void MainWindow::setupTimers() { QTimer *keysTimer = new QTimer; keysTimer->setInterval(10); QObject::connect(keysTimer, SIGNAL(timeout()), this, SLOT(checkKeys())); keysTimer->start(); QTimer *timer = new QTimer; timer->setInterval(1000); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateStandartText())); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateInform())); timer->start(); }
int IEngine::begin() { while(m_window->IsOpened()) { sf::Event Event; checkKeys(); while(m_window->GetEvent(Event)) { if(Event.Type == sf::Event::Closed) { m_window->Close(); return 0; } else if(Event.Type == sf::Event::KeyPressed) { // For one-press keys: (starts to repeat after a while) if(Event.Key.Code == sf::Key::Escape) { m_window->Close(); return 0; } if(Event.Key.Code == sf::Key::M) { m_wireframe = true; } if(Event.Key.Code == sf::Key::N) { m_wireframe = false; } if(Event.Key.Code == sf::Key::R){ c_pos = vec3(0,CHUNK_SIZE,0); c_speed = vec3(0,0,0); } } else if(Event.Type == sf::Event::Resized) { resize(Event.Size.Width, Event.Size.Height); } } update(); drawScene(); m_window->Display(); } return 0; }
void WalletSerializerV1::loadWallet(Common::IInputStream& source, const Crypto::chacha8_key& key, uint32_t version) { CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); cryptoContext.key = key; loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext, version); } if (version < 5) { updateTransfersSign(); cache = false; } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); if (version < 5) { loadObsoleteSpentOutputs(source, cryptoContext); } loadUnlockTransactionsJobs(source, cryptoContext); if (version < 5) { loadObsoleteChange(source, cryptoContext); } if (version > 3) { loadUncommitedTransactions(source, cryptoContext); } } else { resetCachedBalance(); } if (details && cache) { updateTransactionsBaseStatus(); } }
// Checks for keyboard and button events, in which it will react to accordingly, then draws the rubix cube. // Clicking the window close button or ESC key breaks out of the loop in order to unitialize objects before // the program exits. void pollEventsAndDraw() { SDL_Event event; bool running = true; while( running ) { if( SDL_PollEvent(&event) ) if( event.type == SDL_QUIT ) running = false; else if( event.type == SDL_KEYDOWN ) checkKeys(event, running); drawRubixCube(); } }
int main() { //register keys to track vector<int> keyCodes { VK_LBUTTON, VK_RBUTTON, VK_TAB, VK_DELETE, VK_F1,VK_F2,VK_F3,VK_F4,VK_F5, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x41, 0x44, 0x45, 0X46, 0x51, 0x52, 0x53, 0X57 }; vector<int> menuKeyCodes{ VK_END, VK_HOME, VK_DOWN, VK_UP, VK_RETURN }; //load config and notifications Config config("config.txt"); Notification notification(config); while (true) { system("CLS"); //display the menu KeyPress menuKeys(config, menuKeyCodes, "menuKeys"); Display mainMenu(config, BUFFER_SIZE, menuKeys); checkKeys(menuKeys, mainMenu, notification, menuKeyCodes, 1); //ckeck for keys and display the counter screen KeyPress keyLogger(config, keyCodes, "keyLogger"); Display counter(config, BUFFER_SIZE, keyLogger); checkKeys(keyLogger, counter, notification, keyCodes); } //exit main return 0; }
void Engine::drawObjects() { checkKeys(); interaction(); camera->lookAt(player->GetX(), player->GetY(), player->GetZ()); drawAxes(); player->draw(); for(int i = 0; i < 3; i++) { surface[i]->draw(); } calculateFPS(); interf->draw(); }
void QEngineWidget::OnUpdate() { /*Update*/ // handle events sf::Event event; while (this->getRenderWindow()->pollEvent(event)) { switch(event.type) { case sf::Event::Closed: continuer = false; break; case sf::Event::Resized: glViewport(0, 0, event.size.width, event.size.height); break; default: break; } } checkKeys(); draw(); }
void WalletSerializerV1::loadWalletV1(Common::IInputStream& source, const Crypto::chacha8_key& key) { CryptoContext cryptoContext; CryptoNote::BinaryInputStreamSerializer encrypted(source); encrypted(cryptoContext.iv, "iv"); cryptoContext.key = key; std::string cipher; encrypted(cipher, "data"); std::string plain = decrypt(cipher, cryptoContext); MemoryInputStream decryptedStream(plain.data(), plain.size()); CryptoNote::BinaryInputStreamSerializer serializer(decryptedStream); loadWalletV1Keys(serializer); try { checkKeys(); } /* Remove the partially (incorrectly) parsed wallet, pass is wrong */ catch (const std::system_error &e) { m_walletsContainer.clear(); throw(e); } subscribeWallets(); bool detailsSaved; serializer(detailsSaved, "has_details"); if (detailsSaved) { loadWalletV1Details(serializer); } }
void main () { int R_B,L_B, R_VU, L_VU, avg_R=0, avg_L=0; coldstart(); // Grundinitialisierung enable_interrupts(GLOBAL); set_adc_channel(0); delay_ms (1); avg_L = read_adc(); set_adc_channel(1); delay_ms (1); avg_R = read_adc(); while (TRUE) // Beginn Hauptprogramm { // VU-Meter set_adc_channel(0); delay_ms (1); L_VU = read_adc(); set_adc_channel(1); delay_ms (1); R_VU = read_adc(); avg_L = (avg_L + L_VU) /2; avg_R = (avg_R + R_VU) /2; if((avg_L + avg_R) >= 3){ // VU-Meter - Portout L_B = Makevu (L_VU); R_B = Makevu (R_VU); Portout (L_B,R_B); // Bass, mid, treble set_adc_channel(2); delay_ms (1); if (read_adc() > 560) output_low (Ledb_p); else output_high (Ledb_p); set_adc_channel(3); delay_ms (1); if (read_adc() > 570) output_low (Ledm_p); else output_high (Ledm_p); set_adc_channel(4); delay_ms (1); if (read_adc() > 550) output_low (Ledt_p); else output_high (Ledt_p); } else { LEDTest8(); checkKeys(); LEDTest6(); checkKeys(); LEDTest3(); checkKeys(); LEDTest4(); checkKeys(); LEDTest2(); checkKeys(); LEDTest5(); checkKeys(); LEDTest7(); checkKeys(); LEDTest1(); } checkKeys(); } }
void processMovement(){ checkKeys(); }
int main() { initProgram(); #ifdef PROFILING int counter = 0; irqSet(IRQ_HBLANK, hblank_handler); irqEnable(IRQ_HBLANK); cygprofile_begin(); cygprofile_enable(); #endif while(1) { updateStreamLoop(); if(!checkHelp()) { if(getLCDState() == LCD_ON) { updateStreamLoop(); clearHelpScreen(); } updateStreamLoop(); drawControls(getLCDState() != LCD_ON); updateStreamLoop(); checkKeys(); executeQueuedControls(); // Split here because the state can change in checkKeys if(getLCDState() == LCD_ON) { #ifdef SCREENSHOT_MODE takeScreenshot(); #endif updateStreamLoop(); drawToScreen(); } else { updateStreamLoop(); checkEndSound(); } updateStreamLoop(); checkSleepState(); } #ifdef PROFILING counter++; if(counter == 700) { cygprofile_disable(); cygprofile_end(); } #endif } }
void WebcamHandler::run() { // initialize webcam VideoCapture cap = VideoCapture(0); cap.set(CV_CAP_PROP_FRAME_WIDTH, m_frameWidth); cap.set(CV_CAP_PROP_FRAME_HEIGHT, m_frameHeight); // initialize window namedWindow("Settings", CV_WINDOW_AUTOSIZE); namedWindow("FaceRepair", CV_WINDOW_NORMAL); cvSetWindowProperty("FaceRepair", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); cvWaitKey(1000); float* hidden; float* visible; while (m_loop) { // read frame and continue with next frame if not successfull Mat frame; cap.retrieve(frame); flip(frame, frame, 1); // take subimage at faceArea Mat subimage; frame(*m_faceArea).copyTo(subimage); Mat subimageHSV; cvtColor(subimage, subimageHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV // detect color Mat mask; inRange(subimageHSV, *m_detectionColorMin, *m_detectionColorMax, mask); erode(mask, mask, getStructuringElement(MORPH_ELLIPSE, Size(5, 5))); dilate(mask, mask, getStructuringElement(MORPH_ELLIPSE, Size(15, 15))); Mat invertedMask = 255 - mask; // scale to rbm input size Size size = Size(m_edgeLength, m_edgeLength); Mat scaledSubimage; resize(subimage, scaledSubimage, size, 0.0, 0.0, INTER_LINEAR); Mat scaledMask; resize(mask, scaledMask, size, 0.0, 0.0, INTER_NEAREST); Mat invertedScaledMask = 255 - scaledMask; // calc mean rgb of preserved area Scalar bgr = mean(scaledSubimage, invertedScaledMask); // set mean rgb at reconstructionArea scaledSubimage.setTo(bgr, scaledMask); // subimage to normalized float array visible = matToNormalizedFloatArrayWithBias(&scaledSubimage); // process RBMs hidden = m_rbm1000->runHidden(visible, 1); delete visible; hidden[0] = 1; visible = m_rbm1000->runVisible(hidden, 1); delete hidden; visible[0] = 1; resetPreservedArea(&scaledSubimage, &invertedScaledMask, visible); hidden = m_rbm1500->runHidden(visible, 1); delete visible; hidden[0] = 1; visible = m_rbm1500->runVisible(hidden, 1); delete hidden; visible[0] = 1; resetPreservedArea(&scaledSubimage, &invertedScaledMask, visible); hidden = m_rbm2000->runHidden(visible, 1); delete visible; hidden[0] = 1; visible = m_rbm2000->runVisible(hidden, 1); delete hidden; // normalized float array to subimage normalizedFloatArrayToMatWithoutBias(visible, &scaledSubimage); // scale to original faceArea size Mat result; size = Size(m_faceArea->width, m_faceArea->height); resize(scaledSubimage, result, size, 0.0, 0.0, INTER_CUBIC); // reset pixels of preserved area in native resolution subimage.copyTo(result, invertedMask); // create fullscreen image Mat fs; frame.copyTo(fs); result.copyTo(fs(*m_faceArea)); flip(fs, fs, 1); // maybe not necessary //result.copyTo(frame(*m_faceArea)); // paint visualizations for settings image rectangle(frame, *m_faceArea, Scalar(0, 255, 0)); Point* eyePositions = calculateEyePositions(m_faceArea, m_relativeEyePositionX, m_relativeEyePositionY); circle(frame, eyePositions[0], 4, Scalar(255, 255, 0)); circle(frame, eyePositions[1], 4, Scalar(255, 255, 0)); delete eyePositions; // show frames imshow("Settings", frame); imshow("FaceRepair", fs); // check keyboard input checkKeys(); } // terminate webcam cap.release(); }
int AddIn_main(int isAppli, unsigned short OptionNum) { int collided = 0; unsigned char answer; Bdisp_AllClr_DDVRAM(); Init_SerialPort(); Start_SerialPort(); if(connect() == 0) { isHost = 1; } while(1) { startScreen(); memset(videoBuffer, 0, 1024); DrawBox(0, 0, 127, 63, videoBuffer, BLACK); DrawBox(48, 27, 79, 37, videoBuffer, BLACK); CoolText(51, 29, FONT_FIVE, "Ready?", videoBuffer); DrawAll(videoBuffer); Sleep(1000); SerialTransmit(READY); while(SerialReceive() != READY) { ; } reset(); while(1) { answer = SerialReceive(); if(answer == CRASH) { score++; wonLast = ME; break; } if(answer == EXIT) { Reset_Calc(); } if(answer == COORDS) { receivedX = SerialReceive(); receivedY = SerialReceive(); setBit(videoBuffer, 128, receivedX, receivedY, 1); } checkKeys(); move(); collided = getBit(videoBuffer, 128, playerX, playerY); if(collided) { otherScore++; wonLast = OTHER; SerialTransmit(CRASH); break; } setBit(videoBuffer, 128, playerX, playerY, 1); SerialTransmit(COORDS); SerialTransmit(playerX); SerialTransmit(playerY); DrawAll(videoBuffer); Sleep(delays[speed]); } } return 1; }