mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Revert back to old disconnect bluetooth behavior
This commit is contained in:
parent
de1b6b223f
commit
44501c24de
@ -1571,7 +1571,7 @@ namespace DS4Windows
|
|||||||
ConnectionType deviceConn = d.getConnectionType();
|
ConnectionType deviceConn = d.getConnectionType();
|
||||||
if (deviceConn == ConnectionType.BT)
|
if (deviceConn == ConnectionType.BT)
|
||||||
{
|
{
|
||||||
d.DisconnectBT(false);
|
d.DisconnectBT();
|
||||||
}
|
}
|
||||||
|
|
||||||
//foreach (DS4Controls dc in action.trigger)
|
//foreach (DS4Controls dc in action.trigger)
|
||||||
|
@ -726,7 +726,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
if (conType == ConnectionType.BT)
|
if (conType == ConnectionType.BT)
|
||||||
{
|
{
|
||||||
if (DisconnectBT(false))
|
if (DisconnectBT())
|
||||||
return; // all done
|
return; // all done
|
||||||
}
|
}
|
||||||
else if (conType == ConnectionType.SONYWA)
|
else if (conType == ConnectionType.SONYWA)
|
||||||
@ -835,7 +835,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisconnectBT(bool allThreadsQuit = true)
|
public bool DisconnectBT()
|
||||||
{
|
{
|
||||||
if (Mac != null)
|
if (Mac != null)
|
||||||
{
|
{
|
||||||
@ -850,6 +850,7 @@ namespace DS4Windows
|
|||||||
//parse hex byte in reverse order
|
//parse hex byte in reverse order
|
||||||
btAddr[5 - i] = Convert.ToByte(sbytes[i], 16);
|
btAddr[5 - i] = Convert.ToByte(sbytes[i], 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
long lbtAddr = BitConverter.ToInt64(btAddr, 0);
|
long lbtAddr = BitConverter.ToInt64(btAddr, 0);
|
||||||
|
|
||||||
NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS p = new NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS();
|
NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS p = new NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS();
|
||||||
@ -862,30 +863,27 @@ namespace DS4Windows
|
|||||||
success = NativeMethods.DeviceIoControl(btHandle, IOCTL_BTH_DISCONNECT_DEVICE, ref lbtAddr, 8, IntPtr.Zero, 0, ref bytesReturned, IntPtr.Zero);
|
success = NativeMethods.DeviceIoControl(btHandle, IOCTL_BTH_DISCONNECT_DEVICE, ref lbtAddr, 8, IntPtr.Zero, 0, ref bytesReturned, IntPtr.Zero);
|
||||||
NativeMethods.CloseHandle(btHandle);
|
NativeMethods.CloseHandle(btHandle);
|
||||||
if (!success)
|
if (!success)
|
||||||
|
{
|
||||||
if (!NativeMethods.BluetoothFindNextRadio(searchHandle, ref btHandle))
|
if (!NativeMethods.BluetoothFindNextRadio(searchHandle, ref btHandle))
|
||||||
btHandle = IntPtr.Zero;
|
btHandle = IntPtr.Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeMethods.BluetoothFindRadioClose(searchHandle);
|
NativeMethods.BluetoothFindRadioClose(searchHandle);
|
||||||
Console.WriteLine("Disconnect successful: " + success);
|
Console.WriteLine("Disconnect successful: " + success);
|
||||||
success = true; // XXX return value indicates failure, but it still works?
|
success = true; // XXX return value indicates failure, but it still works?
|
||||||
if(success)
|
if (success)
|
||||||
{
|
{
|
||||||
IsDisconnecting = true;
|
IsDisconnecting = true;
|
||||||
if (allThreadsQuit)
|
StopOutputUpdate();
|
||||||
{
|
|
||||||
StopUpdate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StopOutputUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Removal != null)
|
if (Removal != null)
|
||||||
Removal(this, EventArgs.Empty);
|
Removal(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,6 +900,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
isDisconnecting = true;
|
isDisconnecting = true;
|
||||||
StopOutputUpdate();
|
StopOutputUpdate();
|
||||||
|
|
||||||
if (Removal != null)
|
if (Removal != null)
|
||||||
Removal(this, EventArgs.Empty);
|
Removal(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace DS4Windows
|
|||||||
return deviceInstanceId;
|
return deviceInstanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//enumerates ds4 controllers in the system
|
// enumerates ds4 controllers in the system
|
||||||
public static void findControllers()
|
public static void findControllers()
|
||||||
{
|
{
|
||||||
lock (Devices)
|
lock (Devices)
|
||||||
|
Loading…
Reference in New Issue
Block a user