Exemple #1
0
/**
 * @brief Main thread function for Proxy166.
 * Runs forever, until MyTaskInitialized is false. 
 * 
 * @todo Update DS switch array
 */
int Proxy166::Main(	int a2, int a3, int a4, int a5,
					int a6, int a7, int a8, int a9, int a10) {

	Robot166 *lHandle = NULL;
#if LoggingProxy
	ProxyLog sl;
#endif
	WaitForGoAhead();
	
	lHandle = Robot166::getInstance();
#if LoggingProxy
	lHandle->RegisterLogger(&sl);
#endif
	
	Timer debugTimer;
	debugTimer.Start();
	
	ProxyJoystick old_sticks[NUMBER_OF_JOYSTICKS+1];
	
	while(MyTaskInitialized) {
		if(lHandle->IsOperatorControl() && true == AreSettingJoysticks()) {
			for(int x = 0;x<NUMBER_OF_JOYSTICKS;x++) {
				old_sticks[x] = GetJoystick(x);
			}
			SetJoystick(1, driveStickRight);
			SetJoystick(2, driveStickLeft);
			SetJoystick(3, driveStickCopilot);
			
			if(tracker.size() > 0) {
				vector<int>::iterator it = tracker.begin();
				while(it != tracker.end()) {
					int joy_id = *it;
					int button_id = *(it+1);
					
					bool old_button = old_sticks[joy_id].button[button_id];
					bool new_button = GetButton(joy_id, button_id);
					
					if(old_button == 1 && new_button == 0) {
						// The button was previously pressed, but is now released
						(*(it+2))++; // Increase the counter
					}
					it += 3;
				}
			}
			if(debugTimer.HasPeriodPassed(1.0)) {
				// Debug info
			}
		}
		SetBattery(lHandle->GetBatteryVoltage());
#if LoggingProxy
		sl.PutOne(Battery, GetJoystick(1), GetJoystick(2), GetJoystick(3));
#endif
		// The task ends if it's not initialized
		WaitForNextLoop();
	}
	
	return 0;
}
Exemple #2
0
int gameMainOpen(void)
{

    unsigned int joy;
    tmouse *mo;

    int sound;
    int draw;
    
      

        actualLevel->view.buf=GetVideo();
        
        joy=GetJoystick();
        mo=getMouseInf();
        
        actualLevel->mouse=mo;
        actualLevel->key=joy;
        
   
        draw=getDrawFrame();
    
        switch (runStateGame) 
        {
            case 0:
                if(loadGame(actualLevel,draw)) 
                    runStateGame=1;
            break;
            case 1:
                runGame(actualLevel,draw);
            break;        
            default:
            break;
        }
        
    
        wipeView(&actualLevel->transiction);
              
        if(getRenderAudio())
            sound=SRenderAudio();
        
        if(draw) FlipVideo();
        WaitSyncTimer();  
        
        
        getFPS(&Vfpsg,&Vfps);
		
      
        return draw;
             
   
}
Exemple #3
0
unsigned int NETJoystick(void)
{
  unsigned int J,I;

  /* Get local joystick state */
  J = GetJoystick();
#ifdef MAEMO
  J|= PenJoystick();
#endif

  /* When ALT pressed, swap players back */
  if(J&BTN_ALT) J=(J&BTN_MODES)|((J>>16)&BTN_ALL)|((J&BTN_ALL)<<16);

  /* If exchanged joystick states over the network... */
  /* Assume server to be player #1, client to be player #2 */
  if(NETExchange((char *)&I,(const char *)&J,sizeof(J)))
    J = NETConnected()==NET_SERVER?
        ((J&(BTN_ALL|BTN_MODES))|((I&BTN_ALL)<<16))
      : ((I&(BTN_ALL|BTN_MODES))|((J&BTN_ALL)<<16));

  /* Done */
  return(J);
}