Skip to content

Commit 01241d9

Browse files
committed
convert to int and round inside of update() instead of prop set.
1 parent 1d6cab5 commit 01241d9

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

adafruit_usb_host_mouse.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ def __init__(self, device, endpoint_address, tilegrid, was_attached, scale=1):
145145
"""The scale of the group that the Mouse TileGrid will be put into.
146146
Needed in order to properly clamp the mouse to the display bounds."""
147147

148-
self._sensitivity = 1
148+
self.sensitivity = 1
149+
"""The sensitivity of the mouse cursor. Larger values will make
150+
the mouse cursor move slower relative to physical mouse movement. Default is 1."""
151+
149152
self.display_size = (supervisor.runtime.display.width, supervisor.runtime.display.height)
150153

151154
@property
@@ -170,15 +173,6 @@ def y(self) -> int:
170173
def y(self, new_y: int) -> None:
171174
self.tilegrid.y = int(new_y)
172175

173-
@property
174-
def sensitivity(self) -> int:
175-
"""The sensitivity of the mouse cursor. Larger values will make
176-
the mouse cursor move slower relative to physical mouse movement. Default is 1."""
177-
return self._sensitivity
178-
179-
@sensitivity.setter
180-
def sensitivity(self, new_sensitivity: int) -> None:
181-
self._sensitivity = int(new_sensitivity)
182176

183177
def release(self):
184178
"""
@@ -213,14 +207,14 @@ def update(self):
213207
0,
214208
min(
215209
(self.display_size[0] // self.scale) - 1,
216-
self.tilegrid.x + (self.buffer[1] // self.sensitivity),
210+
self.tilegrid.x + int(round((self.buffer[1] // self.sensitivity), 0)),
217211
),
218212
)
219213
self.tilegrid.y = max(
220214
0,
221215
min(
222216
(self.display_size[1] // self.scale) - 1,
223-
self.tilegrid.y + (self.buffer[2] // self.sensitivity),
217+
self.tilegrid.y + int(round((self.buffer[2] // self.sensitivity), 0)),
224218
),
225219
)
226220

0 commit comments

Comments
 (0)