Add headphone volume support for DS4 v2 controllers

This commit is contained in:
Travis Nickles 2017-10-02 03:16:57 -05:00
parent c5ef4196bd
commit 22912dff50
2 changed files with 20 additions and 1 deletions

View File

@ -56,6 +56,18 @@ namespace DS4Windows.DS4Library
Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer)); Marshal.ThrowExceptionForHR(audioDevice.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out interfacePointer));
endpointVolume = interfacePointer as IAudioEndpointVolume; 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); Marshal.ReleaseComObject(audioDevice);
} }

View File

@ -419,6 +419,13 @@ namespace DS4Windows
if (conType == ConnectionType.USB) if (conType == ConnectionType.USB)
{ {
warnInterval = WARN_INTERVAL_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; synced = true;
} }
else else
@ -1041,7 +1048,7 @@ namespace DS4Windows
outputReportBuffer[8] = ligtBarColor.blue; // blue outputReportBuffer[8] = ligtBarColor.blue; // blue
outputReportBuffer[9] = ledFlashOn; // flash on duration outputReportBuffer[9] = ledFlashOn; // flash on duration
outputReportBuffer[10] = ledFlashOff; // flash off duration outputReportBuffer[10] = ledFlashOff; // flash off duration
if (conType == ConnectionType.SONYWA) if (audio != null)
{ {
// Headphone volume levels // Headphone volume levels
outputReportBuffer[19] = outputReportBuffer[20] = outputReportBuffer[19] = outputReportBuffer[20] =