From 22912dff50ec8ddbf3c60204a3098afcf2b0554a Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 2 Oct 2017 03:16:57 -0500 Subject: [PATCH] Add headphone volume support for DS4 v2 controllers --- DS4Windows/DS4Library/DS4Audio.cs | 12 ++++++++++++ DS4Windows/DS4Library/DS4Device.cs | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Library/DS4Audio.cs b/DS4Windows/DS4Library/DS4Audio.cs index b256870..c3fb325 100644 --- a/DS4Windows/DS4Library/DS4Audio.cs +++ b/DS4Windows/DS4Library/DS4Audio.cs @@ -56,6 +56,18 @@ namespace DS4Windows.DS4Library Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); endpointVolume = interfacePointer as IAudioEndpointVolume; } + else if (deviceName.Contains("Headset Earphone (Wireless Controller)")) + { + object interfacePointer; + Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); + endpointVolume = interfacePointer as IAudioEndpointVolume; + } + else if (deviceName.Contains("Headset Microphone (Wireless Controller)")) + { + object interfacePointer; + Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); + endpointVolume = interfacePointer as IAudioEndpointVolume; + } Marshal.ReleaseComObject(audioDevice); } diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index f06950d..a26d722 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -419,6 +419,13 @@ namespace DS4Windows if (conType == ConnectionType.USB) { warnInterval = WARN_INTERVAL_USB; + HidDeviceAttributes tempAttr = hDevice.Attributes; + if (tempAttr.VendorId == 0x054C && tempAttr.ProductId == 0x09CC) + { + audio = new DS4Audio(); + micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Capture); + } + synced = true; } else @@ -1041,7 +1048,7 @@ namespace DS4Windows outputReportBuffer[8] = ligtBarColor.blue; // blue outputReportBuffer[9] = ledFlashOn; // flash on duration outputReportBuffer[10] = ledFlashOff; // flash off duration - if (conType == ConnectionType.SONYWA) + if (audio != null) { // Headphone volume levels outputReportBuffer[19] = outputReportBuffer[20] =