1010import array
1111import random
1212import time
13- import atexit
1413from displayio import Group , OnDiskBitmap , TileGrid
1514from adafruit_display_text .bitmap_label import Label
1615from adafruit_display_text .text_box import TextBox
@@ -299,20 +298,18 @@ def update_score_text():
299298 print (f"{ device .idVendor :04x} :{ device .idProduct :04x} " )
300299 print (device .manufacturer , device .product )
301300 print (device .serial_number )
302-
303- config_descriptor = adafruit_usb_host_descriptors .get_configuration_descriptor (
304- device , 0
305- )
306-
307- _possible_interface_index , _possible_endpoint_address = (
301+ mouse_interface_index , mouse_endpoint_address = (
308302 adafruit_usb_host_descriptors .find_boot_mouse_endpoint (device ))
309303
310- if _possible_interface_index is not None and _possible_endpoint_address is not None :
304+ if mouse_interface_index is not None and mouse_endpoint_address is not None :
311305 mouse = device
312- mouse_interface_index = _possible_interface_index
313- mouse_endpoint_address = _possible_endpoint_address
314- print (f"mouse interface: { mouse_interface_index } " , end = "" )
315- print (f"endpoint_address: { hex (mouse_endpoint_address )} " )
306+ print (
307+ f"mouse interface: { mouse_interface_index } "
308+ + f"endpoint_address: { hex (mouse_endpoint_address )} "
309+ )
310+
311+ break
312+
316313
317314mouse_was_attached = None
318315if mouse is not None :
@@ -326,19 +323,6 @@ def update_score_text():
326323 # set configuration on the mouse so we can use it
327324 mouse .set_configuration ()
328325
329-
330- def atexit_callback ():
331- """
332- re-attach USB devices to kernel if needed.
333- :return:
334- """
335- print ("inside atexit callback" )
336- if mouse_was_attached and not mouse .is_kernel_driver_active (0 ):
337- mouse .attach_kernel_driver (0 )
338-
339-
340- atexit .register (atexit_callback )
341-
342326# Buffer to hold data read from the mouse
343327# Boot mice have 4 byte reports
344328buf = array .array ("b" , [0 ] * 4 )
0 commit comments