Skip to content

Commit 38ede7c

Browse files
committed
support Enumerate by (vid, pid)[]
1 parent c834345 commit 38ede7c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/HidLibrary/HidDevices.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ public static IEnumerable<HidDevice> Enumerate(int vendorId, params int[] produc
3535
return EnumerateDevices().Select(x => new HidDevice(x.Path, x.Description)).Where(x => x.Attributes.VendorId == vendorId &&
3636
productIds.Contains(x.Attributes.ProductId));
3737
}
38+
39+
public static IEnumerable<HidDevice> Enumerate((int vid,int pid)[] vidpids)
40+
{
41+
var Devices = EnumerateDevices().Select(x => new HidDevice(x.Path, x.Description));
42+
List<HidDevice> temp = new List<HidDevice>();
43+
foreach(var d in Devices)
44+
{
45+
if(vidpids.Contains((d.Attributes.VendorId, d.Attributes.ProductId))){
46+
temp.Add(d);
47+
}
48+
}
49+
return (IEnumerable<HidDevice>)temp;
50+
}
3851

3952
public static IEnumerable<HidDevice> Enumerate(int vendorId, int productId, ushort UsagePage)
4053
{

0 commit comments

Comments
 (0)