Skip to content

Commit 3f18217

Browse files
committed
update for multi interface detach
1 parent 25c9109 commit 3f18217

File tree

2 files changed

+14
-9
lines changed
  • Fruit_Jam/Fruit_Jam_PyPaint
  • Metro/Metro_RP2350_Memory/memory_game

2 files changed

+14
-9
lines changed

Fruit_Jam/Fruit_Jam_PyPaint/code.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,12 @@ def atexit_callback():
680680
print("inside atexit callback")
681681
if painter.mouse is not None:
682682
mouse = painter.mouse
683-
if mouse.was_attached and not mouse.device.is_kernel_driver_active(mouse.interface):
684-
mouse.device.attach_kernel_driver(mouse.interface)
683+
if mouse.was_attached:
684+
# Typically HID devices have interfaces 0,1,2
685+
# Trying 0..mouse_iface is safe and sufficient
686+
for intf in range(mouse.interface+1):
687+
if not mouse.device.is_kernel_driver_active(intf):
688+
mouse.device.attach_kernel_driver(intf)
685689
# The keyboard buffer seems to have data left over from when it was detached
686690
# This clears it before the next process starts
687691
while supervisor.runtime.serial_bytes_available:

Metro/Metro_RP2350_Memory/memory_game/code.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,14 @@ def atexit_callback():
310310
:return:
311311
"""
312312
print("inside atexit callback")
313-
if mouse is not None:
314-
if (
315-
mouse_ptr.was_attached and
316-
not mouse_ptr.device.is_kernel_driver_active(mouse_ptr.interface)
317-
):
318-
319-
mouse.attach_kernel_driver(mouse_ptr.interface)
313+
if mouse_ptr.device is not None:
314+
if mouse_ptr.was_attached:
315+
# Typically HID devices have interfaces 0,1,2
316+
# Trying 0..mouse_iface is safe and sufficient
317+
for intf in range(mouse_ptr.interface+1):
318+
if not mouse_ptr.device.is_kernel_driver_active(intf):
319+
mouse_ptr.device.attach_kernel_driver(intf)
320+
320321
# The keyboard buffer seems to have data left over from when it was detached
321322
# This clears it before the next process starts
322323
while supervisor.runtime.serial_bytes_available:

0 commit comments

Comments
 (0)