From 076b1d0839b3fa427fc76f7e34c7e7f78120a030 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 28 Oct 2017 19:58:23 -0500 Subject: [PATCH] Use array to specify compatible vids --- DS4Windows/DS4Library/DS4Devices.cs | 3 ++- DS4Windows/HidLibrary/HidDevices.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 0a1ced6..5493beb 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -37,8 +37,9 @@ namespace DS4Windows { lock (Devices) { + int[] vids = { 0x054C }; int[] pid = { 0xBA0, 0x5C4, 0x09CC }; - IEnumerable hDevices = HidDevices.Enumerate(0x054C, pid); + IEnumerable hDevices = HidDevices.Enumerate(vids, pid); // Sort Bluetooth first in case USB is also connected on the same controller. hDevices = hDevices.OrderBy((HidDevice d) => { return DS4Device.HidConnectionType(d); }); 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);