|
32 | 32 | import array |
33 | 33 | from traceback import print_exception |
34 | 34 |
|
| 35 | +import adafruit_imageload |
35 | 36 | import adafruit_usb_host_descriptors |
36 | 37 | import usb |
37 | | -from displayio import OnDiskBitmap, TileGrid |
| 38 | +from displayio import Bitmap, Palette, TileGrid |
38 | 39 |
|
39 | 40 | __version__ = "0.0.0+auto.0" |
40 | 41 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse.git" |
@@ -119,13 +120,15 @@ def find_and_init_mouse(cursor_image=DEFAULT_CURSOR, subclass=SUBCLASS_BOOT): |
119 | 120 | # load the mouse cursor bitmap |
120 | 121 | mouse_tg = None |
121 | 122 | if isinstance(cursor_image, str): |
122 | | - mouse_bmp = OnDiskBitmap(cursor_image) |
| 123 | + mouse_bmp, mouse_palette = adafruit_imageload.load( |
| 124 | + cursor_image, bitmap=Bitmap, palette=Palette |
| 125 | + ) |
123 | 126 |
|
124 | 127 | # make the background pink pixels transparent |
125 | | - mouse_bmp.pixel_shader.make_transparent(0) |
| 128 | + mouse_palette.make_transparent(0) |
126 | 129 |
|
127 | 130 | # create a TileGrid for the mouse, using its bitmap and pixel_shader |
128 | | - mouse_tg = TileGrid(mouse_bmp, pixel_shader=mouse_bmp.pixel_shader) |
| 131 | + mouse_tg = TileGrid(mouse_bmp, pixel_shader=mouse_palette) |
129 | 132 |
|
130 | 133 | return ( |
131 | 134 | (mouse_device, mouse_interface_index, mouse_endpoint_address, mouse_was_attached), |
@@ -268,7 +271,10 @@ def release(self): |
268 | 271 | # an empty list if no interfaces were detached |
269 | 272 | for intf in self.was_attached: |
270 | 273 | if not self.device.is_kernel_driver_active(intf): |
271 | | - self.device.attach_kernel_driver(intf) |
| 274 | + try: |
| 275 | + self.device.attach_kernel_driver(intf) |
| 276 | + except usb.core.USBError: |
| 277 | + pass |
272 | 278 |
|
273 | 279 | def update(self): |
274 | 280 | """ |
|
0 commit comments