From e3f1d9dc1d1ac9242cd1b0f5e49cbe9e159d3a8c Mon Sep 17 00:00:00 2001 From: Yuki-nyan Date: Fri, 12 May 2017 00:57:02 +0100 Subject: [PATCH] Nacon Revolution Pro support --- DS4Windows/DS4Library/DS4Devices.cs | 9 ++++++--- DS4Windows/HidLibrary/HidDevices.cs | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 33015da..1f289d4 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -32,8 +32,9 @@ namespace DS4Windows { lock (Devices) { - int[] pid = { 0xBA0, 0x5C4, 0x09CC }; - IEnumerable hDevices = HidDevices.Enumerate(0x054C, pid); + int[] vid = { 0x054C, 0x146B }; + int[] pid = { 0xBA0, 0x5C4, 0x09CC, 0x0D01 }; + IEnumerable hDevices = HidDevices.Enumerate(vid, pid); // Sort Bluetooth first in case USB is also connected on the same controller. hDevices = hDevices.OrderBy((HidDevice d) => { return DS4Device.HidConnectionType(d); }); @@ -46,7 +47,9 @@ namespace DS4Windows //foreach (HidDevice hDevice in hDevices) { HidDevice hDevice = tempList[i]; - if (DevicePaths.Contains(hDevice.DevicePath)) + if (hDevice.Description == "HID-compliant vendor-defined device") + continue; // ignore the Nacon Revolution Pro programming interface + else if (DevicePaths.Contains(hDevice.DevicePath)) continue; // BT/USB endpoint already open once if (!hDevice.IsOpen) diff --git a/DS4Windows/HidLibrary/HidDevices.cs b/DS4Windows/HidLibrary/HidDevices.cs index 4a8c555..d6c7f1c 100644 --- a/DS4Windows/HidLibrary/HidDevices.cs +++ b/DS4Windows/HidLibrary/HidDevices.cs @@ -36,6 +36,12 @@ namespace DS4Windows productIds.Contains(x.Attributes.ProductId)); } + public static IEnumerable Enumerate(int[] vendorIds, params int[] productIds) + { + return EnumerateDevices().Select(x => new HidDevice(x.Path, x.Description)).Where(x => vendorIds.Contains(x.Attributes.VendorId) && + productIds.Contains(x.Attributes.ProductId)); + } + public static IEnumerable Enumerate(int vendorId) { return EnumerateDevices().Select(x => new HidDevice(x.Path, x.Description)).Where(x => x.Attributes.VendorId == vendorId);