Use array to specify compatible vids

This commit is contained in:
Travis Nickles 2017-10-28 19:58:23 -05:00
parent 212ae71d4e
commit 076b1d0839
2 changed files with 8 additions and 1 deletions

View File

@ -37,8 +37,9 @@ namespace DS4Windows
{
lock (Devices)
{
int[] vids = { 0x054C };
int[] pid = { 0xBA0, 0x5C4, 0x09CC };
IEnumerable<HidDevice> hDevices = HidDevices.Enumerate(0x054C, pid);
IEnumerable<HidDevice> hDevices = HidDevices.Enumerate(vids, pid);
// Sort Bluetooth first in case USB is also connected on the same controller.
hDevices = hDevices.OrderBy<HidDevice, ConnectionType>((HidDevice d) => { return DS4Device.HidConnectionType(d); });

View File

@ -36,6 +36,12 @@ namespace DS4Windows
productIds.Contains(x.Attributes.ProductId));
}
public static IEnumerable<HidDevice> 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<HidDevice> Enumerate(int vendorId)
{
return EnumerateDevices().Select(x => new HidDevice(x.Path, x.Description)).Where(x => x.Attributes.VendorId == vendorId);