From a011ecf509bedb2125443b0bfc7950f5f3b057f7 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 18 Aug 2025 21:59:29 -0400 Subject: [PATCH] Add check to skip over keyboard --- Metro/Metro_RP2350_Minesweeper/code.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) mode change 100755 => 100644 Metro/Metro_RP2350_Minesweeper/code.py diff --git a/Metro/Metro_RP2350_Minesweeper/code.py b/Metro/Metro_RP2350_Minesweeper/code.py old mode 100755 new mode 100644 index 6f3abec32..ea1100fa4 --- a/Metro/Metro_RP2350_Minesweeper/code.py +++ b/Metro/Metro_RP2350_Minesweeper/code.py @@ -138,6 +138,22 @@ for device in usb.core.find(find_all=True): # set the mouse configuration so it can be used mouse.set_configuration() + # Verify mouse works by reading from it + buf = array.array("b", [0] * 4) + try: + # Try to read some data with a short timeout + data = mouse.read(0x81, buf, timeout=100) + print(f"Mouse test read successful: {data} bytes") + break + except usb.core.USBTimeoutError: + # Timeout is normal if mouse isn't moving + print("Mouse connected but not sending data (normal)") + break + except Exception as e: # pylint: disable=broad-except + print(f"Mouse test read failed: {e}") + # Continue to try next device or retry + mouse = None + buf = array.array("b", [0] * 4) waiting_for_release = False left_button = right_button = False