Repository: pwr-Solaar/Solaar

Issue:
Logitech, Inc. PRO Gaming Keyboard not recognized
**Information**
<!-- Please update to Solaar from this repository before asking for a new feature. -->
- Solaar version (`solaar --version` and `git describe --tags`): **1.1.5**
- Distribution: **RPM**
- Kernel version (ex. `uname -srmo`): **Linux 5.19.12-200.fc36.x86_64 x86_64 GNU/Linux**
- Output of `solaar show` for the target device (if applicable): **NA**

**Is your feature request related to a problem? Please describe.**
No

**Describe the solution you'd like**
Logitech, Inc. PRO Gaming Keyboard support added




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
@@ -299,6 +299,7 @@ class _PerformanceMXDpi(_ST.RegisterDpi):
 _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)
+_D('Logitech PRO Gaming Keyboard', codename='PRO Gaming Keyboard', usbid=0xc339, interface=1)
 
 # Trackballs
 
diff --git a/lib/logitech_receiver/settings.py b/lib/logitech_receiver/settings.py
--- a/lib/logitech_receiver/settings.py
+++ b/lib/logitech_receiver/settings.py
@@ -420,7 +420,7 @@ def write(self, map, save=True):
                         return None
             return map
 
-    def write_key_value(self, key, value):
+    def write_key_value(self, key, value, save=True):
         assert hasattr(self, '_value')
         assert hasattr(self, '_device')
         assert key is not None
@@ -436,7 +436,7 @@ def write_key_value(self, key, value):
                 data_bytes = self._validator.prepare_write(int(key), value)
                 # always need to write to configuration because dictionary is shared and could have changed
                 self._value[int(key)] = value
-                self._pre_write()
+                self._pre_write(save)
             except ValueError:
                 data_bytes = value = None
             if data_bytes is not None:
@@ -521,7 +521,7 @@ def write(self, map, save=True):
                                 return None
             return map
 
-    def write_key_value(self, item, value):
+    def write_key_value(self, item, value, save=True):
         assert hasattr(self, '_value')
         assert hasattr(self, '_device')
         assert item is not None
@@ -535,7 +535,7 @@ def write_key_value(self, item, value):
                 self.read()
             data_bytes = self._validator.prepare_write_item(item, value)
             self._value[int(item)] = value
-            self._pre_write()
+            self._pre_write(save)
             if data_bytes is not None:
                 if _log.isEnabledFor(_DEBUG):
                     _log.debug('%s: settings prepare item value write(%s,%s) => %r', self.name, item, value, data_bytes)
@@ -619,7 +619,7 @@ def write(self, map, save=True):
                         return None
             return map
 
-    def write_key_value(self, key, value):
+    def write_key_value(self, key, value, save=True):
         assert hasattr(self, '_value')
         assert hasattr(self, '_device')
         assert key is not None
@@ -633,7 +633,7 @@ def write_key_value(self, key, value):
                 self.read()
             value = bool(value)
             self._value[int(key)] = value
-            self._pre_write()
+            self._pre_write(save)
 
             data_bytes = self._validator.prepare_write(self._value)
             if data_bytes is not None:
@@ -710,7 +710,7 @@ def write(self, map, save=True):
                 _log.warn('%s: range field setting no data to write', self.name)
             return map
 
-    def write_key_value(self, key, value):
+    def write_key_value(self, key, value, save=True):
         assert key is not None
         assert value is not None
         if _log.isEnabledFor(_DEBUG):
@@ -720,7 +720,7 @@ def write_key_value(self, key, value):
                 self.read()
             map = self._value
             map[int(key)] = value
-            self.write(map)
+            self.write(map, save)
             return value
 
 
diff --git a/lib/solaar/configuration.py b/lib/solaar/configuration.py
--- a/lib/solaar/configuration.py
+++ b/lib/solaar/configuration.py
@@ -140,12 +140,14 @@ def _cleanup_load(c):
             if divert:
                 sliding = element.get('dpi-sliding')
                 if sliding:  # convert old-style dpi-sliding setting to divert-keys entry
-                    divert[sliding] = 3
-                    element.pop('dpi-sliding')
+                    divert[int(sliding)] = 3
+                element.pop('dpi-sliding', None)
                 gestures = element.get('mouse-gestures')
                 if gestures:  # convert old-style mouse-gestures setting to divert-keys entry
-                    divert[gestures] = 2
-                    element.pop('mouse-gestures')
+                    divert[int(gestures)] = 2
+                element.pop('mouse-gestures', None)
+                # remove any string entries (from bad conversions)
+                element['divert-keys'] = {k: v for k, v in divert.items() if isinstance(k, int)}
             # convert to device entries
             element = _DeviceEntry(**element)
             _config.append(element)


Test patch: