Repository: pwr-Solaar/Solaar

Issue:
Logitech G535 support
**Information**
- Solaar version: 1.1.8
- Distribution: Ubuntu 22.04

The Logitech G535, a wireless Lightspeed 2,4Ghz headset, and it's usb receiver don't seem to be supported yet.

```
$ lsusb
Bus 001 Device 005: ID 046d:0ac4 Logitech, Inc. G535 Wireless Gaming Headset
```

```
$ sudo solaar -ddd
2022-12-31 13:55:52,798,798     INFO [MainThread] root: language de_DE (UTF-8), translations path None
2022-12-31 13:55:52,889,889     INFO [MainThread] logitech_receiver.diversion: GDK Keymap set up
2022-12-31 13:55:52,896,896    DEBUG [MainThread] solaar.ui.tray: using Ayatana AppIndicator3
2022-12-31 13:55:52,900,900     INFO [MainThread] solaar.upower: connected to system dbus, watching for suspend/resume events
2022-12-31 13:55:52,924,924    DEBUG [MainThread] solaar.ui: startup registered=True, remote=False
2022-12-31 13:55:52,924,924    DEBUG [AsyncUI] solaar.tasks: started
2022-12-31 13:55:52,925,925     INFO [MainThread] solaar.ui.notify: starting desktop notifications
2022-12-31 13:55:52,926,926    DEBUG [MainThread] solaar.ui.icons: sys.path[0] = /usr/share/solaar/lib
2022-12-31 13:55:52,926,926    DEBUG [MainThread] solaar.ui.icons: looking for icons in /usr/share/solaar/icons
2022-12-31 13:55:52,926,926    DEBUG [MainThread] solaar.ui.icons: icon theme paths: ['/usr/share/solaar/icons', '/root/.local/share/icons', '/root/.icons', '/usr/local/share/icons', '/usr/share/icons', '/usr/local/share/pixmaps', '/usr/share/pixmaps']
2022-12-31 13:55:52,953,953     INFO [MainThread] solaar.listener: starting receiver listening threads
2022-12-31 13:55:53,055,055  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 00000D8C PID 0000013C: Expecting 3 usages but got 1
2022-12-31 13:55:53,056,056     INFO [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 00000AC4 HID++ False True USB 3 None
2022-12-31 13:55:53,056,056     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw0', bus_id=3, vendor_id='046D', product_id='0AC4', interface=3, driver='hid-generic', manufacturer=None, product=None, serial='', release=None, isDevice=True, hidpp_short=False, hidpp_long=True)
2022-12-31 13:55:53,056,056    DEBUG [MainThread] logitech_receiver.base: (13) pinging device 255
2022-12-31 13:55:53,057,057     INFO [MainThread] logitech_receiver.base: New lock 13
2022-12-31 13:55:53,057,057    DEBUG [MainThread] logitech_receiver.base: (13) <= w[10 FF 001F 00005D]
2022-12-31 13:55:53,360,360    ERROR [MainThread] logitech_receiver.base: write failed, assuming handle 13 no longer available
2022-12-31 13:55:53,360,360    DEBUG [MainThread] solaar.ui: activate
2022-12-31 13:55:53,367,367    ERROR [MainThread] solaar.ui: error: nodevice /dev/hidraw0
```


```
$ cat /sys/class/hidraw/hidraw0/device/uevent
DRIVER=hid-generic
HID_ID=0003:0000046D:00000AC4
HID_NAME=Logitech G535 Wireless Gaming Headset
HID_PHYS=usb-0000:03:00.0-3/input3
HID_UNIQ=
MODALIAS=hid:b0003g0001v0000046Dp00000AC4
```

```
$ cat /sys/class/hidraw/hidraw0/device/report_descriptor | base64
BQwJAaEBhQEJ6QnqdQGVAhUAJQGBAnUGlQGBA3UYgQPABkP/CgICoQGFEZUTdQgm/wAJAoEACQKR
AMA=
```


<details><summary>$ sudo lsusb -vv -d 046d:0ac4</summary>

```
Bus 001 Device 007: ID 046d:0ac4 Logitech, Inc. G535 Wireless Gaming Headset
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x046d Logitech, Inc.
  idProduct          0x0ac4 
  bcdDevice            9.00
  iManufacturer           1 Logitech
  iProduct                2 G535 Wireless Gaming Headset
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x012e
    bNumInterfaces          6
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       1 Control Device
      bFunctionProtocol       0 
      iFunction               2 G535 Wireless Gaming Headset
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0048
        bInCollection           2
        baInterfaceNr(0)        1
        baInterfaceNr(1)        2
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0402 Headset
        bAssocTerminal          6
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 2
        bSourceID               1
        bControlSize            1
        bmaControls(0)       0x02
          Volume Control
        bmaControls(1)       0x00
        bmaControls(2)       0x00
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             4
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 5
        bSourceID               4
        bControlSize            1
        bmaControls(0)       0x03
          Mute Control
          Volume Control
        bmaControls(1)       0x00
        bmaControls(2)       0x00
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             6
        wTerminalType      0x0402 Headset
        bAssocTerminal          1
        bSourceID               5
        iTerminal               0 
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               8
        bRefresh                0
        bSynchAddress           0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           3
        bDelay                  0 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             1
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            1 Discrete
        tSamFreq[ 0]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes           13
          Transfer Type            Isochronous
          Synch Type               Synchronous
          Usage Type               Data
        wMaxPacketSize     0x0062  1x 98 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           4
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           3
        bBitResolution         24
        bSamFreqType            1 Discrete
        tSamFreq[ 0]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes           13
          Transfer Type            Isochronous
          Synch Type               Synchronous
          Usage Type               Data
        wMaxPacketSize     0x0120  1x 288 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      59
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              16
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         4
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       0 
      iFunction               3 USB VCOM
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      0 
      iInterface              0 
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x06
          sends break
          line coding and serial state
      CDC Union:
        bMasterInterface        4
        bSlaveInterface         5 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        5
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
```

</details>


Discussion:
Somehow the write to /dev/hidraw0 failed.  Please provide output of `ls -l /dev/hidraw*`


```
crw-rw----+ 1 root root 237, 2 Dez 31 13:59 /dev/hidraw2
crw-------  1 root root 237, 3 Dez 31 13:59 /dev/hidraw3
crw-rw----+ 1 root root 237, 4 Dez 31 13:59 /dev/hidraw4
crw-rw----+ 1 root root 237, 5 Dez 31 13:59 /dev/hidraw5
```
(After a restart it's now /dev/hidraw2)
That looks OK.  It might be that the device needs a slightly different message to ping it.

Resolving patch:
diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py
--- a/lib/logitech_receiver/device.py
+++ b/lib/logitech_receiver/device.py
@@ -442,7 +442,7 @@ def feature_request(self, feature, function=0x00, *params, no_reply=False):
 
     def ping(self):
         """Checks if the device is online, returns True of False"""
-        long = self.bluetooth or self._protocol is not None and self._protocol >= 2.0
+        long = self.bluetooth or self.hidpp_short is False or self._protocol is not None and self._protocol >= 2.0
         protocol = _base.ping(self.handle or self.receiver.handle, self.number, long_message=long)
         self.online = protocol is not None
         if protocol:


Test patch: