Skip to content

Commit 1d6cab5

Browse files
committed
enforce ints on sensitivity and x,y props
1 parent 0fdc197 commit 1d6cab5

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

adafruit_usb_host_mouse.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,35 +143,42 @@ def __init__(self, device, endpoint_address, tilegrid, was_attached, scale=1):
143143

144144
self.scale = scale
145145
"""The scale of the group that the Mouse TileGrid will be put into.
146-
Needed in order to properly clamp the mouse to the display bounds."""
147-
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."""
146+
Needed in order to properly clamp the mouse to the display bounds."""
151147

148+
self._sensitivity = 1
152149
self.display_size = (supervisor.runtime.display.width, supervisor.runtime.display.height)
153150

154151
@property
155-
def x(self):
152+
def x(self) -> int:
156153
"""
157154
The x coordinate of the mouse cursor
158155
"""
159156
return self.tilegrid.x
160157

161158
@x.setter
162-
def x(self, new_x):
163-
self.tilegrid.x = new_x
159+
def x(self, new_x: int) -> None:
160+
self.tilegrid.x = int(new_x)
164161

165162
@property
166-
def y(self):
163+
def y(self) -> int:
167164
"""
168165
The y coordinate of the mouse cursor
169166
"""
170167
return self.tilegrid.y
171168

172169
@y.setter
173-
def y(self, new_y):
174-
self.tilegrid.y = new_y
170+
def y(self, new_y: int) -> None:
171+
self.tilegrid.y = int(new_y)
172+
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)
175182

176183
def release(self):
177184
"""

0 commit comments

Comments
 (0)