예제 #1
0
	void WinInputDeviceKeyBoard::Tick(f32 _fDeltaTime)
	{
		if(IsPlugged() == false)
		{
			HRESULT	hr = m_poDXKBDevice->Acquire();
			if(FAILED(hr))
				return;
			else
				SetPlugged(true);
		}
		Char     buffer[256]; 
		HRESULT  hr; 
		hr = m_poDXKBDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer); 
		if(FAILED(hr))
		{ 
			if(hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) 
			{
				//SetAcquire();
				SetPlugged(false);
				return;
			}
			return; 
		} 
		for(s32 i = 1; i <= DIK_DELETE; i++)
		{
			m_poManager->PostButtonEvent(_Convert[i], buffer[i] & 0x80 ? E_KS_Down : E_KS_Up);
		}
	}
예제 #2
0
	void WinInputDeviceMouse::Tick(f32 _fDeltaTime)
	{
		if(IsPlugged() == false)
		{
			HRESULT	hr = m_poDXMouseDevice->Acquire();
			if(FAILED(hr))
				return;
			else
				SetPlugged(true);
		}

		//InvalidateCursorRect(m_poWnd);
		Bool	bDone = false;
		HRESULT	hr;
		s16		x = 0, y = 0;
		while (!bDone) 
		{
			DIDEVICEOBJECTDATA od;
			DWORD dwElements = 1;   // number of items to be retrieved
			hr = m_poDXMouseDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
			if(hr == DIERR_INPUTLOST) 
			{
				//SetAcquire();
				SetPlugged(false);
				break;
			}
			if( FAILED(hr) || dwElements == 0 ) 
			{
				//D_Output("[WinInputDeviceMouse::Tick] Can't get Data\n");
				break;
			}
			switch(od.dwOfs) 
			{
				// Mouse horizontal motion
				case DIMOFS_X:
					x += (s16)od.dwData;
					break;
				// Mouse vertical motion
				case DIMOFS_Y:
					y += (s16)od.dwData;
					break; 
				case DIMOFS_BUTTON0:
				case DIMOFS_BUTTON1:
				{
					m_poManager->PostButtonEvent((Key_t)(E_MOUSE_BUTTON1 + (od.dwOfs - DIMOFS_BUTTON0)),
												 od.dwData & 0x80 ? E_KS_Down : E_KS_Up);
					break;
				}
			}
		}
		m_poManager->PostMouseEvent(x, y);
		//InvalidateCursorRect(m_poWnd);
	}
예제 #3
0
MojErr Subscription::QueueEvent(ActivityEvent_t event)
{
	LOG_TRACE("Entering function %s", __FUNCTION__);

	/* Non-detailed subscriptions do not get update events */
	if ((event == ActivityUpdateEvent) && !m_detailedEvents) {
		return MojErrNone;
	}

	if (!IsPlugged()) {
		return SendEvent(event);
	} else {
		/* If there's already an event queued, suppress this one.
		 * Current Activity details will be pulled when the event is
		 * *sent* */
		if ((event == ActivityUpdateEvent) && !m_eventQueue.empty()) {
			return MojErrNone;
		}

		m_eventQueue.push_back(event);
		return MojErrNone;
	}
}