Repository: pwr-Solaar/Solaar

Issue:
G203 Misidentified as G102
This is a minor issue, but as mentioned in [this PR](https://github.com/pwr-Solaar/Solaar/pull/1953) my G203 mouse is identified as a G102 mouse.

here is the output of `solaar -ddd show`
[show.log](https://github.com/pwr-Solaar/Solaar/files/10333522/show.log)
it does report it's name as `Name: G203 LIGHTSYNC Gaming Mouse`

[A suggestion](https://github.com/pwr-Solaar/Solaar/pull/1953#issuecomment-1369185225) was to remove the name override in `logitech_receiver/descriptors.py` but I assume that would break other devices with the same ID. Is there a 'proper' way to solve this? Again it's just a minor issue so just close this issue if not.



Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/descriptors.py b/lib/logitech_receiver/descriptors.py
--- a/lib/logitech_receiver/descriptors.py
+++ b/lib/logitech_receiver/descriptors.py
@@ -57,7 +57,6 @@ def _D(
     interface=None,
     btid=None,
 ):
-    assert name
 
     if kind is None:
         kind = (
@@ -66,13 +65,7 @@ def _D(
         )
     assert kind is not None, 'descriptor for %s does not have kind set' % name
 
-    # heuristic: the codename is the last word in the device name
-    if codename is None and ' ' in name:
-        codename = name.split(' ')[-1]
-    assert codename is not None, 'descriptor for %s does not have codename set' % name
-
     if protocol is not None:
-
         if wpid:
             for w in wpid if isinstance(wpid, tuple) else (wpid, ):
                 if protocol > 1.0:
@@ -104,7 +97,8 @@ def _D(
         assert found is None, 'duplicate btid in device descriptors: %s' % (found, )
 
     assert codename not in DEVICES, 'duplicate codename in device descriptors: %s' % (DEVICES[codename], )
-    DEVICES[codename] = device_descriptor
+    if codename:
+        DEVICES[codename] = device_descriptor
 
     if wpid:
         for w in wpid if isinstance(wpid, tuple) else (wpid, ):
@@ -181,25 +175,27 @@ def get_btid(btid):
 
 _D('Wireless Keyboard S510', codename='S510', protocol=1.0, wpid='0056', registers=(_R.battery_status, ))
 _D('Wireless Keyboard EX100', codename='EX100', protocol=1.0, wpid='0065', registers=(_R.battery_status, ))
-_D('Wireless Keyboard MK300', protocol=1.0, wpid='0068', registers=(_R.battery_status, ))
-_D('Number Pad N545', protocol=1.0, wpid='2006', registers=(_R.battery_status, ))
-_D('Wireless Compact Keyboard K340', protocol=1.0, wpid='2007', registers=(_R.battery_status, ))
-_D('Wireless Keyboard MK700', protocol=1.0, wpid='2008', registers=(_R.battery_status, ), settings=[_ST.RegisterFnSwap])
-_D('Wireless Wave Keyboard K350', protocol=1.0, wpid='200A', registers=(_R.battery_status, ))
-_D('Wireless Keyboard MK320', protocol=1.0, wpid='200F', registers=(_R.battery_status, ))
-_D('Wireless Illuminated Keyboard K800', protocol=1.0, wpid='2010',
+_D('Wireless Keyboard MK300', codename='MK300', protocol=1.0, wpid='0068', registers=(_R.battery_status, ))
+_D('Number Pad N545', codename='N545', protocol=1.0, wpid='2006', registers=(_R.battery_status, ))
+_D('Wireless Compact Keyboard K340', codename='K340', protocol=1.0, wpid='2007', registers=(_R.battery_status, ))
+_D('Wireless Keyboard MK700', codename='MK700', protocol=1.0, wpid='2008',
+   registers=(_R.battery_status, ), settings=[_ST.RegisterFnSwap])
+_D('Wireless Wave Keyboard K350', codename='K350', protocol=1.0, wpid='200A', registers=(_R.battery_status, ))
+_D('Wireless Keyboard MK320', codename='MK320', protocol=1.0, wpid='200F', registers=(_R.battery_status, ))
+_D('Wireless Illuminated Keyboard K800', codename='K800', protocol=1.0, wpid='2010',
     registers=(_R.battery_status, _R.three_leds), settings=[_ST.RegisterFnSwap, _ST.RegisterHandDetection])
-_D('Wireless Keyboard K520', protocol=1.0, wpid='2011', registers=(_R.battery_status, ), settings=[_ST.RegisterFnSwap])
-_D('Wireless Solar Keyboard K750', protocol=2.0, wpid='4002', settings=[_ST.FnSwap])
-_D('Wireless Keyboard K270 (unifying)', protocol=2.0, wpid='4003')
-_D('Wireless Keyboard K360', protocol=2.0, wpid='4004', settings=[_ST.FnSwap])
-_D('Wireless Keyboard K230', protocol=2.0, wpid='400D')
-_D('Wireless Touch Keyboard K400', protocol=2.0, wpid=('400E', '4024'), settings=[_ST.FnSwap])
-_D('Wireless Keyboard MK270', protocol=2.0, wpid='4023', settings=[_ST.FnSwap])
-_D('Illuminated Living-Room Keyboard K830', protocol=2.0, wpid='4032', settings=[_ST.NewFnSwap])
+_D('Wireless Keyboard K520', codename='K520', protocol=1.0, wpid='2011',
+   registers=(_R.battery_status, ), settings=[_ST.RegisterFnSwap])
+_D('Wireless Solar Keyboard K750', codename='K750', protocol=2.0, wpid='4002', settings=[_ST.FnSwap])
+_D('Wireless Keyboard K270 (unifying)', codename='K270', protocol=2.0, wpid='4003')
+_D('Wireless Keyboard K360', codename='K360', protocol=2.0, wpid='4004', settings=[_ST.FnSwap])
+_D('Wireless Keyboard K230', codename='K230', protocol=2.0, wpid='400D')
+_D('Wireless Touch Keyboard K400', codename='K400', protocol=2.0, wpid=('400E', '4024'), settings=[_ST.FnSwap])
+_D('Wireless Keyboard MK270', codename='MK270', protocol=2.0, wpid='4023', settings=[_ST.FnSwap])
+_D('Illuminated Living-Room Keyboard K830', codename='K830', protocol=2.0, wpid='4032', settings=[_ST.NewFnSwap])
 _D('Wireless Touch Keyboard K400 Plus', codename='K400 Plus', protocol=2.0, wpid='404D')
-_D('Wireless Multi-Device Keyboard K780', protocol=4.5, wpid='405B', settings=[_ST.NewFnSwap])
-_D('Wireless Keyboard K375s', protocol=2.0, wpid='4061', settings=[_ST.K375sFnSwap])
+_D('Wireless Multi-Device Keyboard K780', codename='K780', protocol=4.5, wpid='405B', settings=[_ST.NewFnSwap])
+_D('Wireless Keyboard K375s', codename='K375s', protocol=2.0, wpid='4061', settings=[_ST.K375sFnSwap])
 _D('Craft Advanced Keyboard', codename='Craft', protocol=4.5, wpid='4066', btid=0xB350)
 _D('Wireless Illuminated Keyboard K800 new', codename='K800 new', protocol=4.5, wpid='406E', settings=[_ST.FnSwap])
 _D('Wireless Keyboard K470', codename='K470', protocol=4.5, wpid='4075', settings=[_ST.FnSwap])
@@ -246,30 +242,32 @@ class _PerformanceMXDpi(_ST.RegisterDpi):
    settings=[_PerformanceMXDpi, _ST.RegisterSmoothScroll, _ST.RegisterSideScroll])
 _D('Marathon Mouse M705 (M-R0009)', codename='M705 (M-R0009)', protocol=1.0, wpid='101B',
     registers=(_R.battery_charge, ), settings=[_ST.RegisterSmoothScroll, _ST.RegisterSideScroll])
-_D('Wireless Mouse M350', protocol=1.0, wpid='101C', registers=(_R.battery_charge, ))
+_D('Wireless Mouse M350', codename='M350', protocol=1.0, wpid='101C', registers=(_R.battery_charge, ))
 _D('Wireless Mouse M505', codename='M505/B605', protocol=1.0, wpid='101D',
     registers=(_R.battery_charge, ), settings=[_ST.RegisterSmoothScroll, _ST.RegisterSideScroll])
-_D('Wireless Mouse M305', protocol=1.0, wpid='101F', registers=(_R.battery_status, ), settings=[_ST.RegisterSideScroll])
-_D('Wireless Mouse M215', protocol=1.0, wpid='1020')
+_D('Wireless Mouse M305', codename='M305', protocol=1.0, wpid='101F',
+   registers=(_R.battery_status, ), settings=[_ST.RegisterSideScroll])
+_D('Wireless Mouse M215', codename='M215', protocol=1.0, wpid='1020')
 _D('G700 Gaming Mouse', codename='G700', protocol=1.0, wpid='1023', usbid=0xc06b, interface=1,
     registers=(_R.battery_status, _R.three_leds,), settings=[_ST.RegisterSmoothScroll, _ST.RegisterSideScroll])
-_D('Wireless Mouse M310', protocol=1.0, wpid='1024', registers=(_R.battery_status, ))
-_D('Wireless Mouse M510', protocol=1.0, wpid='1025', registers=(_R.battery_status, ), settings=[_ST.RegisterSideScroll])
+_D('Wireless Mouse M310', codename='M310', protocol=1.0, wpid='1024', registers=(_R.battery_status, ))
+_D('Wireless Mouse M510', codename='M510', protocol=1.0, wpid='1025',
+   registers=(_R.battery_status, ), settings=[_ST.RegisterSideScroll])
 _D('Fujitsu Sonic Mouse', codename='Sonic', protocol=1.0, wpid='1029')
 _D('G700s Gaming Mouse', codename='G700s', protocol=1.0, wpid='102A', usbid=0xc07c, interface=1,
     registers=(_R.battery_status, _R.three_leds,), settings=[_ST.RegisterSmoothScroll, _ST.RegisterSideScroll])
-_D('Couch Mouse M515', protocol=2.0, wpid='4007')
-_D('Wireless Mouse M175', protocol=2.0, wpid='4008')
-_D('Wireless Mouse M325', protocol=2.0, wpid='400A', settings=[_ST.HiResScroll])
-_D('Wireless Mouse M525', protocol=2.0, wpid='4013')
-_D('Wireless Mouse M345', protocol=2.0, wpid='4017')
-_D('Wireless Mouse M187', protocol=2.0, wpid='4019')
-_D('Touch Mouse M600', protocol=2.0, wpid='401A')
-_D('Wireless Mouse M150', protocol=2.0, wpid='4022')
-_D('Wireless Mouse M185', protocol=2.0, wpid='4038')
+_D('Couch Mouse M515', codename='M515', protocol=2.0, wpid='4007')
+_D('Wireless Mouse M175', codename='M175', protocol=2.0, wpid='4008')
+_D('Wireless Mouse M325', codename='M325', protocol=2.0, wpid='400A', settings=[_ST.HiResScroll])
+_D('Wireless Mouse M525', codename='M525', protocol=2.0, wpid='4013')
+_D('Wireless Mouse M345', codename='M345', protocol=2.0, wpid='4017')
+_D('Wireless Mouse M187', codename='M187', protocol=2.0, wpid='4019')
+_D('Touch Mouse M600', codename='M600', protocol=2.0, wpid='401A')
+_D('Wireless Mouse M150', codename='M150', protocol=2.0, wpid='4022')
+_D('Wireless Mouse M185', codename='M185', protocol=2.0, wpid='4038')
 _D('Wireless Mouse MX Master', codename='MX Master', protocol=4.5, wpid='4041', btid=0xb012)
 _D('Anywhere Mouse MX 2', codename='Anywhere MX 2', protocol=4.5, wpid='404A', settings=[_ST.HiresSmoothInvert])
-_D('Wireless Mouse M510', protocol=2.0, wpid='4051', codename='M510v2')
+_D('Wireless Mouse M510', codename='M510v2', protocol=2.0, wpid='4051')
 _D('Wireless Mouse M185 new', codename='M185n', protocol=4.5, wpid='4054')
 _D('Wireless Mouse M185/M235/M310', codename='M185/M235/M310', protocol=4.5, wpid='4055')
 _D('Wireless Mouse MX Master 2S', codename='MX Master 2S', protocol=4.5, wpid='4069', btid=0xb019,
@@ -278,7 +276,7 @@ class _PerformanceMXDpi(_ST.RegisterDpi):
 _D('Marathon Mouse M705 (M-R0073)', codename='M705 (M-R0073)', protocol=4.5, wpid='406D',
     settings=[_ST.HiresSmoothInvert, _ST.PointerSpeed])
 _D('MX Vertical Wireless Mouse', codename='MX Vertical', protocol=4.5, wpid='407B', btid=0xb020, usbid=0xc08a)
-_D('Wireless Mouse Pebble M350', protocol=2.0, wpid='4080', codename='Pebble')
+_D('Wireless Mouse Pebble M350', codename='Pebble', protocol=2.0, wpid='4080')
 _D('MX Master 3 Wireless Mouse', codename='MX Master 3', protocol=4.5, wpid='4082', btid=0xb023)
 _D('PRO X Wireless', kind='mouse', codename='PRO X', wpid='4093', usbid=0xc094)
 
@@ -296,7 +294,7 @@ class _PerformanceMXDpi(_ST.RegisterDpi):
 _D('MX518 Gaming Mouse', codename='MX518', usbid=0xc08e, interface=1)
 _D('G703 Hero Gaming Mouse', codename='G703 Hero', usbid=0xc090)
 _D('G903 Hero Gaming Mouse', codename='G903 Hero', usbid=0xc091)
-_D('G102 Lightsync Mouse', codename='G102', usbid=0xc092, interface=1)
+_D(None, kind=_DK.mouse, usbid=0xc092, interface=1)  # two mice share this ID
 _D('M500S Mouse', codename='M500S', usbid=0xc093, interface=1)
 # _D('G600 Gaming Mouse', codename='G600 Gaming', usbid=0xc24a, interface=1) # not an HID++ device
 _D('G502 Proteus Spectrum Optical Mouse', codename='G502 Proteus Spectrum', usbid=0xc332, interface=1)
@@ -304,12 +302,12 @@ class _PerformanceMXDpi(_ST.RegisterDpi):
 
 # Trackballs
 
-_D('Wireless Trackball M570')
+_D('Wireless Trackball M570', codename='M570')
 
 # Touchpads
 
 _D('Wireless Touchpad', codename='Wireless Touch', protocol=2.0, wpid='4011')
-_D('Wireless Rechargeable Touchpad T650', protocol=2.0, wpid='4101')
+_D('Wireless Rechargeable Touchpad T650', codename='T650', protocol=2.0, wpid='4101')
 
 # Headset
 


Test patch: