Introduce Enum BusID

Distinguishes Bluetooth and USB devices.
This commit is contained in:
MattHag 2024-05-28 02:53:32 +02:00 committed by Peter F. Patel-Schneider
parent 7f5e156fa1
commit 86b55b9c25
2 changed files with 11 additions and 4 deletions

View File

@ -39,6 +39,7 @@ from . import hidpp10_constants
from . import hidpp20
from . import hidpp20_constants
from .common import LOGITECH_VENDOR_ID
from .common import BusID
logger = logging.getLogger(__name__)
@ -62,14 +63,14 @@ def _usb_device(product_id: int, usb_interface: int) -> dict[str, Any]:
return {
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"bus_id": 3,
"bus_id": BusID.USB,
"usb_interface": usb_interface,
"isDevice": True,
}
def _bluetooth_device(product_id: int) -> dict[str, Any]:
return {"vendor_id": LOGITECH_VENDOR_ID, "product_id": product_id, "bus_id": 5, "isDevice": True}
return {"vendor_id": LOGITECH_VENDOR_ID, "product_id": product_id, "bus_id": BusID.BLUETOOTH, "isDevice": True}
KNOWN_DEVICE_IDS = []
@ -87,10 +88,11 @@ def other_device_check(bus_id: int, vendor_id: int, product_id: int):
This allows Solaar to support receiverless HID++ 2.0 devices that it knows nothing about"""
if vendor_id != LOGITECH_VENDOR_ID:
return
if bus_id == 0x3: # USB
if bus_id == BusID.USB:
if product_id >= 0xC07D and product_id <= 0xC094 or product_id >= 0xC32B and product_id <= 0xC344:
return _usb_device(product_id, 2)
elif bus_id == 0x5: # Bluetooth
elif bus_id == BusID.BLUETOOTH:
if product_id >= 0xB012 and product_id <= 0xB0FF or product_id >= 0xB317 and product_id <= 0xB3FF:
return _bluetooth_device(product_id)

View File

@ -631,3 +631,8 @@ class Notification(IntEnum):
RAW_INPUT = 0x49
PAIRING_LOCK = 0x4A
POWER = 0x4B
class BusID(IntEnum):
USB = 0x03
BLUETOOTH = 0x05