Skip to content

Commit a7124f0

Browse files
committed
resolve mouse errors
1 parent ec3260c commit a7124f0

File tree

1 file changed

+9
-25
lines changed
  • Metro/Metro_RP2350_Memory/memory_game

1 file changed

+9
-25
lines changed

Metro/Metro_RP2350_Memory/memory_game/code.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import array
1111
import random
1212
import time
13-
import atexit
1413
from displayio import Group, OnDiskBitmap, TileGrid
1514
from adafruit_display_text.bitmap_label import Label
1615
from 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

317314
mouse_was_attached = None
318315
if 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
344328
buf = array.array("b", [0] * 4)

0 commit comments

Comments
 (0)