@@ -127,38 +127,50 @@ class BootMouse:
127
127
:param endpoint_address: The address of the mouse endpoint
128
128
:param tilegrid: The TileGrid that holds the visible mouse cursor
129
129
:param was_attached: Whether the usb device was attached to the kernel
130
+ :param scale: The scale of the group that the Mouse TileGrid will be put into.
131
+ Needed in order to properly clamp the mouse to the display bounds
130
132
"""
131
133
132
134
def __init__ (self , device , endpoint_address , tilegrid , was_attached , scale = 1 ): # noqa: PLR0913, too many args
133
135
self .device = device
136
+
134
137
self .tilegrid = tilegrid
138
+ """TileGrid containing the Mouse cursor graphic."""
139
+
135
140
self .endpoint = endpoint_address
136
141
self .buffer = array .array ("b" , [0 ] * 4 )
137
142
self .was_attached = was_attached
143
+
138
144
self .scale = scale
145
+ """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."""
139
151
140
152
self .display_size = (supervisor .runtime .display .width , supervisor .runtime .display .height )
141
153
142
154
@property
143
- def x (self ):
155
+ def x (self ) -> int :
144
156
"""
145
157
The x coordinate of the mouse cursor
146
158
"""
147
159
return self .tilegrid .x
148
160
149
161
@x .setter
150
- def x (self , new_x ) :
162
+ def x (self , new_x : int ) -> None :
151
163
self .tilegrid .x = new_x
152
164
153
165
@property
154
- def y (self ):
166
+ def y (self ) -> int :
155
167
"""
156
168
The y coordinate of the mouse cursor
157
169
"""
158
170
return self .tilegrid .y
159
171
160
172
@y .setter
161
- def y (self , new_y ) :
173
+ def y (self , new_y : int ) -> None :
162
174
self .tilegrid .y = new_y
163
175
164
176
def release (self ):
@@ -191,10 +203,18 @@ def update(self):
191
203
# update the mouse tilegrid x and y coordinates
192
204
# based on the delta values read from the mouse
193
205
self .tilegrid .x = max (
194
- 0 , min ((self .display_size [0 ] // self .scale ) - 1 , self .tilegrid .x + self .buffer [1 ])
206
+ 0 ,
207
+ min (
208
+ (self .display_size [0 ] // self .scale ) - 1 ,
209
+ self .tilegrid .x + int (round ((self .buffer [1 ] / self .sensitivity ), 0 )),
210
+ ),
195
211
)
196
212
self .tilegrid .y = max (
197
- 0 , min ((self .display_size [1 ] // self .scale ) - 1 , self .tilegrid .y + self .buffer [2 ])
213
+ 0 ,
214
+ min (
215
+ (self .display_size [1 ] // self .scale ) - 1 ,
216
+ self .tilegrid .y + int (round ((self .buffer [2 ] / self .sensitivity ), 0 )),
217
+ ),
198
218
)
199
219
200
220
pressed_btns = []
0 commit comments