Skip to content

Commit

Permalink
Fix for #417
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JnyJny committed Nov 26, 2024
1 parent 5730f6e commit 63b874f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions busylight/lights/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,12 @@
"""


import abc
import asyncio

import platform
from contextlib import contextmanager
from functools import lru_cache
from typing import (
Any,
Callable,
Generator,
Dict,
List,
Tuple,
Type,
Union,
)
from typing import Any, Callable, Dict, Generator, List, Tuple, Type, Union

from loguru import logger

Expand All @@ -37,7 +27,6 @@
LightUnsupported,
NoLightsFound,
)

from .taskable import TaskableMixin

LightType = Type["Light"]
Expand Down Expand Up @@ -549,7 +538,10 @@ def update(self) -> None:
- LightUnavailable
"""

data = bytes(self)
if platform.system() == "Windows":
data = bytes([0x00]) + bytes(self)
else:
data = bytes(self)

with self.exclusive_access():
try:
Expand Down

0 comments on commit 63b874f

Please sign in to comment.