コード例 #1
0
//==============================================================================
void EventManager::deleteEventsMarkedForDeletion()
{
	SceneAllocator<Event> al = getSceneAllocator();

	// Gather events for deletion
	SceneFrameVector<EventsContainer::iterator> 
		forDeletion(getSceneFrameAllocator());

	for(EventsContainer::iterator it = events.begin(); it != events.end(); ++it)
	{
		Event* event = *it;
		if(event->isMarkedForDeletion())
		{
			forDeletion.push_back(it);
		}
	}

	// Delete events
	for(auto it : forDeletion)
	{
		Event* event = *it;

		unregisterEvent(event);
		al.deleteInstance(event);
	}
}
コード例 #2
0
//==============================================================================
void EventManager::deleteEventsMarkedForDeletion()
{
	SceneAllocator<U8> alloc = getSceneAllocator();

	// Check if nodes are marked for deletion
	if(true)
	{
		auto it = m_events.getBegin();
		auto end = m_events.getEnd();
		for(; it != end; ++it)
		{
		}
	}

	// Gather events for deletion
	while(m_markedForDeletionCount != 0)
	{
		auto it = m_events.getBegin();
		auto end = m_events.getEnd();
		for(; it != end; ++it)
		{
			Event* event = *it;
			if(event->getMarkedForDeletion())
			{
				unregisterEvent(it);
				alloc.deleteInstance<Event>(event);
				--m_markedForDeletionCount;
				break;
			}
		}
	}
}
コード例 #3
0
//!***************************************************************
//! @details:
//! handles SDL events, we need this to make sure we capture
//! focus lost events on our window
//!
//! @param[in]: evt
//! SDL event
//!
//! @return: 
//! bool
//! 
//!***************************************************************
bool ScreenScroller::onSdlEvent(SDL_Event& evt)
{
	// if it is a mouse focus event and we have lost focus
	// then we need to unregister for events until
	// we have regained focus
	if (evt.type == SDL_ACTIVEEVENT 
		&& (evt.active.state & SDL_APPMOUSEFOCUS) 
		&& !evt.active.gain)
	{
		unregisterEvent();
		return true;
	}

	return false;
}
コード例 #4
0
//!***************************************************************
//! @details:
//! this is called by the time manager on an interval for event
//! notification, we will use this to change our location if we
//! should be scrolling
//!
//! @param: time
//!
//! @return: 
//! void
//! 
//!***************************************************************
void ScreenScroller::updateEvent(uint32_t time)
{
	if (m_shouldScroll)
	{
		FIFE::Location camLocation(m_camera->getLocationRef());
		FIFE::ExactModelCoordinate mapCoords = m_camera->toMapCoordinates(m_scrollCoords, false);
		mapCoords.z = 0.0;
		camLocation.setMapCoordinates(mapCoords);

		m_camera->setLocation(camLocation);
	}
	else
	{
		unregisterEvent();
	}
}
コード例 #5
0
ファイル: JdwpEvent.cpp プロジェクト: handgod/soma
/*
 * Remove all entries from the event list.
 */
void dvmJdwpUnregisterAll(JdwpState* state)
{
    lockEventMutex(state);

    JdwpEvent* pEvent = state->eventList;
    while (pEvent != NULL) {
        JdwpEvent* pNextEvent = pEvent->next;

        unregisterEvent(state, pEvent);
        dvmJdwpEventFree(pEvent);
        pEvent = pNextEvent;
    }

    state->eventList = NULL;

    unlockEventMutex(state);
}
コード例 #6
0
ファイル: JdwpEvent.cpp プロジェクト: handgod/soma
/*
 * Remove the event with the given ID from the list.
 *
 * Failure to find the event isn't really an error, but it is a little
 * weird.  (It looks like Eclipse will try to be extra careful and will
 * explicitly remove one-off single-step events.)
 */
void dvmJdwpUnregisterEventById(JdwpState* state, u4 requestId)
{
    lockEventMutex(state);

    JdwpEvent* pEvent = state->eventList;
    while (pEvent != NULL) {
        if (pEvent->requestId == requestId) {
            unregisterEvent(state, pEvent);
            dvmJdwpEventFree(pEvent);
            goto done;      /* there can be only one with a given ID */
        }

        pEvent = pEvent->next;
    }

    //ALOGD("Odd: no match when removing event reqId=0x%04x", requestId);

done:
    unlockEventMutex(state);
}
コード例 #7
0
ファイル: JdwpEvent.cpp プロジェクト: handgod/soma
/*
 * Run through the list and remove any entries with an expired "count" mod
 * from the event list, then free the match list.
 */
static void cleanupMatchList(JdwpState* state, JdwpEvent** matchList,
    int matchCount)
{
    JdwpEvent** ppEvent = matchList;

    while (matchCount--) {
        JdwpEvent* pEvent = *ppEvent;

        for (int i = 0; i < pEvent->modCount; i++) {
            if (pEvent->mods[i].modKind == MK_COUNT &&
                pEvent->mods[i].count.count == 0)
            {
                ALOGV("##### Removing expired event");
                unregisterEvent(state, pEvent);
                dvmJdwpEventFree(pEvent);
                break;
            }
        }

        ppEvent++;
    }

    free(matchList);
}
コード例 #8
0
//!***************************************************************
//! @details:
//! destructor
//! 
//!***************************************************************
ScreenScroller::~ScreenScroller()
{
	unregisterEvent();
}
コード例 #9
0
ファイル: events.cpp プロジェクト: piif/ArduinoTools
void Events::waitNext(word sleepMode) {
	if (queueSize >= MAX_QUEUE_SIZE) {
		LOG("Queue was full");
		queueSize = MAX_QUEUE_SIZE;
	}

	bool found = false;
	unsigned long now = 0, next = 0xffffffffL;

	// loop on event queue THEN on timers
	// but at end of event queue, we may have new items in queue => must loop
	do {
		// for each fired events, call callback
		for (int q = 0; q < queueSize; q++) {
			for (int h = 0; h < eventHandlerMax; h++) {
				if (eventQueueTypes[q] == handlers[h].type) {
					// this handler may be for this event
					eventHandler *hdl = &(handlers[h]);

					if (hdl->type == event_input) {
						// is it for this interrupt ?
						if (hdl->inputSpec.interrupt == eventQueueDetails[q]) {
							hdl->callback(eventQueueDetails[q], hdl->data);
						}
					} else if (hdl->type == event_analogcomp) {
						bool state = analogCompValue() ? RISING : FALLING;
						if (hdl->analogCompSpec.mode == CHANGE || hdl->analogCompSpec.mode == state) {
							hdl->callback(state, hdl->data);
						}
					} else if (hdl->type >= 10) {
						hdl->callback(eventQueueDetails[q], hdl->data);
					}
				}
			}
		}
		// if a handler fired an event in queue, loop will continue on it
		// => here, we can empty it safely
		queueSize = 0;

		// look at expired timer events + compute next time
		// TODO : must avoid to use millis/micros
		// => must compute our own time elapsed since preceding call, using timer values
#ifdef WITHOUT_MILLIS_FUNCTIONS
		now = myMillis() * 1000;
#else
		now = (millis() * 1000) + (micros() % 1000);
#endif
		next = 0xffffffffL;

		for (int h = 0; h < eventHandlerMax; h++) {
			eventHandler *hdl = &(handlers[h]);

			if (hdl->type == event_timer) {
				// is it expired ? => handle
				if (hdl->timerSpec.next <= now + TIMER_EVENT_PRECISION) {
					hdl->callback(hdl->timerSpec.count - 1, hdl->data);
					if (hdl->timerSpec.count == 1) {
						// last timer iteration => remove it
						unregisterEvent(hdl);
						hdl->timerSpec.next  = 0xffffffffL;
					} else {
						if (hdl->timerSpec.count > 0) {
							// remaining iterations => just update counter
							hdl->timerSpec.count--;
						}
						// infinite iterations, or remaining ones => compute next time
						do {
							hdl->timerSpec.next += hdl->timerSpec.delay * 1000;
							// loop over iterations in case we missed some
						} while(hdl->timerSpec.next < now + TIMER_EVENT_PRECISION);
					}
				}

				if (next > hdl->timerSpec.next) {
					next = hdl->timerSpec.next;
					found = true;
				}
			}
		}
		// here, timer handler having queued new events must be handled => loop
	} while (queueSize > 0);

	if (!found) {
		if (defaultTimeout == 0) {
			sleepNow(sleepMode);
		} else {
			// wait in a interruptible manner, until default timeout
			delayIdleWith(defaultTimeout, defaultTimer, sleepMode, true);
		}
	} else {
		// wait in a interruptible manner
		// TODO : remove time elapsed since "now" calculation, but risks to be too late
		// round value too TIMER_EVENT_PRECISION multiple
		long delay = next - now, rem = delay % TIMER_EVENT_PRECISION;
		if (rem > TIMER_EVENT_PRECISION / 2) {
			delay -= rem + TIMER_EVENT_PRECISION;
		} else {
			delay -= rem;
		}
		delayIdleWith(delay, defaultTimer, sleepMode, true);
	}

	analogCompAlready = false;
	eventLoop++;
}