Ejemplo n.º 1
0
void updateDisplay(void)
{	  
   int gyroX = 0,gyroY = 0;
   IEE_HeadsetGetGyroDelta(0,&gyroX,&gyroY);
   xmax += gyroX;
   ymax += gyroY;

   if( outOfBound )
   {
	   if( preX != gyroX && preY != gyroY )
	   {
		   xmax = currX;
		   ymax = currY;
	   }
   }

   double val = sqrt((float)(xmax*xmax + ymax*ymax));
  
    std::cout << "xmax : " << xmax << " ; ymax : " << ymax
              << std::endl;

   
   if( val >= maxRadius )
   {
	   changeXY(1);	
	   outOfBound = true;
	   preX = gyroX;
	   preY = gyroY;
   }
   else
   {		
	   outOfBound = false;
		if(oldXVal == gyroX && oldYVal == gyroY)
		{
			++count;
			if( count > 10 )
			{									
				changeXY(0);
			}
		}
		else
		{
			count = 0;
			currX = xmax;
			currY = ymax;
			oldXVal = gyroX;
			oldYVal = gyroY;			
		}
   }
    
#ifdef _WIN32
    Sleep(15);
#endif
#ifdef __linux__
    sleep(1);
#endif
    
    glutPostRedisplay();
}
Ejemplo n.º 2
0
	// Given a string, compute recursively( no loops ) a new string where all the lowercase 'x' chars have been changed to 'y' chars.
	string changeXY( string str )
	{
		if( str.empty() )
			return str;

		string c = string( 1, str.at( str.length() - 1 ) );

		return changeXY( str.substr( 0, str.length() - 1 ) ) + ( c == "x" ? "y" : c );
	}
Ejemplo n.º 3
0
DWORD WINAPI funThread(LPVOID tParam)
{
	PMYRECT t = (PMYRECT)tParam;
	while (true)
	{
		changeXY(t);
		InvalidateRect(t->hWnd, NULL, TRUE);
		Sleep(t->sleep);
	}
	return 0;
}