Skip to content

Commit b585540

Browse files
committed
Merge branch 'refs/heads/main' into cursor-bitmap
# Conflicts: # adafruit_usb_host_mouse/__init__.py
2 parents e7e3021 + d214ace commit b585540

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

adafruit_usb_host_mouse/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ def __init__(self, device, endpoint_address, was_attached, tilegrid=None, scale=
155155
"""The sensitivity of the mouse cursor. Larger values will make
156156
the mouse cursor move slower relative to physical mouse movement. Default is 1."""
157157

158+
self.pressed_btns = []
159+
"""List of buttons currently pressed (one or more of "left", "right", "middle")
160+
If there's no new mouse data (nothing changes) this property can be checked to see
161+
which buttons are currently pressed."""
162+
158163
if tilegrid is not None:
159164
self.display_size = (
160165
supervisor.runtime.display.width,
@@ -238,13 +243,13 @@ def update(self):
238243
self._x += dx
239244
self._y += dy
240245

241-
pressed_btns = []
246+
self.pressed_btns = []
242247
for i, button in enumerate(BUTTONS):
243248
# check if each button is pressed using bitwise AND shifted
244249
# to the appropriate index for this button
245250
if self.buffer[0] & (1 << i) != 0:
246251
# append the button name to the string to show if
247252
# it is being clicked.
248-
pressed_btns.append(button)
253+
self.pressed_btns.append(button)
249254

250-
return tuple(pressed_btns)
255+
return tuple(self.pressed_btns)

0 commit comments

Comments
 (0)