mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Allow drivers to perform arbitrary post id match checks to detect devices
This commit is contained in:
parent
399b6bbcb0
commit
719926222e
@ -41,6 +41,20 @@ class Device(object):
|
|||||||
'''Return the FDI description of this device for HAL on linux.'''
|
'''Return the FDI description of this device for HAL on linux.'''
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def can_handle(cls, device_info):
|
||||||
|
'''
|
||||||
|
Optional method to perform further checks on a device to see if this driver
|
||||||
|
is capable of handling it. If it is not it should return False. This method
|
||||||
|
is only called after the vendor, product ids and the bcd have matched, so
|
||||||
|
it can do some relatively time intensive checks. The default implementation
|
||||||
|
returns True.
|
||||||
|
|
||||||
|
:param device_info: On windows a device ID string. On Unix a tuple of
|
||||||
|
``(vendor_id, product_id, bcd)``.
|
||||||
|
'''
|
||||||
|
return True
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
'''
|
'''
|
||||||
Perform any device specific initialization. Called after the device is
|
Perform any device specific initialization. Called after the device is
|
||||||
|
@ -63,12 +63,14 @@ class DeviceScanner(object):
|
|||||||
for device_id in self.devices:
|
for device_id in self.devices:
|
||||||
if vid in device_id and pid in device_id:
|
if vid in device_id and pid in device_id:
|
||||||
if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)):
|
if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)):
|
||||||
return True
|
if device.can_handle(device_id):
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
for vendor, product, bcdDevice in self.devices:
|
for vendor, product, bcdDevice in self.devices:
|
||||||
if device.VENDOR_ID == vendor and device.PRODUCT_ID == product:
|
if device.VENDOR_ID == vendor and device.PRODUCT_ID == product:
|
||||||
if self.test_bcd(bcdDevice, getattr(device, 'BCD', None)):
|
if self.test_bcd(bcdDevice, getattr(device, 'BCD', None)):
|
||||||
return True
|
if device.can_handle((vendor, product, bcdDevice)):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user