mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Make detection of devices based on BCD optional
This commit is contained in:
parent
ed040cb7fe
commit
cfb275598b
@ -20,7 +20,9 @@ class Device(object):
|
|||||||
FORMATS = ["lrf", "rtf", "pdf", "txt"]
|
FORMATS = ["lrf", "rtf", "pdf", "txt"]
|
||||||
VENDOR_ID = 0x0000
|
VENDOR_ID = 0x0000
|
||||||
PRODUCT_ID = 0x0000
|
PRODUCT_ID = 0x0000
|
||||||
BCD = 0x0000
|
# BCD can be either None to not distinguish between devices based on BCD, or
|
||||||
|
# it can be a list of the BCD numbers of all devices supported by this driver.
|
||||||
|
BCD = None
|
||||||
THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
|
THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
|
||||||
|
|
||||||
def __init__(self, key='-1', log_packets=False, report_progress=None) :
|
def __init__(self, key='-1', log_packets=False, report_progress=None) :
|
||||||
|
@ -85,7 +85,7 @@ class PRS500(Device):
|
|||||||
|
|
||||||
VENDOR_ID = 0x054c #: SONY Vendor Id
|
VENDOR_ID = 0x054c #: SONY Vendor Id
|
||||||
PRODUCT_ID = 0x029b #: Product Id for the PRS-500
|
PRODUCT_ID = 0x029b #: Product Id for the PRS-500
|
||||||
BCD = 0x100
|
BCD = [0x100]
|
||||||
PRODUCT_NAME = 'PRS-500'
|
PRODUCT_NAME = 'PRS-500'
|
||||||
VENDOR_NAME = 'SONY'
|
VENDOR_NAME = 'SONY'
|
||||||
INTERFACE_ID = 0 #: The interface we use to talk to the device
|
INTERFACE_ID = 0 #: The interface we use to talk to the device
|
||||||
|
@ -29,7 +29,7 @@ class File(object):
|
|||||||
class PRS505(Device):
|
class PRS505(Device):
|
||||||
VENDOR_ID = 0x054c #: SONY Vendor Id
|
VENDOR_ID = 0x054c #: SONY Vendor Id
|
||||||
PRODUCT_ID = 0x031e #: Product Id for the PRS-505
|
PRODUCT_ID = 0x031e #: Product Id for the PRS-505
|
||||||
BCD = 0x229 #: Needed to disambiguate 505 and 700 on linux
|
BCD = [0x229] #: Needed to disambiguate 505 and 700 on linux
|
||||||
PRODUCT_NAME = 'PRS-505'
|
PRODUCT_NAME = 'PRS-505'
|
||||||
VENDOR_NAME = 'SONY'
|
VENDOR_NAME = 'SONY'
|
||||||
FORMATS = ['lrf', 'epub', "rtf", "pdf", "txt"]
|
FORMATS = ['lrf', 'epub', "rtf", "pdf", "txt"]
|
||||||
|
@ -9,7 +9,7 @@ from calibre.devices.prs505.driver import PRS505
|
|||||||
|
|
||||||
class PRS700(PRS505):
|
class PRS700(PRS505):
|
||||||
|
|
||||||
BCD = 0x31a
|
BCD = [0x31a]
|
||||||
PRODUCT_NAME = 'PRS-700'
|
PRODUCT_NAME = 'PRS-700'
|
||||||
OSX_NAME = 'Sony PRS-700'
|
OSX_NAME = 'Sony PRS-700'
|
||||||
|
|
||||||
|
@ -39,19 +39,34 @@ class DeviceScanner(object):
|
|||||||
'''Fetch list of connected USB devices from operating system'''
|
'''Fetch list of connected USB devices from operating system'''
|
||||||
self.devices = self.scanner()
|
self.devices = self.scanner()
|
||||||
|
|
||||||
|
def test_bcd_windows(self, device_id, bcd):
|
||||||
|
if bcd is None or len(bcd) == 0:
|
||||||
|
return True
|
||||||
|
for c in bcd:
|
||||||
|
# Bug in winutil.get_usb_devices converts a to :
|
||||||
|
rev = ('rev_%4.4x'%c).replace(':', 'a')
|
||||||
|
if rev in device_id:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def test_bcd(self, bcdDevice, bcd):
|
||||||
|
if bcd is None or len(bcd) == 0:
|
||||||
|
return True
|
||||||
|
for c in bcd:
|
||||||
|
if c == bcdDevice:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def is_device_connected(self, device):
|
def is_device_connected(self, device):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
for device_id in self.devices:
|
for device_id in self.devices:
|
||||||
vid, pid = 'vid_%4.4x'%device.VENDOR_ID, 'pid_%4.4x'%device.PRODUCT_ID
|
vid, pid = 'vid_%4.4x'%device.VENDOR_ID, 'pid_%4.4x'%device.PRODUCT_ID
|
||||||
rev = ('rev_%4.4x'%device.BCD).replace('a', ':') # Bug in winutil.get_usb_devices converts a to :
|
if vid in device_id and pid in device_id:
|
||||||
if vid in device_id and pid in device_id and rev in device_id:
|
return self.test_bcd_windows(device_id, getattr(device, 'BCD', None))
|
||||||
return True
|
|
||||||
return False
|
|
||||||
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 hasattr(device, 'BCD') and device.BCD == bcdDevice:
|
return self.test_bcd(bcdDevice, getattr(device, 'BCD', None))
|
||||||
return True
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user