Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Allow arbitrary base classes for hid devices
Browse files Browse the repository at this point in the history
  • Loading branch information
doc-hex committed Jan 6, 2016
1 parent a5e4ee7 commit 47b965a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions u2flib_host/hid_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@
TIMEOUT = 1000


def list_devices():
def list_devices(dev_class=None):
dev_class = dev_class or HIDDevice
devices = []
for d in hid.enumerate(0, 0):
usage_page = d['usage_page']
if usage_page == 0xf1d0 and d['usage'] == 1:
devices.append(HIDDevice(d['path']))
devices.append(dev_class(d['path']))
# Usage page doesn't work on Linux
elif (d['vendor_id'], d['product_id']) in DEVICES:
device = HIDDevice(d['path'])
try:
device.open()
device.close()
devices.append(HIDDevice(d['path']))
devices.append(dev_class(d['path']))
except exc.DeviceError:
pass
return devices
Expand Down

0 comments on commit 47b965a

Please sign in to comment.