@@ -127,15 +127,27 @@ class BootMouse:
127127 :param endpoint_address: The address of the mouse endpoint
128128 :param tilegrid: The TileGrid that holds the visible mouse cursor
129129 :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
130132 """
131133
132134 def __init__ (self , device , endpoint_address , tilegrid , was_attached , scale = 1 ): # noqa: PLR0913, too many args
133135 self .device = device
136+
134137 self .tilegrid = tilegrid
138+ """TileGrid containing the Mouse cursor graphic."""
139+
135140 self .endpoint = endpoint_address
136141 self .buffer = array .array ("b" , [0 ] * 4 )
137142 self .was_attached = was_attached
143+
138144 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."""
139151
140152 self .display_size = (supervisor .runtime .display .width , supervisor .runtime .display .height )
141153
@@ -191,10 +203,18 @@ def update(self):
191203 # update the mouse tilegrid x and y coordinates
192204 # based on the delta values read from the mouse
193205 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 + (self .buffer [1 ] // self .sensitivity ),
210+ ),
195211 )
196212 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 + (self .buffer [2 ] // self .sensitivity ),
217+ ),
198218 )
199219
200220 pressed_btns = []
0 commit comments