Repository: pwr-Solaar/Solaar

Issue:
Support G195 keyboard in wireless mode
**Information**
<!-- The version of Solaar in this repository has more features than released vesions.  Update to this version before asking for a new feature. -->
- **Solaar version :** 1.1.10
- **Distribution :** Archlinux
- **Kernel version :** Linux 6.6.7-arch1-1 x86_64 GNU/Linux
- `solaar show` outputs

<details>
```
solaar: error: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/solaar/cli/__init__.py", line 206, in run
    raise Exception(
Exception: No supported device found.  Use "lsusb" and "bluetoothctl devices Connected" to list connected devices.
```
</details>

**Is your feature request related to a problem? Please describe.**
I would like to use solaar with my G195 keyboard. It is not the TKL version, but the "LIGHTSPEED Wireless RGB". Solaar recognizes it when connected with its micro-USB cable, but not when it is connection with its wireless dongle.

**Describe the solution you'd like**
To be able to configure the keyboard and have information on its battery level.

**Describe alternatives you've considered**
None

**Additional context**
According to the documentation process, here are the hidraw files. Oddly, they have two of them with the same signature, but in the descriptor files, we can the first one is considered as a mouse and the second one as a keyboard. I do not have a Logitech mouse but a Roccat one which already have its own hidraw path. You will also find the lsusb output.

[input0.txt](https://github.com/pwr-Solaar/Solaar/files/13743371/input0.txt)
[input0_descriptor.txt](https://github.com/pwr-Solaar/Solaar/files/13743370/input0_descriptor.txt)
[input1.txt](https://github.com/pwr-Solaar/Solaar/files/13743373/input1.txt)
[input1_descriptor.txt](https://github.com/pwr-Solaar/Solaar/files/13743372/input1_descriptor.txt)
[usb.txt](https://github.com/pwr-Solaar/Solaar/files/13743375/usb.txt)




Discussion:
Please provide output of `solaar show` when then keyboard is connected via USB.
Here it is : [show.txt](https://github.com/pwr-Solaar/Solaar/files/13744025/show.txt)

I'm not sure that the descriptor files correspond to the keyboard.  

Can you start up the Solaar GUI as `solaar -ddd` with the receiver unplugged.  Then pug in the receiver and connect the keyboard to it.   Post the output from Solaar.

As far as I can tell Solaar has had support for this receiver since mid-2021.
Here is is : [debug.txt](https://github.com/pwr-Solaar/Solaar/files/13746188/debug.txt)

When I plugged the receiver while solaar was up, it recognized it as "Lightspeed receiver". It never happened before.


Resolving patch:
diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py
--- a/lib/solaar/listener.py
+++ b/lib/solaar/listener.py
@@ -154,16 +154,20 @@ def has_stopped(self):
     def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None):
         assert device is not None
         if _log.isEnabledFor(_INFO):
-            if device.kind is None:
-                _log.info(
-                    'status_changed %r: %s, %s (%X) %s', device, 'present' if bool(device) else 'removed', device.status,
-                    alert, reason or ''
-                )
-            else:
-                _log.info(
-                    'status_changed %r: %s %s, %s (%X) %s', device, 'paired' if bool(device) else 'unpaired',
-                    'online' if device.online else 'offline', device.status, alert, reason or ''
-                )
+            try:
+                device.ping()
+                if device.kind is None:
+                    _log.info(
+                        'status_changed %r: %s, %s (%X) %s', device, 'present' if bool(device) else 'removed', device.status,
+                        alert, reason or ''
+                    )
+                else:
+                    _log.info(
+                        'status_changed %r: %s %s, %s (%X) %s', device, 'paired' if bool(device) else 'unpaired',
+                        'online' if device.online else 'offline', device.status, alert, reason or ''
+                    )
+            except Exception:
+                _log.info('status_changed for unknown device')
 
         if device.kind is None:
             assert device == self.receiver
@@ -253,7 +257,11 @@ def _notifications_handler(self, n):
         # Apply settings every time the device connects
         if n.sub_id == 0x41:
             if _log.isEnabledFor(_INFO):
-                _log.info('connection %s for %r', n, dev)
+                try:
+                    dev.ping()
+                    _log.info('connection %s for %r', n, dev)
+                except Exception:
+                    _log.info('connection %s for unknown device, number %s', n, n.devnumber)
             # If there are saved configs, bring the device's settings up-to-date.
             # They will be applied when the device is marked as online.
             configuration.attach_to(dev)


Test patch: