Пример #1
0
void ProcessLine(struct TGPS *GPS, char *Buffer, int *GotGGA, int *GotRMC)
{
    float utc_time, latitude, longitude, hdop, altitude, speed, course;
	int lock, satellites, date;
	char ns, ew, units;
	
	satellites = 0;
	
    if (sscanf(Buffer, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c", &utc_time, &latitude, &ns, &longitude, &ew, &lock, &satellites, &hdop, &altitude, &units) >= 1)
	{
	printf("%s\n", Buffer);
		// $GPGGA,124943.00,5157.01557,N,00232.66381,W,1,09,1.01,149.3,M,48.6,M,,*42
		*GotGGA = 1;
		if (satellites >= 4)
		{
			GPS->Time = utc_time;
			GPS->Latitude = FixPosition(latitude);
			if (ns == 'S') GPS->Latitude = -GPS->Latitude;
			GPS->Longitude = FixPosition(longitude);
			if (ew == 'W') GPS->Longitude = -GPS->Longitude;
			GPS->Altitude = altitude;
		}
		GPS->Satellites = satellites;
    }
    else if (sscanf(Buffer, "$GPRMC,%f,%f,%c,%f,%c,%f,%f,%d", &utc_time, &latitude, &ns, &longitude, &ew, &speed, &course, &date) >= 1)
	{
		// $GPRMC,124943.00,A,5157.01557,N,00232.66381,W,0.039,,200314,,,A*6C
		GPS->Speed = (int)speed;
		GPS->Direction = (int)course;
        *GotRMC = 1;
    }
}
Пример #2
0
HDWP _DeferWindowPosHook(
		  HDWP hWinPosInfo,
		  HWND hWnd,
		  HWND hWndInsertAfter,
		  int x,
		  int y,
		  int cx,
		  int cy,
		  UINT uFlags)
{
	int newY = y;
	int newCy = cy;

	Log(FUNCTION_DEFERWNDPOS, hWnd, y, cy);

	if (systemIsServiceEnabled && IsWindow(hWnd) == TRUE)
	{
		wchar_t className[50];
		ZeroString(className, 50);
		GetClassName(hWnd, className, 50);

		if (wcslen(className) && FixPosition(hWnd, className, uFlags, &newY, &newCy) == TRUE)
		{
			if (DetectInfiniteLoop(hWnd, y, cy) == TRUE)
				return OldDeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags);
		}
	}

	return OldDeferWindowPos(hWinPosInfo, hWnd, hWndInsertAfter, x, newY, cx, newCy, uFlags/* | SWP_UTASK*/);
};
Пример #3
0
void CDuiDropDownList::UpdateItems(const CRect * prcOwner)
{
    int nItems=m_pOwner->GetListItemCount();
    BOOL bShowTop=FALSE;
    if(prcOwner)
    {
        int nDropHeight=m_nDropHeight;
        if(nItems!=0 && nItems*m_pListBox->GetItemHeight()+m_pListBox->GetStyle().m_nMarginY*2<m_nDropHeight)
        {
            nDropHeight=nItems*m_pListBox->GetItemHeight()+m_pListBox->GetStyle().m_nMarginY*2;
        }

        bShowTop = FixPosition(prcOwner, nDropHeight);
    }

    for(int i=0; i<nItems; i++)
    {
        m_pListBox->AddString(m_pOwner->GetListItemText(i),
                              m_pOwner->GetListItemIcon(i), m_pOwner->GetListItemData(i));
    }

    m_pListBox->SetCurSel(m_pOwner->GetListCurSel());
    m_pListBox->EnsureVisible(m_pOwner->GetListCurSel());
    if(prcOwner)
    {
        ::AnimateWindow(m_hWnd,m_pOwner->GetAnimateTime(),
                        AW_SLIDE|AW_ACTIVATE|(bShowTop?AW_VER_NEGATIVE:AW_VER_POSITIVE));
    }
}
Пример #4
0
BOOL _MoveWindowHook(HWND hWnd,
					 int X,
					 int Y,
					 int nWidth,
					 int nHeight,
					 BOOL bRepaint)
{
	int newY = Y;
	int newCy = nHeight;

	Log(FUNCTION_MOVEWINDOW, hWnd, Y, nHeight);
	
	if (systemIsServiceEnabled && IsWindow(hWnd) == TRUE)
	{
		wchar_t className[50];
		ZeroString(className, 50);
		GetClassName(hWnd, className, 50);
		if (wcslen(className) && FixPosition(hWnd, className, 0, &newY, &newCy) == TRUE)
		{
			if (DetectInfiniteLoop(hWnd, Y, nHeight) == TRUE)
			{
				return OldMoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint);
			}
			
			else if (IsDialogWindow(className) == TRUE)
			{
				CloseHandle(CreateThread( 0, 0, DialogFixThread, (LPVOID)hWnd, 0, 0));
				return OldMoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint);
			}
			
		}
	}

	return OldMoveWindow(hWnd, X, newY, nWidth, newCy, bRepaint);
};
Пример #5
0
BOOL _ShowWindowHook(HWND hWnd,
					INT nCmdShow)
{
	BOOL result = OldShowWindow(hWnd, nCmdShow);
	
	Log(FUNCTION_SHOWWINDOW, hWnd, 0, 0);
	
	if ((nCmdShow & SW_SHOWNORMAL) && settingPositionFixEnabled && systemIsServiceEnabled && IsWindow(hWnd) == TRUE)
	{
		
		RECT rect = {0, 0, 0, 0};
		GetWindowRect(hWnd, &rect);

		int nY = rect.top, nCY = rect.bottom - rect.top;
		wchar_t className[50];
		className[0] = L'\0';
		GetClassName(hWnd, className, 50);
		if (wcslen(className) && FixPosition(hWnd, className, 0, &nY, &nCY) == TRUE)
			OldSetWndPos(hWnd, NULL, rect.left, nY, rect.right - rect.left, nCY, SWP_NOZORDER);
	}
	return result;
};
Пример #6
0
void CDuiDropDownListEx::UpdateItems(const CRect * prcOwner)
{
    int nItems=m_pOwner->GetListItemCount();
    BOOL bShowTop=FALSE;
    if(prcOwner)
    {
        int nDropHeight=m_nDropHeight;
        if(nItems!=0 && nItems*m_pListBox->GetItemHeight()+m_pListBox->GetStyle().m_nMarginY*2<m_nDropHeight)
        {
            nDropHeight=nItems*m_pListBox->GetItemHeight()+m_pListBox->GetStyle().m_nMarginY*2;
        }

        bShowTop = FixPosition(prcOwner, nDropHeight);
    }
    m_pListBox->SetItemCount(nItems);
    for(int i=0; i<nItems; i++)
    {
        CDuiPanel *pPanel=m_pListBox->GetItemPanel(i);
        if(m_nTextID!=-1)
        {
            CDuiWindow *pText=pPanel->FindChildByCmdID(m_nTextID);
            if(pText) pText->SetInnerText(m_pOwner->GetListItemText(i));
        }
        if(m_nIconID!=-1)
        {
            CDuiImageWnd *pIcon=(CDuiImageWnd*)pPanel->FindChildByCmdID(m_nIconID);
            if(pIcon && pIcon->IsClass(CDuiImageWnd::GetClassName()))
                pIcon->SetIcon(m_pOwner->GetListItemIcon(i));
        }
    }
    m_pListBox->SetCurSel(m_pOwner->GetListCurSel());
    m_pListBox->EnsureVisible(m_pOwner->GetListCurSel());
    if(prcOwner)
    {
        ::AnimateWindow(m_hWnd,m_pOwner->GetAnimateTime(),
                        AW_SLIDE|AW_ACTIVATE|(bShowTop?AW_VER_NEGATIVE:AW_VER_POSITIVE));
    }
}
Пример #7
0
BOOL _SetWindowPosHook(HWND hWnd, 
				  HWND hWndInsertAfter, 
				  int X, 
				  int Y, 
				  int cx, 
				  int cy, 
				  UINT uFlags)
{
	int newY = Y;
	int newCy = cy;

	Log(FUNCTION_SETWNDPOS, hWnd, Y, cy);

	BOOL posFix = FALSE;
	if (systemIsServiceEnabled && IsWindow(hWnd) == TRUE)
	{
		wchar_t className[50];
		ZeroString(className, 50);
		GetClassName(hWnd, className, 50);
		if (wcslen(className) && FixPosition(hWnd, className, uFlags, &newY, &newCy) == TRUE)
		{
			if (DetectInfiniteLoop(hWnd, Y, cy) == TRUE)
			{
				return OldSetWndPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
			}
			
			else if (IsDialogWindow(className) == TRUE)
			{
				CloseHandle(CreateThread(0, 0, DialogFixThread, (LPVOID)hWnd, 0, 0));
				return OldSetWndPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
			}
		}
	}
	
	return OldSetWndPos(hWnd, hWndInsertAfter, X, newY, cx, newCy, uFlags);
};
Пример #8
0
ULONG DialogFixThread(LPVOID pParam)
{
	Sleep(200);
	HWND hWnd = (HWND)pParam;

	if (IsWindow(hWnd) == TRUE)
	{
		RECT rect = {0, 0, 0, 0};
		GetWindowRect(hWnd, &rect);
		
		int newY = rect.top;
		int newCy = rect.bottom - rect.top;
		
		wchar_t windowName[50];
		ZeroString(windowName, 50);
		GetWindowText(hWnd, windowName, 50);

		wchar_t className[50];
		ZeroString(className, 50);
		GetClassName(hWnd, className, 50);
			
		if (ShouldBeProcessed(className) == TRUE)
		{
			if (IsDoubleFixWindow(hWnd) == TRUE && IsSipWindowVisible() == TRUE && IsSizeOk(rect.left, rect.right - rect.left) == TRUE)
			{
				SIPINFO si;
				GetSipInfo(&si);
				SHSipInfo_(hWnd, SPI_SETSIPINFO, 0, &si, 0);
			}

			if (wcslen(className) && FixPosition(hWnd, className, 0, &newY, &newCy) == TRUE)
				SetWindowPos(hWnd, NULL, rect.left, newY, rect.right - rect.left, newCy, SWP_NOZORDER);
		}
	}
	return 0;
};
Пример #9
0
// asynchronous position fix improves stability
ULONG AsyncFixThread( LPVOID pParam )
{
	HWND hWnd = (HWND) pParam;
	
	// little delay is needed to guarantee that window is ready
	for (int x = 0; x < 20; x++)
	{
		Sleep(100);
		if (IsWindow(hWnd) == FALSE)
			return 0;
		if (IsWindowVisible(hWnd) == TRUE)
			break;
	}

	Sleep(100);

	__try
	{
		if (IsWindow(hWnd) == TRUE)
		{
			if ((GetParent(hWnd) == NULL || ((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) == NULL)) && IsWindowVisible(hWnd) == TRUE)
			{
				wchar_t className[50];
				ZeroString(className, 50);
				GetClassName(hWnd, className, 50);

				if (wcslen(className))
				{

					RECT rect = {0, 0, 0, 0};
					GetWindowRect(hWnd, &rect);
					int newY = rect.top;
					int newHeight = rect.bottom - rect.top;
					

					if (FixPosition(hWnd, className, 0, &newY, &newHeight) == TRUE)
					{
						SetWindowPos(hWnd, NULL, rect.left, newY, rect.right - rect.left, newHeight, SWP_NOZORDER);
					}

					wchar_t windowName[50];
					ZeroString(windowName, 50);
					GetWindowText(hWnd, windowName, 50);

					DWORD isDoubleFix = IsDoubleFixWindow(hWnd);
					if (isDoubleFix && (IsSipWindowVisible() == TRUE || isDoubleFix == 2) && ShouldBeProcessed(className) == TRUE)
					{
						//RECT rect = {0, 0, 0, 0};
						//GetWindowRect(hWnd, &rect);
						//SetWindowPos(hWnd, NULL, rect.left, rect.top, 
						//	rect.right - rect.left, rect.bottom - rect.top, 
						//	SWP_NOZORDER);
						SIPINFO si;
						GetSipInfo(&si);
						SHSipInfo(SPI_SETSIPINFO, 0, &si, 0);
					}
				}
			}
		}
	}
	__except (GetExceptionCode())
	{
	}
	return 0;
};
Пример #10
0
void EChesses::lin(){
	Entiles::lin();
	if(b_CanMove){
		b2Vec2 vel = m_body->GetLinearVelocity();
		
		b2Vec2 desiredVel = b2Vec2(0,0);
		float tfRate = mfBaseRate * mfAdditRate;

		switch(state){
		case 0:
			{
				switch ( direc )
				{
#if (WM_TYPE == MAP_TYPE_ISO)
				case MS_LEFT:  desiredVel = b2Vec2(-4,2); break;
				case MS_STOP:  desiredVel =  b2Vec2(0,0); break;
				case MS_RIGHT: desiredVel =  b2Vec2(4,-2); break;
				case MS_UP: desiredVel = b2Vec2(4,2); break;
				case MS_DOWN: desiredVel = b2Vec2(-4,-2); break;
#else
				case MS_LEFT:  desiredVel = b2Vec2(-4,0); break;
				case MS_STOP:  desiredVel =  b2Vec2(0,0); break;
				case MS_RIGHT: desiredVel =  b2Vec2(4,0); break;
				case MS_UP: desiredVel = b2Vec2(0,4); break;
				case MS_DOWN: desiredVel = b2Vec2(0,-4); break;
#endif
				}
				//////////////////////////////////////////////////////////////////////////
				if(direc != MS_STOP){
					stand = direc;
					m_animator->PlayAnim(CCString::createWithFormat("paodong_%s",sDirect[direc])->getCString());
				}else{
					m_animator->PlayAnim(CCString::createWithFormat("stand_%s",sDirect[stand])->getCString());
					m_bMoving = false;
					//FixPosition();
					FixTar();
				}
				break;
			}
		case 1:
			{
				CCPoint cur = GameManager::sharedLogicCenter()->ml->tm->m_checkPoint(ccp(m_body->GetPosition().x,m_body->GetPosition().y));
				DecideDirect(cur,desiredVel);
				//////////////////////////////////////////////////////////////////////////
				if(direc != MS_STOP){
					stand = direc;
					m_animator->PlayAnim(CCString::createWithFormat("paodong_%s",sDirect[direc])->getCString());
				}else{
					m_animator->PlayAnim(CCString::createWithFormat("stand_%s",sDirect[stand])->getCString());
					m_bMoving = false;
					FixTar();
					//FixPosition();
				}
				break;
			}
		case 3:
			{
				m_animator->setDirect(stand);
				break;
			}
		case 4:
			{
				//CCLog(">[EChess] lin() | Upadate| %s", name.c_str());
				CCPoint cur = GameManager::sharedLogicCenter()->ml->tm->m_checkPoint(ccp(m_body->GetPosition().x,m_body->GetPosition().y));
				DecideDirect(cur,desiredVel);
				//////////////////////////////////////////////////////////////////////////
				if(direc != MS_STOP){
					stand = direc;
				}else{
					CCLog(">[EChess] lin() | Move ends normaly. | %s", name.c_str());
					m_bMoving = false;
					state = 3;
					mfAdditRate = 1;
					FixPosition();
				}
				break;
			}
		}



		float velChangeX = desiredVel.x * tfRate - vel.x;
		float velChangeY = desiredVel.y * tfRate - vel.y;
		float impulseX = m_body->GetMass() * velChangeX; //disregard time factor
		float impulseY = m_body->GetMass() * velChangeY;
		m_body->ApplyLinearImpulse( b2Vec2(impulseX,impulseY), m_body->GetWorldCenter() );
		


		b_Dirty = true;
	}

}
Пример #11
0
void ProcessLine(struct i2c_info *bb, struct TGPS *GPS, char *Buffer, int Count)
{
	static SystemTimeHasBeenSet=0;
	
    float utc_time, latitude, longitude, hdop, altitude;
	int lock, satellites;
	char active, ns, ew, units, timestring[16], speedstring[16], *course, *date, restofline[80], *ptr;
	long Hours, Minutes, Seconds;
	
    if (GPSChecksumOK(Buffer, Count))
	{
		satellites = 0;
	
		if (strncmp(Buffer+3, "GGA", 3) == 0)
		{
			if (sscanf(Buffer+7, "%f,%f,%c,%f,%c,%d,%d,%f,%f,%c", &utc_time, &latitude, &ns, &longitude, &ew, &lock, &satellites, &hdop, &altitude, &units) >= 1)
			{	
				// $GPGGA,124943.00,5157.01557,N,00232.66381,W,1,09,1.01,149.3,M,48.6,M,,*42
				if (satellites >= 4)
				{
					GPS->Time = utc_time;
					Hours = GPS->Time / 10000;
					Minutes = (GPS->Time / 100) % 100;
					Seconds = GPS->Time % 100;
					GPS->Seconds = Hours * 3600 + Minutes * 60 + Seconds;					
					GPS->Latitude = FixPosition(latitude);
					if (ns == 'S') GPS->Latitude = -GPS->Latitude;
					GPS->Longitude = FixPosition(longitude);
					if (ew == 'W') GPS->Longitude = -GPS->Longitude;
					GPS->Altitude = altitude;
				}
				GPS->Satellites = satellites;
			}
			if (Config.EnableGPSLogging)
			{
				WriteLog("gps.txt", Buffer);
			}
		}
		else if (strncmp(Buffer+3, "RMC", 3) == 0)
		{
			speedstring[0] = '\0';
			if (sscanf(Buffer+7, "%[^,],%c,%f,%c,%f,%c,%[^,],%s", timestring, &active, &latitude, &ns, &longitude, &ew, speedstring, restofline) >= 7)
			{			
				// $GPRMC,124943.00,A,5157.01557,N,00232.66381,W,0.039,,200314,,,A*6C

				ptr = restofline;
				
				course = strsep(&ptr, ",");

				date = strsep(&ptr, ",");
				
				GPS->Speed = (int)atof(speedstring);
				GPS->Direction = (int)atof(course);

				if ((atof(timestring) > 0) && !SystemTimeHasBeenSet)
				{
					struct tm tm;
					char timedatestring[32];
					time_t t;

					// Now create a tm structure from our date and time
					memset(&tm, 0, sizeof(struct tm));
					sprintf(timedatestring, "%c%c-%c%c-20%c%c %c%c:%c%c:%c%c",
											date[0], date[1], date[2], date[3], date[4], date[5],
											timestring[0], timestring[1], timestring[2], timestring[3], timestring[4], timestring[5]);
					strptime(timedatestring, "%d-%m-%Y %H:%M:%S", &tm);
				
					t = mktime(&tm);
					if (stime(&t) == -1)
					{
						printf("Failed to set system time\n");
					}
					else
					{
						SystemTimeHasBeenSet = 1;
					}
				}
			}

			if (Config.EnableGPSLogging)
			{
				WriteLog("gps.txt", Buffer);
			}
		}
		else if (strncmp(Buffer+3, "GSV", 3) == 0)
        {
            // Disable GSV
            printf("Disabling GSV\r\n");
            unsigned char setGSV[] = { 0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x39 };
            SendUBX(bb, setGSV, sizeof(setGSV));
        }
		else if (strncmp(Buffer+3, "GLL", 3) == 0)
        {
            // Disable GLL
            printf("Disabling GLL\r\n");
            unsigned char setGLL[] = { 0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x2B };
            SendUBX(bb, setGLL, sizeof(setGLL));
        }
		else if (strncmp(Buffer+3, "GSA", 3) == 0)
        {
            // Disable GSA
            printf("Disabling GSA\r\n");
            unsigned char setGSA[] = { 0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x32 };
            SendUBX(bb, setGSA, sizeof(setGSA));
        }
		else if (strncmp(Buffer+3, "VTG", 3) == 0)
        {
            // Disable VTG
            printf("Disabling VTG\r\n");
            unsigned char setVTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x47};
            SendUBX(bb, setVTG, sizeof(setVTG));
        }
        else
        {
            printf("Unknown NMEA sentence: %s\n", Buffer);
        }
    }
    else
    {
       printf("Bad checksum\r\n");
	}
}