codeminders / javahidapi

Java API for HID (Human Interface) Devices
Other
10 stars 7 forks source link

openById misnomer #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a USB dongle which creates two devices of identical vendor and product 
id. To distinguish, I have to look at the report after opening.

It took me a long time to narrow this down because openById implies that vendor 
/ product is unique. I suggest that this method be @deprecated and replaced 
with the following

    public List<HIDDeviceInfo> findDevices(int vendor, int product) throws IOException {
        HIDDeviceInfo[] infos = manager.listDevices();
        List<HIDDeviceInfo> devs = new ArrayList<HIDDeviceInfo>(infos.length);
        for (HIDDeviceInfo info: infos) {
            if (info.getVendor_id() == vendor && info.getProduct_id() == product)
                devs.add(info);
        }
        return devs;
    }

Original issue reported on code.google.com by Sam.Hall...@gmail.com on 28 Dec 2012 at 1:28