karalabe / hid

Gopher Interface Devices (USB HID)
Other
266 stars 132 forks source link

Export generic usb api for "webUSB device" support #19

Closed gballet closed 5 years ago

gballet commented 5 years ago

This PR extends the current API to also let client code handle non-hid ("generic") USB devices. This is done by offering two types of devices behind a Device interface: HidDevice (formerly Device) and GenericDevice.

Most of the work happens in Enumerate : the function starts by enumerating generic devices and skipping those who are going to be picked up by the HID code. Doing it the other way around has advantages, I'm considering switching.

libusb hasn't been updated in this version, as it uses the same interface as the latest version. I'm happy to upgrade it in a subsequent PR.

TODO The last issue that I'm aware of, is to ensure that it builds and works on macos and Windows

karalabe commented 5 years ago

Generally looks ok, but due to the extreme API changes + incompatible licensing (libusb forces LGPL), I'm forking the repo - with this PR on top - out into its own repository (https://github.com/karalabe/usb). Will make some API tweaks there and finish the Windows port.