Stop() 공개 메소드

public Stop ( ) : System.Boolean
리턴 System.Boolean
예제 #1
0
 public bool Stop(bool showlog = true)
 {
     if (running)
     {
         running = false;
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppingX360);
         }
         bool anyUnplugged = false;
         for (int i = 0; i < DS4Controllers.Length; i++)
         {
             if (DS4Controllers[i] != null)
             {
                 if (DCBTatStop && !DS4Controllers[i].Charging && showlog)
                 {
                     DS4Controllers[i].DisconnectBT();
                 }
                 else
                 {
                     DS4LightBar.forcelight[i]  = false;
                     DS4LightBar.forcedFlash[i] = 0;
                     DS4LightBar.defualtLight   = true;
                     DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], ExposedState[i], touchPad[i]);
                     System.Threading.Thread.Sleep(50);
                 }
                 CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change.
                 x360Bus.Unplug(i);
                 anyUnplugged      = true;
                 DS4Controllers[i] = null;
                 touchPad[i]       = null;
             }
         }
         if (anyUnplugged)
         {
             System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
         }
         x360Bus.UnplugAll();
         x360Bus.Stop();
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppingDS4);
         }
         DS4Devices.stopControllers();
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppedDS4Windows);
         }
         ControllerStatusChanged(this);
     }
     return(true);
 }
        public bool Stop(bool showlog = true)
        {
            if (running)
            {
                running    = false;
                runHotPlug = false;

                if (showlog)
                {
                    LogDebug(Properties.Resources.StoppingX360);
                }

                bool anyUnplugged = false;
                for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
                {
                    DS4Device tempDevice = DS4Controllers[i];
                    if (tempDevice != null)
                    {
                        if (DCBTatStop && !tempDevice.isCharging())
                        {
                            if (tempDevice.getConnectionType() == ConnectionType.BT)
                            {
                                tempDevice.StopUpdate();
                                tempDevice.DisconnectBT(true);
                            }
                            else if (tempDevice.getConnectionType() == ConnectionType.SONYWA)
                            {
                                tempDevice.StopUpdate();
                                tempDevice.DisconnectDongle(true);
                            }
                        }
                        else
                        {
                            DS4LightBar.forcelight[i]  = false;
                            DS4LightBar.forcedFlash[i] = 0;
                            DS4LightBar.defaultLight   = true;
                            DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i],
                                                       ExposedState[i], touchPad[i]);
                            tempDevice.IsRemoved = true;
                            Thread.Sleep(50);
                        }

                        CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change.
                        x360Bus.Unplug(i);
                        useDInputOnly[i]  = true;
                        anyUnplugged      = true;
                        DS4Controllers[i] = null;
                        touchPad[i]       = null;
                        lag[i]            = false;
                        inWarnMonitor[i]  = false;
                    }
                }

                if (anyUnplugged)
                {
                    Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
                }

                x360Bus.UnplugAll();
                x360Bus.Stop();

                if (showlog)
                {
                    LogDebug(Properties.Resources.StoppingDS4);
                }

                DS4Devices.stopControllers();

                if (_udpServer != null)
                {
                    _udpServer.Stop();
                }

                if (showlog)
                {
                    LogDebug(Properties.Resources.StoppedDS4Windows);
                }
            }

            runHotPlug = false;
            return(true);
        }