void QOpenWFDDevice::waitForPipelineBindSourceCompleteEvent() { mWaitingForBindSourceEvent = true; while (mWaitingForBindSourceEvent) { readEvents(WFD_FOREVER); } }
int InputDriverAbstract::listen() { int ret; ret = readEvents(); if (ret < 0) { // Failed } return ret; }
bool Game::gameLoop(){ ///main game loop update(); if(!readEvents()) return false; display(); return true; }
void EventMachineThread::clientConnect() { qDebug() << "New connection!"; QTcpSocket* client = m_server->nextPendingConnection(); connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnect())); connect(client, SIGNAL(readyRead()), this, SLOT(readEvents())); m_sockets.push_back(client); }
void processInotifyEvent(FileWatcher *watcher) { int ret; while (watcher->trigger && watcher->watched_item_number >= 0) { struct timeval time_to_wait; time_to_wait.tv_sec = watcher->timeout; time_to_wait.tv_usec = 0; int pid = getTracerpid(watcher->tracerPath, watcher->child); if (pid > 0) { LOGD("%d being traced, tracer pid is %d. Terminating...", watcher->pid, pid); watcher->trigger = false; break; } int r = handleSelect(watcher->fd, &time_to_wait); if (r < 0) { LOGE("select failed [error:%d, desc:%s]", errno, strerror(errno)); } else if (r > 0) { //handle event int event = readEvents(watcher); if (event < 0) { LOGE("inotify_event read failed [errno:%d, desc:%s]", errno, strerror(errno)); break; } else { handleEvents(watcher); // communicating if (watcher->sinfo) { ret = communicate_send(watcher->sinfo); if (ret == -1) { LOGI("Lost connection.\n"); watcher->trigger = false; if (watcher->sinfo->callback) { (watcher->sinfo->callback)(); } break; } } } } else if (r == 0) { // communicating if (watcher->sinfo) { ret = communicate_send(watcher->sinfo); if (ret == -1) { LOGI("Lost connection.\n"); watcher->trigger = false; if (watcher->sinfo->callback) { (watcher->sinfo->callback)(); } break; } } } } }
int main(){ struct Event* ptr; readEvents(&ptr); menu(ptr); writeFile(ptr); return 0; }
void UDPInterface::readPendingDatagrams(){ while (socket->hasPendingDatagrams()) { QByteArray datagram; datagram.resize(socket->pendingDatagramSize()); QHostAddress sender; quint16 senderPort; socket->readDatagram(datagram.data(), datagram.size(),&sender, &senderPort); readEvents(datagram); } }
// Author V.Fine 06/12/2001 BNL mailto:[email protected] // This run Pythia using ROOT TPYthia6 interface // Thanks Michael Bussmann <*****@*****.**> for Pythia living example void ReadPythia(const char *fileName="pythia.root") { struct pythia_particle { Int_t status; // status of particle ( LUJETS K[1] ) Int_t pdg_id; // flavour code ( LUJETS K[2] ) Int_t parent; // parrent's id ( LUJETS K[3] ) Int_t firstChild; // id of first child ( LUJETS K[4] ) Int_t lastChild; // id of last child ( LUJETS K[5] ) Float_t momentum[4]; // X.Y,Z,energy momenta [GeV/c]( LUJETS P[1]=P[4] ) Float_t mass; // Mass [Gev/c^2] ( LUJETS P[5] ) Float_t vertex[4]; // X,Y,Z vertex [mm]; time of procuction [mm/c]( LUJETS V[1]-V[4] ) Float_t lifetime; // proper lifetime [mm/c] ( LUJETS V[5] ) }; TFileIter readEvents(fileName); TObject *nextObject = 0; // the number of the object available directly from "MyDataSet.root" Int_t size = readEvents.TotalKeys(); printf(" The total number of the events: %d\n",size); //----------------------------------------------------------------------- // Loop over all events, read them in to memory one by one printf(" -- > Loop over all events, read them in to memory one by one < -- \n"); for( readEvents = 0; int(readEvents) < size; readEvents.SkipObjects() ){ nextObject = *readEvents; printf(" %d bytes of the object \"%s\" of class \"%s\" written with TKey \"%s\" has been read from file\n" ,readEvents.GetObjlen() ,nextObject->GetName() ,nextObject->IsA()->GetName() ,(const char *)readEvents ); TDataSet *event = (TDataSet *)nextObject; event->ls(9); delete nextObject; } }
int EventList::exec(const t_channel_id channel_id, const std::string& channelname) // UTF-8 { neutrino_msg_t msg; neutrino_msg_data_t data; bool in_search = 0; // windows size width = w_max ( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 )); height = h_max ( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20)); //iheight = 30; // FIXME: info bar height (see below, hard coded at this time) int icon_w; int icon_h; frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icon_w, &icon_h); iheight = std::max(icon_h, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()) + 6;; // theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight(); fheight1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight(); { int h1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getHeight(); int h2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getHeight(); fheight2 = (h1 > h2) ? h1 : h2; } fheight = fheight1 + fheight2 + 2; fwidth1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth("DDD, 00:00, "); fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth("[999 min] "); listmaxshow = (height - theight - iheight)/fheight; // recalculate height height = theight + iheight + listmaxshow*fheight; // recalc height x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; int res = menu_return::RETURN_REPAINT; if(m_search_list == SEARCH_LIST_NONE) // init globals once only { m_search_epg_item = SEARCH_EPG_TITLE; m_search_list = SEARCH_LIST_CHANNEL; m_search_bouquet_id= bouquetList->getActiveBouquetNumber(); } m_search_channel_id = channel_id; m_showChannel = false; // do not show the channel in normal mode, we just need it in search mode name = channelname; sort_mode = SORT_DESCRIPTION; paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); // blit frameBuffer->blit(); int oldselected = selected; unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); bool loop = true; while (loop) { g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd); if ( msg <= CRCInput::RC_MaxRC ) timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); if (msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup) { int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 selected -= step; if((prev_selected-step) < 0) // because of uint selected = evtlist.size() - 1; paintItem(prev_selected - liststart, channel_id); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(channel_id); else paintItem(selected - liststart, channel_id); } else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown) { unsigned int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 selected += step; if(selected >= evtlist.size()) { if (((evtlist.size() / listmaxshow) + 1) * listmaxshow == evtlist.size() + listmaxshow) // last page has full entries selected = 0; else selected = ((step == listmaxshow) && (selected < (((evtlist.size() / listmaxshow) + 1) * listmaxshow))) ? (evtlist.size() - 1) : 0; } paintItem(prev_selected - liststart, channel_id); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(channel_id); else paintItem(selected - liststart, channel_id); } // sort else if (msg == (neutrino_msg_t)g_settings.key_channelList_sort) { unsigned long long selected_id = evtlist[selected].eventID; if(sort_mode == SORT_DESCRIPTION) // by description { sort_mode++; sort(evtlist.begin(), evtlist.end(), sortByDescription); } else// datetime { sort_mode = SORT_DESCRIPTION; sort(evtlist.begin(), evtlist.end(), sortByDateTime); } // find selected for ( selected = 0 ; selected < evtlist.size(); selected++ ) { if ( evtlist[selected].eventID == selected_id ) break; } oldselected = selected; if(selected <=listmaxshow) liststart=0; else liststart=(selected/listmaxshow)*listmaxshow; hide(); paintHead(channel_id); paint(channel_id); showFunctionBar(true); } // epg reload else if (msg == (neutrino_msg_t)g_settings.key_channelList_reload) { sort_mode = SORT_DESCRIPTION; hide(); paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } // add record else if ( msg == (neutrino_msg_t)g_settings.key_channelList_addrecord ) { if (recDir != NULL) { int tID = -1; CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID); if(etype == CTimerd::TIMER_RECORD) { g_Timerd->removeTimerEvent(tID); timerlist.clear(); g_Timerd->getTimerList(timerlist); paint(channel_id); continue; } if (recDir != NULL) { if (g_Timerd->addRecordTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime + evtlist[selected].duration, evtlist[selected].eventID, evtlist[selected].startTime, evtlist[selected].startTime - (ANNOUNCETIME + 120), TIMERD_APIDS_CONF, true, recDir,false) == -1) { if(askUserOnTimerConflict(evtlist[selected].startTime - (ANNOUNCETIME + 120), evtlist[selected].startTime + evtlist[selected].duration)) { g_Timerd->addRecordTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime + evtlist[selected].duration, evtlist[selected].eventID, evtlist[selected].startTime, evtlist[selected].startTime - (ANNOUNCETIME + 120), TIMERD_APIDS_CONF, true, recDir,true); MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } } else { MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } } timerlist.clear(); g_Timerd->getTimerList(timerlist); paint(channel_id); } } // add remind else if ( msg == (neutrino_msg_t) g_settings.key_channelList_addremind ) { int tID = -1; CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID); if(etype == CTimerd::TIMER_ZAPTO) { g_Timerd->removeTimerEvent(tID); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(channel_id); continue; } g_Timerd->addZaptoTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime - ANNOUNCETIME, 0, evtlist[selected].eventID, evtlist[selected].startTime, 0); MessageBox(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(channel_id); } else if (msg == CRCInput::RC_timeout) { selected = oldselected; loop = false; } else if (msg == (neutrino_msg_t)g_settings.key_channelList_cancel) { if(in_search) { in_search = false; name = channelname; paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } else { selected = oldselected; loop = false; } } else if (msg == CRCInput::RC_epg) { hide(); CEPGplusHandler eplus; eplus.exec(NULL, ""); paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } else if ( msg==CRCInput::RC_left ) { loop = false; } else if ( msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg == CRCInput::RC_info) { if ( evtlist[selected].eventID != 0 ) { hide(); res = g_EpgData->show(channel_id, evtlist[selected].eventID, &evtlist[selected].startTime); if ( res == menu_return::RETURN_EXIT_ALL ) { loop = false; } else { g_RCInput->getMsg( &msg, &data, 0 ); if ( ( msg != CRCInput::RC_red ) && ( msg != CRCInput::RC_timeout ) ) { // RC_red schlucken g_RCInput->postMsg( msg, data ); } timerlist.clear(); g_Timerd->getTimerList (timerlist); paintHead(channel_id); paint(channel_id); showFunctionBar(true); } } } else if ( msg == CRCInput::RC_green ) { in_search = findEvents(); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); } else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { g_RCInput->postMsg (msg, 0); res = menu_return::RETURN_EXIT_ALL; loop = false; } else { if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { loop = false; res = menu_return::RETURN_EXIT_ALL; } } // blit frameBuffer->blit(); } hide(); return res; }