Skip to content

Commit 2230a12

Browse files
committed
data_len should never be 0, remove unnecessary test
1 parent b7f5684 commit 2230a12

File tree

1 file changed

+16
-17
lines changed
  • Metro/Metro_RP2350_Match3/match3_game

1 file changed

+16
-17
lines changed

Metro/Metro_RP2350_Match3/match3_game/code.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,23 +394,22 @@ def atexit_callback():
394394
data_len = mouse.read(
395395
mouse_endpoint_addresses[i], mouse_bufs[i], timeout=20
396396
)
397-
if data_len > 0:
398-
mouse_deltas = get_mouse_deltas(mouse_bufs[i], data_len, i)
399-
# if we got data, then update the mouse cursor on the display
400-
# using min and max to keep it within the bounds of the display
401-
mouse_tg.x = max(
402-
0,
403-
min(
404-
display.width // scale_factor - 1, mouse_tg.x + mouse_deltas[0] // 2
405-
),
406-
)
407-
mouse_tg.y = max(
408-
0,
409-
min(
410-
display.height // scale_factor - 1,
411-
mouse_tg.y + mouse_deltas[1] // 2,
412-
),
413-
)
397+
mouse_deltas = get_mouse_deltas(mouse_bufs[i], data_len, i)
398+
# if we got data, then update the mouse cursor on the display
399+
# using min and max to keep it within the bounds of the display
400+
mouse_tg.x = max(
401+
0,
402+
min(
403+
display.width // scale_factor - 1, mouse_tg.x + mouse_deltas[0] // 2
404+
),
405+
)
406+
mouse_tg.y = max(
407+
0,
408+
min(
409+
display.height // scale_factor - 1,
410+
mouse_tg.y + mouse_deltas[1] // 2,
411+
),
412+
)
414413

415414
# timeout error is raised if no data was read within the allotted timeout
416415
except usb.core.USBTimeoutError:

0 commit comments

Comments
 (0)