Skip to content

Commit a011ecf

Browse files
committed
Add check to skip over keyboard
1 parent d0cb33b commit a011ecf

File tree

1 file changed

+16
-0
lines changed
  • Metro/Metro_RP2350_Minesweeper

1 file changed

+16
-0
lines changed

Metro/Metro_RP2350_Minesweeper/code.py

100755100644
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ def update_ui():
138138
# set the mouse configuration so it can be used
139139
mouse.set_configuration()
140140

141+
# Verify mouse works by reading from it
142+
buf = array.array("b", [0] * 4)
143+
try:
144+
# Try to read some data with a short timeout
145+
data = mouse.read(0x81, buf, timeout=100)
146+
print(f"Mouse test read successful: {data} bytes")
147+
break
148+
except usb.core.USBTimeoutError:
149+
# Timeout is normal if mouse isn't moving
150+
print("Mouse connected but not sending data (normal)")
151+
break
152+
except Exception as e: # pylint: disable=broad-except
153+
print(f"Mouse test read failed: {e}")
154+
# Continue to try next device or retry
155+
mouse = None
156+
141157
buf = array.array("b", [0] * 4)
142158
waiting_for_release = False
143159
left_button = right_button = False

0 commit comments

Comments
 (0)