Esempio n. 1
0
 public int Start(Action onStop = null)
 {
     controllerCount = controllers.GetId();
     if (scpDevice.Unplug(controllerCount))
     {
         Thread.Sleep(10);
     }
     if (scpDevice.Plugin(controllerCount))
     {
         thread = new Thread(() =>
         {
             try
             {
                 XInput.InputChanged += () =>
                 {
                     if (!scpDevice.Report(controllerCount, XInput.GetBinary()))
                     {
                         running = false;
                     }
                 };
                 while (running)
                 {
                     Thread.Sleep(100);
                 }
             }
             finally
             {
                 scpDevice.Unplug(controllerCount);
                 onStop?.Invoke();
             }
         });
         running             = true;
         thread.IsBackground = true;
         thread.Start();
     }
     else
     {
         resetId();
     }
     return(controllerCount);
 }