public void Disconnect(bool stop)
 {
     device.Report -= Device_Report;
     state.LightBarExplicitlyOff = sendColor.R == 0 && sendColor.G == 0 && sendColor.B == 0;
     state.LightBarColor         = new DS4Color(RestoreColor);
     device.pushHapticState(state);
     if (stop)
     {
         device.DisconnectBT();
         device.DisconnectDongle();
     }
     device.StopUpdate();
 }
Exemple #2
0
 public void Disconnect(bool stop)
 {
     sendColor = RestoreColor;
     Thread.Sleep(10);//HACK: this is terrible, but it works reliably so i'll leave it like this :(
     //this is needed so that OnDeviceReport has time to send the color once the device sends a report.
     device.Report -= OnDeviceReport;
     if (stop)
     {
         device.DisconnectBT();
         device.DisconnectDongle();
     }
     device.StopUpdate();
 }
Exemple #3
0
 public void Stop()
 {
     Console.WriteLine("DS4 disconnecting");
     if (_controller == null)
     {
         return;
     }
     _controller.LightBarColor       = new DS4Color(0, 0, 0);
     _controller.LightBarOnDuration  = 0;
     _controller.LightBarOffDuration = 0;
     _controller.FlushHID();
     if (_controller.ConnectionType == DS4Windows.ConnectionType.BT)
     {
         _controller.DisconnectBT();
     }
     _controller = null;
 }
Exemple #4
0
        protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
        {
            DS4Device d = DS4Controllers[deviceID];

            if ((!pState.PS || !pState.Options) && cState.PS && cState.Options)
            {
                if (!d.Charging)
                {
                    d.DisconnectBT(); InputMethods.performKeyRelease(Global.getCustomKey(0, DS4Controls.PS));
                    string[] skeys = Global.getCustomMacro(0, DS4Controls.PS).Split('/');
                    ushort[] keys  = new ushort[skeys.Length];
                    for (int i = 0; i < keys.Length; i++)
                    {
                        keys[i] = ushort.Parse(skeys[i]);
                        InputMethods.performKeyRelease(keys[i]);
                    }
                    d = null;
                }
            }
            if (!Global.getUseTPforControls(deviceID) && cState.Touch1 && pState.PS)
            {
                if (Global.getTouchSensitivity(deviceID) > 0 && touchreleased[deviceID])
                {
                    oldtouchvalue[deviceID]  = Global.getTouchSensitivity(deviceID);
                    oldscrollvalue[deviceID] = Global.getScrollSensitivity(deviceID);
                    Global.setTouchSensitivity(deviceID, 0);
                    Global.setScrollSensitivity(deviceID, 0);
                    LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
                    Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
                    touchreleased[deviceID] = false;
                }
                else if (touchreleased[deviceID])
                {
                    Global.setTouchSensitivity(deviceID, oldtouchvalue[deviceID]);
                    Global.setScrollSensitivity(deviceID, oldscrollvalue[deviceID]);
                    LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
                    Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
                    touchreleased[deviceID] = false;
                }
            }
            else
            {
                touchreleased[deviceID] = true;
            }
        }
Exemple #5
0
 public void Shutdown()
 {
     try
     {
         if (isInitialized)
         {
             if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_disconnect_when_stop"))
             {
                 device.DisconnectBT();
                 device.DisconnectDongle();
             }
             RestoreColor();
             device.StopUpdate();
             DS4Devices.stopControllers();
             isInitialized = false;
         }
     }
     catch (Exception e)
     {
         Global.logger.Error("There was an error shutting down DualShock: " + e);
         isInitialized = true;
     }
 }