Skip to content

Commit e7e3021

Browse files
committed
Use constant for default cursor image path
1 parent 49a2d49 commit e7e3021

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

adafruit_usb_host_mouse/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse.git"
4242

4343
BUTTONS = ["left", "right", "middle"]
44+
DEFAULT_CURSOR = "/".join(__file__.split("/")[:-1]) + "/mouse_cursor.bmp"
4445

4546

46-
def find_and_init_boot_mouse(cursor_image=None): # noqa: PLR0912
47+
def find_and_init_boot_mouse(cursor_image=DEFAULT_CURSOR): # noqa: PLR0912
4748
"""
4849
Scan for an attached boot mouse connected via USB host.
49-
If one is found initialize an instance of BootMouse class
50+
If one is found initialize an instance of :class:`BootMouse` class
5051
and return it.
5152
52-
:param cursor_image: Provide the absolute path to the desired cursor bitmap image. If not
53-
provided or set to `None`, the bitmap image included with this library will be used. If set as
54-
`False`, the BootMouse instance will not control a :class:`displayio.TileGrid`.
55-
:return: The BootMouse instance or None if no mouse was found.
53+
:param cursor_image: Provide the absolute path to the desired cursor bitmap image. If set as
54+
`None`, the :class:`BootMouse` instance will not control a :class:`displayio.TileGrid` object.
55+
:return: The :class:`BootMouse` instance or None if no mouse was found.
5656
"""
5757
mouse_interface_index, mouse_endpoint_address = None, None
5858
mouse_device = None
@@ -104,10 +104,6 @@ def find_and_init_boot_mouse(cursor_image=None): # noqa: PLR0912
104104
# set configuration on the mouse so we can use it
105105
mouse_device.set_configuration()
106106

107-
# get path of included cursor bitmap
108-
if cursor_image is None:
109-
cursor_image = "/".join(__file__.split("/")[:-1]) + "/mouse_cursor.bmp"
110-
111107
# load the mouse cursor bitmap
112108
if isinstance(cursor_image, str):
113109
mouse_bmp = OnDiskBitmap(cursor_image)

0 commit comments

Comments
 (0)