Skip to content

Commit 63b874f

Browse files
committed
Fix for #417
I added a check to the method `busylight.lights.light.Light.update` that prepends a zero byte to the bytes object that will be sent to a device if the current platform is Windows. This is necessary because the Windows HID API requires a report ID to be sent with the data and the underlying hidapi library doesn't seem to handle this for us on Windows but does handle it on Linux and macOS.
1 parent 5730f6e commit 63b874f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

busylight/lights/light.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@
1212
1313
"""
1414

15-
1615
import abc
1716
import asyncio
18-
17+
import platform
1918
from contextlib import contextmanager
2019
from functools import lru_cache
21-
from typing import (
22-
Any,
23-
Callable,
24-
Generator,
25-
Dict,
26-
List,
27-
Tuple,
28-
Type,
29-
Union,
30-
)
20+
from typing import Any, Callable, Dict, Generator, List, Tuple, Type, Union
3121

3222
from loguru import logger
3323

@@ -37,7 +27,6 @@
3727
LightUnsupported,
3828
NoLightsFound,
3929
)
40-
4130
from .taskable import TaskableMixin
4231

4332
LightType = Type["Light"]
@@ -549,7 +538,10 @@ def update(self) -> None:
549538
- LightUnavailable
550539
"""
551540

552-
data = bytes(self)
541+
if platform.system() == "Windows":
542+
data = bytes([0x00]) + bytes(self)
543+
else:
544+
data = bytes(self)
553545

554546
with self.exclusive_access():
555547
try:

0 commit comments

Comments
 (0)