From bfbcc15df5211a66a8de0a925e0ae2b998a4d326 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 5 Apr 2017 16:51:20 -0700 Subject: [PATCH] Detect the Sony Wireless Adaptor as its own connection type --- DS4Windows/DS4Forms/DS4Form.cs | 1 + DS4Windows/DS4Library/DS4Device.cs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 7f113dd..655424f 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -863,6 +863,7 @@ namespace DS4Windows { case "USB": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.USB; toolTip1.SetToolTip(statPB[Index], ""); break; case "BT": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break; + case "SONYWA": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.DS4_Config_PS; toolTip1.SetToolTip(statPB[Index], ""); break; default: statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); break; } Batteries[Index].Text = Program.rootHub.getDS4Battery(Index); diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index d4d64df..0ce1348 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -87,7 +87,7 @@ namespace DS4Windows public override string ToString() => $"Red: {red} Green: {green} Blue: {blue}"; } - public enum ConnectionType : byte { BT, USB }; // Prioritize Bluetooth when both are connected. + public enum ConnectionType : byte { BT, USB, SONYWA }; // Prioritize Bluetooth when both BT and USB are connected. /** * The haptics engine uses a stack of these states representing the light bar and rumble motor settings. @@ -249,7 +249,20 @@ namespace DS4Windows public static ConnectionType HidConnectionType(HidDevice hidDevice) { - return hidDevice.Capabilities.InputReportByteLength == 64 ? ConnectionType.USB : ConnectionType.BT; + ConnectionType result = ConnectionType.USB; + if (hidDevice.Capabilities.InputReportByteLength == 64) + { + if (hidDevice.Capabilities.NumberFeatureDataIndices == 22) + { + result = ConnectionType.SONYWA; + } + } + else + { + result = ConnectionType.BT; + } + + return result; } public DS4Device(HidDevice hidDevice) @@ -454,7 +467,7 @@ namespace DS4Windows readTimeout.Interval = 3000.0; } readTimeout.Enabled = true; - if (conType != ConnectionType.USB) + if (conType == ConnectionType.BT) { //HidDevice.ReadStatus res = hDevice.ReadFile(btInputReport); HidDevice.ReadStatus res = hDevice.ReadAsyncWithFileStream(btInputReport, READ_STREAM_TIMEOUT);