diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 45454567..d903707f 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -32,7 +32,6 @@ from . import exceptions from . import hidpp10 as _hidpp10 from . import hidpp10_constants as _hidpp10_constants from . import hidpp20 as _hidpp20 -from . import hidpp20_constants as _hidpp20_constants from .settings_templates import check_feature_settings as _check_feature_settings logger = logging.getLogger(__name__) @@ -40,8 +39,6 @@ logger = logging.getLogger(__name__) _R = _hidpp10_constants.REGISTERS _IR = _hidpp10_constants.INFO_SUBREGISTERS -KIND_MAP = {kind: _hidpp10_constants.DEVICE_KIND[str(kind)] for kind in _hidpp20_constants.DEVICE_KIND} - class Device: instances = [] @@ -195,8 +192,7 @@ class Device: @property def kind(self): if not self._kind and self.online and self.protocol >= 2.0: - kind = _hidpp20.get_kind(self) - self._kind = KIND_MAP[kind] if kind else None + self._kind = _hidpp20.get_kind(self) return self._kind or "?" @property diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 2dc61451..7db9ee4f 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -29,6 +29,7 @@ from typing import List, Optional import yaml as _yaml from . import exceptions, special_keys +from . import hidpp10_constants as _hidpp10_constants from .common import BATTERY_APPROX as _BATTERY_APPROX from .common import FirmwareInfo as _FirmwareInfo from .common import NamedInt as _NamedInt @@ -37,8 +38,7 @@ from .common import UnsortedNamedInts as _UnsortedNamedInts from .common import bytes2int as _bytes2int from .common import crc16 as _crc16 from .common import int2bytes as _int2bytes -from .hidpp20_constants import BATTERY_STATUS, CHARGE_LEVEL, CHARGE_STATUS, CHARGE_TYPE, DEVICE_KIND, ERROR, FEATURE, GESTURE -from .hidpp20_constants import FIRMWARE_KIND as _FIRMWARE_KIND +from .hidpp20_constants import BATTERY_STATUS, CHARGE_LEVEL, CHARGE_STATUS, CHARGE_TYPE, DEVICE_KIND, ERROR, FEATURE, FIRMWARE_KIND, GESTURE from .i18n import _ logger = logging.getLogger(__name__) @@ -277,9 +277,7 @@ class ReprogrammableKeyV4(ReprogrammableKey): raise exceptions.FeatureCallError(msg="No reply from device.") except exceptions.FeatureCallError: # if the key hasn't ever been configured only produce a warning if logger.isEnabledFor(logging.WARNING): - logger.warn( - f"Feature Call Error in _getCidReporting on device {self._device} for cid {self._cid} - use defaults" - ) + logger.warn(f"Feature Call Error in _getCidReporting on device {self._device} for cid {self._cid} - use defaults") # Clear flags and set mapping target to self self._mapping_flags = 0 self._mapped_to = self._cid @@ -546,9 +544,7 @@ class KeysArrayPersistent(KeysArray): if keydata: key = _unpack("!H", keydata[:2])[0] try: - mapped_data = feature_request( - self.device, FEATURE.PERSISTENT_REMAPPABLE_ACTION, 0x30, key & 0xFF00, key & 0xFF, 0xFF - ) + mapped_data = feature_request(self.device, FEATURE.PERSISTENT_REMAPPABLE_ACTION, 0x30, key & 0xFF00, key & 0xFF, 0xFF) if mapped_data: _ignore, _ignore, actionId, remapped, modifiers, status = _unpack("!HBBHBB", mapped_data[:8]) except Exception: @@ -875,9 +871,7 @@ class Backlight: if not response: raise exceptions.FeatureCallError(msg="No reply from device.") self.device = device - self.enabled, self.options, supported, effects, self.level, self.dho, self.dhi, self.dpow = _unpack( - "