3535HR_KEYS = b"\x04 "
3636HR_BRAILLE = b"\x05 "
3737HR_POWEROFF = b"\x07 "
38+ HID_USAGE_PAGE = 0x93
3839
3940KEY_NAMES = {
4041 1 : "power" , # Brailliant BI 32, 40 and 80.
@@ -89,47 +90,61 @@ class BrailleDisplayDriver(braille.BrailleDisplayDriver):
8990 @classmethod
9091 def registerAutomaticDetection (cls , driverRegistrar : bdDetect .DriverRegistrar ):
9192 driverRegistrar .addUsbDevices (
92- bdDetect .DeviceType .HID ,
93+ bdDetect .ProtocolType .HID ,
9394 {
9495 "VID_1C71&PID_C111" , # Mantis Q 40
9596 "VID_1C71&PID_C101" , # Chameleon 20
97+ "VID_1C71&PID_C131" , # Brailliant BI 40X
98+ "VID_1C71&PID_C141" , # Brailliant BI 20X
99+ },
100+ matchFunc = bdDetect .HIDUsagePageMatchFuncFactory (HID_USAGE_PAGE ),
101+ )
102+ driverRegistrar .addUsbDevices (
103+ bdDetect .ProtocolType .HID ,
104+ {
96105 "VID_1C71&PID_C121" , # Humanware BrailleOne 20 HID
97106 "VID_1C71&PID_CE01" , # NLS eReader 20 HID
98107 "VID_1C71&PID_C006" , # Brailliant BI 32, 40 and 80
99108 "VID_1C71&PID_C022" , # Brailliant BI 14
100- "VID_1C71&PID_C131" , # Brailliant BI 40X
101- "VID_1C71&PID_C141" , # Brailliant BI 20X
102109 "VID_1C71&PID_C00A" , # BrailleNote Touch
103110 "VID_1C71&PID_C00E" , # BrailleNote Touch v2
104111 },
105112 )
106113 driverRegistrar .addUsbDevices (
107- bdDetect .DeviceType .SERIAL ,
114+ bdDetect .ProtocolType .SERIAL ,
108115 {
109116 "VID_1C71&PID_C005" , # Brailliant BI 32, 40 and 80
110117 "VID_1C71&PID_C021" , # Brailliant BI 14
111118 },
112119 )
113120 driverRegistrar .addBluetoothDevices (
114121 lambda m : (
115- m .type == bdDetect .DeviceType .SERIAL
122+ m .type == bdDetect .ProtocolType .SERIAL
116123 and (
117124 m .id .startswith ("Brailliant B" ) or m .id == "Brailliant 80" or "BrailleNote Touch" in m .id
118125 )
119126 )
120127 or (
121- m .type == bdDetect .DeviceType .HID
128+ m .type == bdDetect .ProtocolType .HID
122129 and m .deviceInfo .get ("manufacturer" ) == "Humanware"
123- and m .deviceInfo .get ("product" )
124- in (
125- "Brailliant HID" ,
126- "APH Chameleon 20" ,
127- "APH Mantis Q40" ,
128- "Humanware BrailleOne" ,
129- "NLS eReader" ,
130- "NLS eReader Humanware" ,
131- "Brailliant BI 40X" ,
132- "Brailliant BI 20X" ,
130+ and (
131+ (
132+ m .deviceInfo .get ("product" )
133+ in (
134+ "APH Chameleon 20" ,
135+ "APH Mantis Q40" ,
136+ "Brailliant BI 40X" ,
137+ "Brailliant BI 20X" ,
138+ )
139+ and bdDetect ._isHIDUsagePageMatch (m , HID_USAGE_PAGE )
140+ )
141+ or m .deviceInfo .get ("product" )
142+ in (
143+ "Brailliant HID" ,
144+ "Humanware BrailleOne" ,
145+ "NLS eReader" ,
146+ "NLS eReader Humanware" ,
147+ )
133148 )
134149 ),
135150 )
@@ -143,10 +158,13 @@ def __init__(self, port="auto"):
143158 self .numCells = 0
144159
145160 for portType , portId , port , portInfo in self ._getTryPorts (port ):
146- self .isHid = portType == bdDetect .DeviceType .HID
161+ self .isHid = portType == bdDetect .ProtocolType .HID
147162 # Try talking to the display.
148163 try :
149164 if self .isHid :
165+ if (usasePage := portInfo .get ("HIDUsagePage" )) != HID_USAGE_PAGE :
166+ log .debugWarning (f"Ignoring device { port !r} with usage page { usasePage !r} " )
167+ continue
150168 self ._dev = hwIo .Hid (port , onReceive = self ._hidOnReceive )
151169 else :
152170 self ._dev = hwIo .Serial (
0 commit comments