예제 #1
0
void ScheduleEvent(s64 cycles_into_future, int event_type, u64 userdata) {
    Event* new_event = GetNewEvent();
    new_event->userdata = userdata;
    new_event->type = event_type;
    new_event->time = GetTicks() + cycles_into_future;
    AddEventToQueue(new_event);
}
예제 #2
0
// This must be run ONLY from within the cpu thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance 
void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata)
{
	Event *ne = GetNewEvent();
	ne->userdata = userdata;
	ne->type = event_type;
	ne->time = globalTimer + cyclesIntoFuture;
	AddEventToQueue(ne);
}
MainEvent_t RunEventHandler (void)
{
	MainEvent_t returnEvent = NO_EVENT;
	uint8_t currentButtonStatus = 0;


	//BT Receive Message EVENT

	//MPU-9250 Event Handler
	if (GetMPU_9250FlagStatus() == NEW_DATA) {
		ClearMPU_9250InterruptFlag();
		intrruptCount++;
		if (AddEventToQueue(MPU_9250_DATA_READY) != ADDED_TO_QUEUE)
			returnEvent = QUEUE_FULL;

	}
	//Joystick Event Handler
	if (IsTimerExpired(JOYSTICK_SAMPLE_TIMER)) {
		ClearTimerExpiredFlag(JOYSTICK_SAMPLE_TIMER);
		InitTimer(JOYSTICK_SAMPLE_TIMER, TIME_JOYSTICK_SAMPLE);
		if(AddEventToQueue(SAMPLE_TIMER) != ADDED_TO_QUEUE)
			returnEvent =  QUEUE_FULL;

	}
	//Button Event Handler
	currentButtonStatus = ReadAllButtons();
	if (currentButtonStatus != lastButtonStatus) {
		if(AddEventToQueue(BUTTON_PRESSED) != ADDED_TO_QUEUE)
			returnEvent = QUEUE_FULL;
		lastButtonStatus = currentButtonStatus;
	}
	//Send BT Data Event Handler
	if (IsTimerExpired(SEND_BT_TIMER)) {
		ClearTimerExpiredFlag(SEND_BT_TIMER);
		InitTimer(SEND_BT_TIMER, TIME_BT_SEND);
		if(AddEventToQueue(SEND_TIMER) != ADDED_TO_QUEUE)
			returnEvent = QUEUE_FULL;

	}

	returnEvent = GetEventFromQueue();

	return returnEvent;
}
예제 #4
0
// This must be run ONLY from within the CPU thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance
void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata)
{
	// TODO: Fix UI thread safety problems, and enable this assertion
	//_assert_msg_(POWERPC, Core::IsCPUThread(), "ScheduleEvent from wrong thread");
	Event *ne = GetNewEvent();
	ne->userdata = userdata;
	ne->type = event_type;
	ne->time = globalTimer + cyclesIntoFuture;
	AddEventToQueue(ne);
}
예제 #5
0
// This must be run ONLY from within the CPU thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance
void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata)
{
	_assert_msg_(POWERPC, Core::IsCPUThread() || Core::GetState() == Core::CORE_PAUSE,
				 "ScheduleEvent from wrong thread");
	Event *ne = GetNewEvent();
	ne->userdata = userdata;
	ne->type = event_type;
	ne->time = globalTimer + cyclesIntoFuture;
	AddEventToQueue(ne);
}
예제 #6
0
void MoveEvents()
{
	BaseEvent sevt;
	while (tsQueue.Pop(sevt))
	{
		Event *evt = GetNewEvent();
		evt->time = sevt.time;
		evt->userdata = sevt.userdata;
		evt->type = sevt.type;
		AddEventToQueue(evt);
	}
}
예제 #7
0
// This must be run ONLY from within the CPU thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance
void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
{
	_assert_msg_(POWERPC, Core::IsCPUThread() || Core::GetState() == Core::CORE_PAUSE,
				 "ScheduleEvent from wrong thread");

	Event *ne = GetNewEvent();
	ne->userdata = userdata;
	ne->type = event_type;
	ne->time = GetTicks() + cyclesIntoFuture;

	// If this event needs to be scheduled before the next advance(), force one early
	if (!globalTimerIsSane)
		ForceExceptionCheck(cyclesIntoFuture);


	AddEventToQueue(ne);
}
예제 #8
0
void MoveEvents() {
    has_ts_events = false;

    std::lock_guard<std::recursive_mutex> lock(external_event_section);
    // Move events from async queue into main queue
    while (ts_first) {
        Event* next = ts_first->next;
        AddEventToQueue(ts_first);
        ts_first = next;
    }
    ts_last = nullptr;

    // Move free events to threadsafe pool
    while (allocated_ts_events > 0 && event_pool) {
        Event* event = event_pool;
        event_pool = event->next;
        event->next = event_ts_pool;
        event_ts_pool = event;
        allocated_ts_events--;
    }
}
예제 #9
0
void MoveEvents()
{
	std::lock_guard<std::recursive_mutex> lk(externalEventSection);
		// Move events from async queue into main queue
	while (tsFirst)
	{
		Event *next = tsFirst->next;
		AddEventToQueue(tsFirst);
		tsFirst = next;
	}
	tsLast = NULL;

	// Move free events to threadsafe pool
	while(allocatedTsEvents > 0 && eventPool)
	{
		Event *ev = eventPool;
		eventPool = ev->next;
		ev->next = eventTsPool;
		eventTsPool = ev;
		allocatedTsEvents--;
	}
}