Skip to content

Commit

Permalink
Introduce constant for Logitech vendor ID
Browse files Browse the repository at this point in the history
The Vendor ID for Logitech is 0x46D = 1133.
  • Loading branch information
MattHag committed May 28, 2024
1 parent 2a2895c commit 04bdf3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/logitech_receiver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from . import hidpp10_constants
from . import hidpp20
from . import hidpp20_constants
from .common import LOGITECH_VENDOR_ID

logger = logging.getLogger(__name__)

Expand All @@ -59,7 +60,7 @@ def __str__(self):

def _usb_device(product_id: int, usb_interface: int) -> dict[str, Any]:
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"bus_id": 3,
"usb_interface": usb_interface,
Expand All @@ -68,7 +69,7 @@ def _usb_device(product_id: int, usb_interface: int) -> dict[str, Any]:


def _bluetooth_device(product_id: int) -> dict[str, Any]:
return {"vendor_id": 1133, "product_id": product_id, "bus_id": 5, "isDevice": True}
return {"vendor_id": LOGITECH_VENDOR_ID, "product_id": product_id, "bus_id": 5, "isDevice": True}


KNOWN_DEVICE_IDS = []
Expand All @@ -84,7 +85,7 @@ def _bluetooth_device(product_id: int) -> dict[str, Any]:
def other_device_check(bus_id: int, vendor_id: int, product_id: int):
"""Check whether product is a Logitech USB-connected or Bluetooth device based on bus, vendor, and product IDs
This allows Solaar to support receiverless HID++ 2.0 devices that it knows nothing about"""
if vendor_id != 0x46D: # Logitech
if vendor_id != LOGITECH_VENDOR_ID:
return
if bus_id == 0x3: # USB
if product_id >= 0xC07D and product_id <= 0xC094 or product_id >= 0xC32B and product_id <= 0xC344:
Expand Down Expand Up @@ -151,7 +152,7 @@ def filter_receivers(bus_id, vendor_id, product_id, hidpp_short=False, hidpp_lon
for record in base_usb.ALL: # known receivers
if match(record, bus_id, vendor_id, product_id):
return record
if vendor_id == 0x046D and 0xC500 <= product_id <= 0xC5FF: # unknown receiver
if vendor_id == LOGITECH_VENDOR_ID and 0xC500 <= product_id <= 0xC5FF: # unknown receiver
return {"vendor_id": vendor_id, "product_id": product_id, "bus_id": bus_id, "isDevice": False}


Expand Down
18 changes: 10 additions & 8 deletions lib/logitech_receiver/base_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

from solaar.i18n import _

from logitech_receiver.common import LOGITECH_VENDOR_ID

# max_devices is only used for receivers that do not support reading from _R.receiver_info offset 0x03, default to 1
# may_unpair is only used for receivers that do not support reading from _R.receiver_info offset 0x03, default to False
# unpair is for receivers that do support reading from _R.receiver_info offset 0x03, no default
Expand All @@ -36,7 +38,7 @@

def _bolt_receiver(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 2,
"name": _("Bolt Receiver"),
Expand All @@ -48,7 +50,7 @@ def _bolt_receiver(product_id):

def _unifying_receiver(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 2,
"name": _("Unifying Receiver"),
Expand All @@ -59,7 +61,7 @@ def _unifying_receiver(product_id):

def _nano_receiver(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 1,
"name": _("Nano Receiver"),
Expand All @@ -71,7 +73,7 @@ def _nano_receiver(product_id):

def _nano_receiver_no_unpair(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 1,
"name": _("Nano Receiver"),
Expand All @@ -84,7 +86,7 @@ def _nano_receiver_no_unpair(product_id):

def _nano_receiver_max2(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 1,
"name": _("Nano Receiver"),
Expand All @@ -97,7 +99,7 @@ def _nano_receiver_max2(product_id):

def _nano_receiver_maxn(product_id, max):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 1,
"name": _("Nano Receiver"),
Expand All @@ -121,7 +123,7 @@ def _lenovo_receiver(product_id):

def _lightspeed_receiver(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 2,
"receiver_kind": "lightspeed",
Expand All @@ -132,7 +134,7 @@ def _lightspeed_receiver(product_id):

def _ex100_receiver(product_id):
return {
"vendor_id": 1133,
"vendor_id": LOGITECH_VENDOR_ID,
"product_id": product_id,
"usb_interface": 1,
"name": _("EX100 Receiver 27 Mhz"),
Expand Down
2 changes: 2 additions & 0 deletions lib/logitech_receiver/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

from solaar.i18n import _

LOGITECH_VENDOR_ID = 0x046D


def crc16(data: bytes):
"""
Expand Down

0 comments on commit 04bdf3b

Please sign in to comment.