void CustomTriggerManager::UpdateTrigger (CustomTriggerController* const controller)
{
	NewtonBody* const triggerBody = controller->GetBody();
	dTree<NewtonBody*,NewtonBody*>& manifest = controller->m_manifest;

	for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint (triggerBody); joint; joint = NewtonBodyGetNextContactJoint (triggerBody, joint)) {

		int isActive = NewtonJointIsActive (joint);
		NewtonBody* const body0 = NewtonJointGetBody0(joint);
		NewtonBody* const body1 = NewtonJointGetBody1(joint);
		NewtonBody* const passangerBody = (body0 != triggerBody) ? body0 : body1; 
		
		if (isActive) {
			dTree<NewtonBody*,NewtonBody*>::dTreeNode* const passengerNode = manifest.Find (passangerBody);
			if (passengerNode) {
				EventCallback (controller, m_inTrigger, passangerBody);

			} else {
				CustomScopeLock lock (&m_lock);
				manifest.Insert (passangerBody, passangerBody);
				EventCallback (controller, m_enterTrigger, passangerBody);
			} 
		} else {
			dTree<NewtonBody*,NewtonBody*>::dTreeNode* const passengerNode = manifest.Find (passangerBody);

			if (passengerNode) {
				EventCallback (controller, m_exitTrigger, passangerBody);

				CustomScopeLock lock (&m_lock);
				manifest.Remove (passengerNode);
			}
		}
	}
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------------------
void Observer::add_handler(int eventType, void* pThis,
                           void (*pt2Func)(void* pObj, SpEventInfo event) )
{
    remove_old_handler(eventType);
    EventCallback* pData = LOMSE_NEW EventCallback(eventType, pThis, pt2Func);
    m_handlers.push_back(pData);
}
Exemplo n.º 3
0
	void KeyObject::ProcessEvent(Event event) {
		switch (event.type) {
		case Event::E_MOUSE_ENTERED:
				state_ = OUTLINED;
			break;
		case Event::E_MOUSE_EXITED:
				state_ = DEFAULT;
			break;
		case Event::E_MOUSE_PRESSED:
			state_ = ACTIVE;
			break;
		case Event::E_MOUSE_RELEASED:
			if (state_ == ACTIVE && event.focus == this) {
				event.focus = this;
				event.type = Event::E_GAME_EVENT;
				event.gameEvent = GameEvent::KEY_CLICK;
				Game::GetInstance()->GetEventManager()->AddEvent(event);
			}
			state_ == OUTLINED;
			break;
		case Event::E_HIRAGANA_DRAWN:
		case Event::E_LOAD_STATE:
			EventCallback(event);
			break;
		}
	}
SoundEffectManager::SoundEffectManager()
{
	EVENTSERVICE->listen(typeid(SpellCastEvent),  EventCallback(&SoundEffectManager::onCast, this));
	for (auto c : soundEffectsFilenames)
	{
		SOUNDSERVICE->loadEffect(c.second, c.first);
	}
}
Exemplo n.º 5
0
void CSerialPDD::SetReceiveError(ULONG ulNewErrors)
{
    if ( ulNewErrors!=0) {
        m_HardwareLock.Lock();
        m_ulCommErrors |= ulNewErrors;
        m_HardwareLock.Unlock();
        EventCallback(EV_ERR);
    }
}
Exemplo n.º 6
0
BOOL CSerialPDD::NotifyPDDInterrupt(INTERRUPT_TYPE interruptType)
{
    m_InterruptLock.Lock();
    // The interrupt is define as Bit event.
    m_dwInterruptFlag |= (DWORD)interruptType;
    m_InterruptLock.Unlock();
    if (IsPowerResumed ( )) {
        if (m_lOpenCount) { // If application is opened.
            EventCallback( EV_POWER );
        }
        else {
            if (GetModemStatus() & MS_RLSD_ON)
                CeEventHasOccurred (NOTIFICATION_EVENT_RS232_DETECTED, NULL);
        }
    }
    m_InterruptLock.Lock();
    SerialEventHandler(m_pMdd);
    m_InterruptLock.Unlock();
    return TRUE;
}
Exemplo n.º 7
0
 virtual ULONG   GetModemStatus()
 {
     ULONG ulReturn = CPdd6410Uart::GetModemStatus();
     ULONG ulEvent = 0;
     m_HardwareLock.Lock();
     BOOL fIsDSRSet = (((*m_pDSRPort) & (1<<m_dwDSRPortNum))==0);
     RETAILMSG(FALSE, (TEXT("DEBUG: DSRPort Register 0x%lx, Value 0x%lx, fIsDSRSet(%d).\r\n"), m_pDSRPort, *m_pDSRPort, fIsDSRSet)); 
     if (fIsDSRSet != m_fIsDSRSet)
     {
         ulEvent |= EV_DSR | EV_RLSD;
         RETAILMSG(FALSE, (TEXT("DEBUG: DSRPort Register 0x%lx, Value 0x%lx, fIsDSRSet(%d).\r\n"), m_pDSRPort, *m_pDSRPort, fIsDSRSet)); 
     }
     ulReturn |= (fIsDSRSet?(MS_DSR_ON|MS_RLSD_ON):0);
     m_fIsDSRSet = fIsDSRSet;
     m_HardwareLock.Unlock();
     if (ulEvent!=0)
     {
         EventCallback(ulEvent,ulReturn);
     }
     return ulReturn;
 }
Exemplo n.º 8
0
BOOL CSerialPDD::DataReplaced(PBYTE puData,BOOL isBadData)
{
    BOOL bReturn = FALSE;
    if (puData) {
        UCHAR inputData= *puData;
        if (m_DCB.fDsrSensitivity && IsDSROff() ) {
        }
        else 
        if (inputData==NULL &&  m_DCB.fNull) {
        }
        else {
            bReturn = TRUE;
            if (m_DCB.fErrorChar && isBadData) {
                inputData = m_DCB.ErrorChar;
            }
            else 
            if (inputData == m_DCB.EvtChar) {
                EventCallback(EV_RXFLAG );
            }
            *puData = inputData;
        }
    }
    return bReturn;
}
Exemplo n.º 9
0
//---------------------------------------------------------------------------------------
void Observer::add_handler(int eventType, EventHandler* pHandler)
{
    remove_old_handler(eventType);
    EventCallback* pData = LOMSE_NEW EventCallback(eventType, pHandler);
    m_handlers.push_back(pData);
}