StopUpdate() 공개 메소드

public StopUpdate ( ) : void
리턴 void
예제 #1
0
        public static void stopControllers()
        {
            lock (Devices)
            {
                IEnumerable <DS4Device> devices = getDS4Controllers();
                //foreach (DS4Device device in devices)
                for (int i = 0, devCount = devices.Count(); i < devCount; i++)
                {
                    DS4Device device = devices.ElementAt(i);
                    device.StopUpdate();
                    //device.runRemoval();
                    device.HidDevice.CloseDevice();
                }

                Devices.Clear();
                DevicePaths.Clear();
                DisabledDevices.Clear();
            }
        }
        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);
        }