void Runtime::pause(int timeout) { if (timeout == -1) { pollEvents(true); if (hasEvent()) { MAEvent *event = popEvent(); processEvent(*event); delete event; } } else { int slept = 0; while (1) { pollEvents(false); if (isBreak()) { break; } else if (hasEvent()) { MAEvent *event = popEvent(); processEvent(*event); delete event; } usleep(WAIT_INTERVAL * 1000); slept += WAIT_INTERVAL; if (timeout > 0 && slept > timeout) { break; } } } }
MAEvent Runtime::processEvents(int waitFlag) { switch (waitFlag) { case 1: // wait for an event _output->flush(true); pollEvents(true); break; case 2: _output->flush(false); pause(WAIT_INTERVAL); break; default: pollEvents(false); } MAEvent event; if (hasEvent()) { MAEvent *nextEvent = popEvent(); processEvent(*nextEvent); event = *nextEvent; delete nextEvent; } else { event.type = 0; } return event; }
// // ISDL12JoystickInputDevice::getEvent // // Removes the first event from the queue and returns it. // This makes no checks to ensure there actually is an event in the queue and // if there is not, the behavior is undefined. // void ISDL12JoystickInputDevice::getEvent(event_t* ev) { assert(hasEvent()); memcpy(ev, &mEvents.front(), sizeof(event_t)); mEvents.pop(); }
void cUObject::addEvent( WPDefaultScript *Event ) { if( hasEvent( Event->getName() ) ) return; scriptChain.push_back( Event ); eventList_.push_back( Event->getName() ); changed( SAVE ); }
/*! Removes an event handler from the object */ void cUObject::removeEvent( const QString& name ) { cPythonScript *event = 0; if( scriptChain && hasEvent( name ) ) { unsigned int count = reinterpret_cast< unsigned int >( scriptChain[0] ); if( count == 1 ) { clearEvents(); } else { unsigned int pos = 1; cPythonScript **newScriptChain = new cPythonScript*[ count ]; newScriptChain[0] = reinterpret_cast< cPythonScript* >( count - 1 ); for( unsigned int i = 1; i < count; ++i ) { if( scriptChain[i]->name() != name ) { newScriptChain[pos++] = scriptChain[i]; } else { event = scriptChain[i]; } } delete [] scriptChain; scriptChain = newScriptChain; } } if( eventList_ != QString::null ) { QStringList eventList = QStringList::split( ",", eventList_ ); eventList.remove( name ); eventList_ = eventList.join( "," ); if( eventList_.isEmpty() ) eventList_ = QString::null; } changed_ = true; if (event && event->canHandleEvent(EVENT_ATTACH)) { PyObject *args = Py_BuildValue("(N)", getPyObject()); event->callEvent(EVENT_ATTACH, args); Py_DECREF(args); } }
bool CycleAB::isReadyToCycle() { if (!waitForCycleEventState.isActive()) { return false; } if (hasEvent(&cycleEvent)) { return false; } return true; }
bool RprMidiTake::hasEventType(RprMidiEvent::MessageType messageType) { if(messageType == RprMidiEvent::NoteOn || messageType == RprMidiEvent::NoteOff) { return countNotes() > 0; } if(messageType == RprMidiEvent::CC) { for(int i = 0; i < 128; ++i) { if( countCCs(i) > 0) { return true; } } } return hasEvent(mOtherEvents, messageType); }
/*! Adds an event handler to this object */ void cUObject::addEvent(cPythonScript *event) { if(hasEvent(event->name())) { return; } // Reallocate the ScriptChain if (scriptChain) { unsigned int count = reinterpret_cast<unsigned int>(*scriptChain); cPythonScript **newScriptChain = new cPythonScript* [count + 2]; memcpy(newScriptChain, scriptChain, (count + 1) * sizeof(cPythonScript*)); newScriptChain[0] = reinterpret_cast<cPythonScript*>(count + 1); newScriptChain[count + 1] = event; delete [] scriptChain; scriptChain = newScriptChain; } else { scriptChain = new cPythonScript*[2]; scriptChain[0] = reinterpret_cast<cPythonScript*>(1); scriptChain[1] = event; } if (eventList_.isEmpty()) { eventList_ = event->name(); } else { eventList_.append("," + event->name()); } changed_ = true; if (event->canHandleEvent(EVENT_ATTACH)) { PyObject *args = Py_BuildValue("(N)", getPyObject()); event->callEvent(EVENT_ATTACH, args); Py_DECREF(args); } }
void clarityEventLoopStart(ClarityEventLoop *eventLoop) { while (hasEvent(eventLoop)) dequeue(eventLoop); }