File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,14 +177,15 @@ def find_and_init_report_mouse(cursor_image=DEFAULT_CURSOR): # noqa: PLR0912
177177 except usb .core .USBError as e :
178178 print_exception (e , e , None )
179179
180- mouse_was_attached = None
180+ mouse_was_attached = False
181181 if mouse_device is not None :
182182 # detach the kernel driver if needed
183- if mouse_device .is_kernel_driver_active (mouse_interface_index ):
184- mouse_was_attached = True
185- mouse_device .detach_kernel_driver (mouse_interface_index )
186- else :
187- mouse_was_attached = False
183+ # Typically HID devices have interfaces 0,1,2
184+ # Trying 0..mouse_iface is safe and sufficient
185+ for intf in range (mouse_interface_index + 1 ):
186+ if mouse_device .is_kernel_driver_active (intf ):
187+ mouse_was_attached = True
188+ mouse_device .detach_kernel_driver (intf )
188189
189190 # set configuration on the mouse so we can use it
190191 mouse_device .set_configuration ()
You can’t perform that action at this time.
0 commit comments