Skip to content

Commit d7302ea

Browse files
authored
Merge pull request #34 from FoamyGuy/editor_keyboardmouse_combo_fix
only try to find mouse if there are at least 2 USB devices in editor.
2 parents 6714862 + 7fe7b0d commit d7302ea

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

builtin_apps/editor/code.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
import supervisor
55
from displayio import Group, Palette, TileGrid
6-
import terminalio
76
from adafruit_display_text.bitmap_label import Label
87
from adafruit_editor import editor, picker
98
from tilepalettemapper import TilePaletteMapper
109
from adafruit_argv_file import read_argv, write_argv
1110
from adafruit_fruitjam.peripherals import request_display_config
1211
from adafruit_usb_host_mouse import find_and_init_boot_mouse
12+
import terminalio
13+
import usb
1314

1415
print(f"cwd in editor/code.py: {os.getcwd()}")
1516

@@ -25,7 +26,6 @@
2526
font_palette[0] = 0x000000
2627
font_palette[1] = 0xFFFFFF
2728

28-
2929
font = terminalio.FONT
3030
char_size = font.get_bounding_box()
3131
screen_size = (display.width // char_size[0], display.height // char_size[1])
@@ -62,7 +62,14 @@
6262
else:
6363
file = picker.pick_file(terminal)
6464

65-
mouse = find_and_init_boot_mouse()
65+
usb_device_count = 0
66+
for dev in usb.core.find(find_all=True):
67+
usb_device_count += 1
68+
69+
mouse = None
70+
if usb_device_count > 1:
71+
mouse = find_and_init_boot_mouse()
72+
6673
if mouse is not None:
6774
mouse.x = display.width - 6
6875
main_group.append(mouse.tilegrid)

0 commit comments

Comments
 (0)