1919import gc
2020import sys
2121import time
22- import supervisor
2322import atexit
23+ import supervisor
2424import board
2525import displayio
2626import terminalio
@@ -220,8 +220,9 @@ def find_mouse(self): # pylint: disable=too-many-statements, too-many-locals
220220 return False
221221
222222 # Change the mouse resolution so it's not too sensitive
223+ fontHeight = terminalio .FONT .get_bounding_box ()[1 ]
223224 self .mouse .display_size = (supervisor .runtime .display .width * self .sensitivity ,
224- (supervisor .runtime .display .height - terminalio . FONT . get_bounding_box ()[ 1 ] )* self .sensitivity )
225+ (supervisor .runtime .display .height - fontHeight )* self .sensitivity )
225226 return True
226227
227228 def poll (self ):
@@ -396,6 +397,7 @@ def _cursor_bitmap_3():
396397
397398 self ._brush = 0
398399 self ._cursor_bitmaps = [_cursor_bitmap_1 (), _cursor_bitmap_3 ()]
400+ self .mouse = None
399401 if hasattr (board , "TOUCH_XL" ):
400402 self ._poller = TouchscreenPoller (self ._splash , self ._cursor_bitmaps [0 ])
401403 elif hasattr (board , "BUTTON_CLOCK" ):
@@ -404,6 +406,7 @@ def _cursor_bitmap_3():
404406 self ._poller = MousePoller (self ._splash , self ._cursor_bitmaps [0 ], self ._w , self ._h )
405407 if not self ._poller .mouse :
406408 raise RuntimeError ("No mouse found. Please connect a USB mouse." )
409+ self .mouse = self ._poller .mouse
407410 else :
408411 raise AttributeError ("PyPaint requires a mouse, touchscreen or cursor." )
409412
@@ -675,8 +678,8 @@ def atexit_callback():
675678 :return:
676679 """
677680 print ("inside atexit callback" )
678- if type ( painter ._poller ) == MousePoller :
679- mouse = painter ._poller . mouse
681+ if painter .mouse is not None :
682+ mouse = painter .mouse
680683 if mouse .was_attached and not mouse .device .is_kernel_driver_active (0 ):
681684 mouse .device .attach_kernel_driver (0 )
682685 # The keyboard buffer seems to have data left over from when it was detached
0 commit comments