Beispiel #1
0
int handleEvent(volatile struct Machine * m, Event e)
{
    if(e>=m->nEvents)
        return(SFSM_E_OOR); //event not handled Out Of Range
		
	if(m->processing >= 0) //event is processing
		if(m->eventBuffer==-1) { //buffer is free
			m->eventBuffer = e;
			return(SFSM_E_BUF); //event buffered
		}
		else
			return(SFSM_E_BOF); //event buffer overflow
	
	else {
		m->processing = e;
		_handleEvent(m,e);
	}
	
	if(m->eventBuffer!=-1) {//we have to process event in buffer
		_handleEvent(m,m->eventBuffer);
		m->eventBuffer = -1;
	}
	m->processing = -1;
	return(0);
}
void TouchEventController::_processEvents(){
    TouchEvent* curEvent;
    while( _eventQueue.size() > 0 ){
        curEvent = _eventQueue.front();
        _eventQueue.pop(); //seriously, you can't get the reference without handling it?        
        _handleEvent( curEvent );   
        
        delete curEvent;
    }
    
    
    if( !_touchMovedThisFrame && _eventQueue.size() > 0){
        curEvent = new TouchEvent();
        curEvent->args = ofTouchEventArgs();
        //curEvent->args.x = ofGetMouseX();
        //curEvent->args.y = ofGetMouseY();
        TouchEvent *lastEvent = _eventQueue.back();
        curEvent->args.x = lastEvent->args.x;
        curEvent->args.x = lastEvent->args.y;
        curEvent->type = STILL;
        
        _handleEvent(curEvent);
        delete curEvent;
    }
    _touchMovedThisFrame = false;
}
Beispiel #3
0
/**
 * Post a new Event
 * @param service The Service the event belongs to
 * @param id The event identification
 * @param state The event state
 * @param action Description of the event action
 * @param s Optional message describing the event
 */
void Event_post(Service_T service, long id, State_Type state, EventAction_T action, char *s, ...) {
        ASSERT(service);
        ASSERT(action);
        ASSERT(s);
        ASSERT(state == State_Failed || state == State_Succeeded || state == State_Changed || state == State_ChangedNot);

        va_list ap;
        va_start(ap, s);
        char *message = Str_vcat(s, ap);
        va_end(ap);

        Event_T e = service->eventlist;
        while (e) {
                if (e->action == action && e->id == id) {
                        gettimeofday(&e->collected, NULL);

                        /* Shift the existing event flags to the left and set the first bit based on actual state */
                        e->state_map <<= 1;
                        e->state_map |= ((state == State_Succeeded || state == State_ChangedNot) ? 0 : 1);

                        /* Update the message */
                        FREE(e->message);
                        e->message = message;
                        break;
                }
                e = e->next;
        }
        if (! e) {
                /* Only first failed/changed event can initialize the queue for given event type, thus succeeded events are ignored until first error. */
                if (state == State_Succeeded || state == State_ChangedNot) {
                        DEBUG("'%s' %s\n", service->name, message);
                        FREE(message);
                        return;
                }
                /* Initialize the event. The mandatory informations are cloned so the event is as standalone as possible and may be saved
                 * to the queue without the dependency on the original service, thus persistent and managable across monit restarts */
                NEW(e);
                e->id = id;
                gettimeofday(&e->collected, NULL);
                e->source = service;
                e->mode = service->mode;
                e->type = service->type;
                e->state = State_Init;
                e->state_map = 1;
                e->action = action;
                e->message = message;
                e->next = service->eventlist;
                service->eventlist = e;
        }
        e->state_changed = _checkState(e, state);
        /* In the case that the state changed, update it and reset the counter */
        if (e->state_changed) {
                e->state = state;
                e->count = 1;
        } else {
                e->count++;
        }
        _handleEvent(service, e);
}
Beispiel #4
0
void TWidget::_sendEvent(const TEvent& event, bool& consumed) {
    if (consumed == false) {
        _handleEvent(event, consumed);
    }

    if (consumed == false) {
        for (auto& child : children) {
            child.second->_sendEvent(event, consumed);
        }
    }
}
void MouseEventController::_processEvents(){
    MouseEvent* curEvent;
    while( _eventQueue.size() > 0 ){
        curEvent = _eventQueue.front();
        _eventQueue.pop(); //seriously, you can't get the reference without handling it?        
        _handleEvent( curEvent );   
        
        delete curEvent;
    }
    if( !_mouseMovedThisFrame ){
        curEvent = new MouseEvent();
        curEvent->args = ofMouseEventArgs();
        curEvent->args.x = ofGetMouseX();
        curEvent->args.y = ofGetMouseY();
        curEvent->type = STILL;
        
        _handleEvent(curEvent);
        delete curEvent;
    }
    _mouseMovedThisFrame = false;
}
	//-----------------------------------------------------------------------
	void ParticleObserver::_handleObserve (ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed)
	{
		if (mEnabled && mObserve)
		{
			if (mObserveUntilEvent && mEventHandlersExecuted)
			{
				// Don't continue if mObserveUntilEvent is set and the event handlers are already called once.
				return;
			}
			if (_observe(particleTechnique, particle, timeElapsed))
			{
				// Handle the event
				_handleEvent (particleTechnique, particle, timeElapsed);
			}
		}
	}
	//-----------------------------------------------------------------------
	void OnClearObserver::_postProcessParticles(ParticleTechnique* technique, Ogre::Real timeElapsed)
	{
		if (mContinue)
		{
			if (!(technique->getNumberOfEmittedParticles() > 0))
			{
				/** Handle the event. Use 0 as the particle pointer. This means that not all eventhandlers
					are suitable. If they expect a particle (and most eventhandlers do), it could
					result in an exception. Handlers such as the DoEnableComponentEventHandler and the
					DoStopSystemEventHandler however can be used without any problem.
				*/
				_handleEvent (technique, 0, timeElapsed);
				mContinue = false;
			}
		}
	}
Beispiel #8
0
    bool OnEvent(const SEvent& event)
    {
        if (event.EventType == irr::EET_KEY_INPUT_EVENT)
        {
            printf("Key: %d, down: %d\n", event.KeyInput.Key, event.KeyInput.PressedDown);
            switch(event.KeyInput.Key)
            {
            case KEY_SPACE:
                {
                    if(event.KeyInput.PressedDown)
                        _jump();
                }
                return true;
            case KEY_F1:
                {
                    if(event.KeyInput.PressedDown)
                    {
                        m_helpPanel->setVisible(!m_helpPanel->isVisible());
                    }
                    return true;
                }
            // adjust movement speed
#ifdef USE_IRR
            case KEY_LSHIFT:
            case KEY_SHIFT:
                {   
                    if(!m_fpsAnimator)
                        break;

                    if(event.KeyInput.PressedDown)
                    {
                        m_fpsAnimator->setMoveSpeed(m_moveSpeed * 3.f);
                    }
                    else
                    {
                        m_fpsAnimator->setMoveSpeed(m_moveSpeed);
                    }
                    return true;
                }
                break;
#endif

            // cycle render mode (normal/wireframe/pointcloud)
            case KEY_F3:
                {
                    if(event.KeyInput.PressedDown)
                    {
                        ++m_renderMode;
                        if(m_renderMode > 2)
                            m_renderMode = 0;
                        updateRenderMode(m_sceneManager->getRootSceneNode());
                        return true;
                    }                
                }
                break;

            // toggle physics debug
            case KEY_F4:
                if(!event.KeyInput.PressedDown)
                {
                    m_displayPhysicsDebug = m_displayPhysicsDebug ? false : true;
                    _enablePhysicsDebug(m_displayPhysicsDebug);
                    m_debugNode->setVisible(m_displayPhysicsDebug);
                    m_debugPanel->setVisible(m_displayPhysicsDebug);
                    return true;
                }
                break;

            case KEY_F5:
                if(event.KeyInput.PressedDown)
                {
                    _warp(m_startPos);
                    return true;
                }
                break;

            // screen shot
            case KEY_SNAPSHOT:
                {
                    if(!event.KeyInput.PressedDown) // key up
                    {
                        IImage* image = m_videoDriver->createScreenShot();
                        char buf[32];

                        sprintf(buf,"cap%.2d.png",m_capNumber++);

                        m_videoDriver->writeImageToFile(image,buf);

                        image->drop();
                    }
                    break;
                }

            // quit the app
            case KEY_ESCAPE:
                if(!event.KeyInput.PressedDown) // key up
                    m_running = false;
                return true;
            default:
                break;
            }
        }

        return _handleEvent(event);
    }
Beispiel #9
0
bool ViewData::handleEvent( eq::EventICommand command )
{
    const eq::Event& event = command.read< eq::Event >();
    return _handleEvent( event );
}
Beispiel #10
0
bool ViewData::handleEvent( const eq::ConfigEvent* event )
{
    return _handleEvent( event->data );
}
Beispiel #11
0
bool View::handleEvent(const ButtonEvent& event)
{
    return _handleEvent(event);
}
Beispiel #12
0
bool View::handleEvent(const AxisEvent& event)
{
    return _handleEvent(event);
}
Beispiel #13
0
bool View::handleEvent(eq::EventType type, const KeyEvent& event)
{
    return _handleEvent(type, event);
}