コード例 #1
0
 public void StartXBoxControllerHandling()
 {
     while (!_shouldStop)
     {
         if (VariableStorage.ipaddress != null)
         {
             Controller = new ControllerHandler(OldPSButtons, freq, "Tank", controllerMode);
             var speed     = Controller.GetSpeed();
             var wheelpos1 = Controller.GetWheelPos1();
             var wheelpos2 = Controller.GetWheelPos2();
             OldPSButtons = Controller.GetPsButtons();
             vars         = Controller.GetVars();
             SendControllerData(speed, wheelpos1, wheelpos2, Controller.GetServoX(), Controller.GetServoY());
             VariableStorage.ViewModel.Speed           = speed.ToString();
             VariableStorage.ViewModel.WheelSpeedLeft  = wheelpos1.ToString();
             VariableStorage.ViewModel.WheelSpeedRight = wheelpos2.ToString();
             Thread.Sleep(20); // We do not set a changeble time here for a realistic feeling of things that the "motor" does not respond well
         }
     }
 }