pwr-Solaar / Solaar

Linux device manager for Logitech devices
https://pwr-solaar.github.io/Solaar
GNU General Public License v2.0
5.54k stars 409 forks source link

Cannot see the G815 keyboard in the Solaar window #1457

Closed gregopet closed 2 years ago

gregopet commented 2 years ago

Information

``` solaar: error: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/solaar/cli/__init__.py", line 200, in run raise Exception('No devices found') Exception: No devices found ```

Describe the bug

I have a G815 keyboard connected via USB cable and I would like to reprogram the macro keys. Solaar doesn't recognize the keyboard. lsusb returns it as Bus 002 Device 023: ID 046d:c33f Logitech, Inc. G815 Mechanical Keyboard

pfps commented 2 years ago

Solaar can only handle devices that use the Logitech HID++ protocol. It looks as if the G815 might use this protocol. To find out:

Look at output of lsusb to find ID of device or receiver. (You have done this.) Provide output of lsusb -vv -d xxxx:yyyy where xxxx:yyyy is ID of device or receiver. (046d:c33f for you.)

Look at output of grep -H . /sys/class/hidraw/hidraw*/device/uevent to find directory for the device or receiver, e.g., /sys/class/hidraw/hidraw3/device/uevent:HID_NAME=Logitech USB Receiver. Provide contents of the file /sys/class/hidraw/hidrawN/device/report_descriptor where N was found above. You will have to copy the contents to a file with txt extension before attaching it. Or, better, install hidrd-convert and provide output of hidrd-convert -o spec /sys/class/hidraw/hidrawN/device/report_descriptor.

gregopet commented 2 years ago

Hi,

First of all, thank you for your work :+1:

Output of lsusb -vv -d:

``` Bus 002 Device 023: ID 046d:c33f Logitech, Inc. G815 Mechanical Keyboard Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x046d Logitech, Inc. idProduct 0xc33f G815 Mechanical Keyboard bcdDevice 31.02 iManufacturer 1 Logitech iProduct 2 G815 RGB MECHANICAL GAMING KEYBOARD iSerial 3 087E303E3836 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x003b bNumInterfaces 2 bConfigurationValue 1 iConfiguration 4 U131.02_B0018 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 500mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 1 Keyboard iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.11 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 65 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 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 188 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered) ```

It's interesting that the keyboard registers itself at two hidraw folders, possibly because the keyboard comes with two USB cables (presumably for its USB hub function?). Here's the output of both:

hidrd-convert -o spec /sys/class/hidraw/hidraw0/device/report_descriptor:

Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Keyboard),                   ; Keyboard (06h, application collection)
Collection (Application),
    Usage Page (Keyboard),          ; Keyboard/keypad (07h)
    Usage Minimum (KB Leftcontrol), ; Keyboard left control (E0h, dynamic value)
    Usage Maximum (KB Right GUI),   ; Keyboard right GUI (E7h, dynamic value)
    Logical Minimum (0),
    Logical Maximum (1),
    Report Size (1),
    Report Count (8),
    Input (Variable),
    Report Count (1),
    Report Size (8),
    Input (Constant),
    Report Count (3),
    Report Size (1),
    Usage Page (LED),               ; LEDs (08h)
    Usage Minimum (01h),
    Usage Maximum (03h),
    Output (Variable),
    Report Count (5),
    Report Size (1),
    Output (Constant),
    Report Count (6),
    Report Size (8),
    Logical Minimum (0),
    Logical Maximum (255),
    Usage Page (Keyboard),          ; Keyboard/keypad (07h)
    Usage Minimum (None),           ; No event (00h, selector)
    Usage Maximum (FFh),
    Input,
End Collection

hidrd-convert -o spec /sys/class/hidraw/hidraw1/device/report_descriptor:

Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Keyboard),                   ; Keyboard (06h, application collection)
Collection (Application),
    Usage Page (Keyboard),          ; Keyboard/keypad (07h)
    Usage Minimum (None),           ; No event (00h, selector)
    Usage Maximum (KB Right GUI),   ; Keyboard right GUI (E7h, dynamic value)
    Logical Minimum (0),
    Logical Maximum (231),
    Report Size (8),
    Report Count (20),
    Report ID (1),
    Input,
End Collection,
Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Mouse),                      ; Mouse (02h, application collection)
Collection (Application),
    Report ID (2),
    Usage (Pointer),                ; Pointer (01h, physical collection)
    Collection (Physical),
        Usage Page (Button),        ; Button (09h)
        Usage Minimum (01h),
        Usage Maximum (10h),
        Logical Minimum (0),
        Logical Maximum (1),
        Report Count (16),
        Report Size (1),
        Input (Variable),
        Usage Page (Desktop),       ; Generic desktop controls (01h)
        Logical Minimum (-32767),
        Logical Maximum (32767),
        Report Size (16),
        Report Count (2),
        Usage (X),                  ; X (30h, dynamic value)
        Usage (Y),                  ; Y (31h, dynamic value)
        Input (Variable, Relative),
        Logical Minimum (-127),
        Logical Maximum (127),
        Report Size (8),
        Report Count (1),
        Usage (Wheel),              ; Wheel (38h, dynamic value)
        Input (Variable, Relative),
        Usage Page (Consumer),      ; Consumer (0Ch)
        Usage (AC Pan),             ; AC pan (0238h, linear control)
        Report Count (1),
        Input (Variable, Relative),
    End Collection,
End Collection,
Usage Page (Consumer),              ; Consumer (0Ch)
Usage (Consumer Control),           ; Consumer control (01h, application collection)
Collection (Application),
    Report ID (3),
    Logical Minimum (0),
    Logical Maximum (1),
    Report Size (1),
    Report Count (7),
    Usage (Scan Next Track),        ; Scan next track (B5h, one-shot control)
    Usage (Scan Previous Track),    ; Scan previous track (B6h, one-shot control)
    Usage (Stop),                   ; Stop (B7h, one-shot control)
    Usage (Play Pause),             ; Play/pause (CDh, one-shot control)
    Usage (Volume Inc),             ; Volume increment (E9h, re-trigger control)
    Usage (Volume Dec),             ; Volume decrement (EAh, re-trigger control)
    Usage (Mute),                   ; Mute (E2h, on/off control)
    Input (Variable),
    Report Count (1),
    Input (Constant),
End Collection,
Usage Page (FF43h),                 ; FF43h, vendor-defined
Usage (0602h),
Collection (Application),
    Report ID (17),
    Report Size (8),
    Report Count (19),
    Logical Minimum (0),
    Logical Maximum (255),
    Usage (02h),
    Input,
    Usage (02h),
    Output,
End Collection,
Usage Page (FF43h),                 ; FF43h, vendor-defined
Usage (0604h),
Collection (Application),
    Report ID (18),
    Report Size (8),
    Report Count (63),
    Logical Minimum (0),
    Logical Maximum (255),
    Usage (04h),
    Input,
    Usage (04h),
    Output,
End Collection
gregopet commented 2 years ago

I tried disconnecting one of the USB cables and the keyboard still works, but two hidraw entries remain.

pfps commented 2 years ago

It looks as if this device uses a different interface number than Solaar expects by default. The fix is quite simple though.

gregopet commented 2 years ago

Anything I can help test? I'm a developer, though with very limited Python experience, but I can give it a go perhaps?

pfps commented 2 years ago

PR #1459 should add the G815 to Solaar. However Solaar doesn't do macros the same way that Logitech software does. You will probably have to write Solaar rules for the macro keys that simulate keypresses and divert the keys so that they trigger the rules.

To clone and use Solar from its GitHub repository

git clone https://github.com/pwr-Solaar/Solaar.git
cd Solaar

Run Solaar as bin/solaar from this directory.

To run PR #1459, first clone Solaar if you have not already done so and cd to the clone directory. The first time you download the pull request, fetch it into a new branch and checkout that branch, as in:

git fetch origin pull/1459/head:pull_1459
git checkout pull_1459

To download a new version of the pull request, fetch it and then set your pull branch to the new fetch, as in:

git checkout pull_1459
git fetch origin pull/1459/head
git reset --hard FETCH_HEAD
gregopet commented 2 years ago

Thank you, that worked!

If I run bin/solaar show I now get the following output:

Solaar version 1.1.1

USB and Bluetooth Devices

  1: G815 Mechanical Keyboard
     Device path  : /dev/hidraw1
     USB id       : 046d:C33F
     Codename     : G815
     Kind         : keyboard
     Protocol     : HID++ 4.2
     Polling rate : 1 ms (1000Hz)
     Serial number: 
     Model ID:      C33F00000000
     Unit ID:       34304708
        Bootloader: BOT 84.00.B0003
          Firmware: U1  31.02.B0018
             Other: 
             Other: 
             Other: 
     Supports 24 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
            Firmware: Bootloader BOT 84.00.B0003 AAEA
            Firmware: Firmware U1  31.02.B0018 C33F
            Firmware: Other   
            Firmware: Other   
            Firmware: Other   
            Unit ID: 34304708  Model ID: C33F00000000  Transport IDs: {'usbid': 'C33F'}
         3: DEVICE NAME            {0005}   
            Name: G815 RGB MECHANICAL GAMING KEYBOARD
            Kind: keyboard
         4: RESET                  {0020}   
         5: DFUCONTROL SIGNED      {00C2}   
         6: DFU                    {00D0}   
         7: REPORT HID USAGE       {1BC0}   
         8: KEYBOARD DISABLE BY USAGE {4522}   
         9: KEYBOARD LAYOUT 2      {4540}   
        10: GKEY                   {8010}   
            Divert G Keys        : False
        11: MKEYS                  {8020}   
        12: MR                     {8030}   
        13: BRIGHTNESS CONTROL     {8040}   
        14: REPORT RATE            {8060}   
            Polling Rate (ms): 1
            Polling Rate (ms)        : 1
        15: RGB EFFECTS            {8071}   
        16: PER KEY LIGHTING V2    {8081}   
        17: ONBOARD PROFILES       {8100}   
            Device Mode: On-Board
        18: unknown:1801           {1801}   internal, hidden
        19: DEVICE RESET           {1802}   internal, hidden
        20: CONFIG DEVICE PROPS    {1806}   internal, hidden
        21: unknown:18B0           {18B0}   internal, hidden
        22: unknown:1E00           {1E00}   hidden
        23: unknown:1EB0           {1EB0}   internal, hidden
     Battery status unavailable.

I will try to set macros tomorrow because the keyboard stayed at work (I tested the PR remotely) :smile:

pfps commented 2 years ago

I see that your keyboard has G, M, and MR keys. A very recent change to Solaar now supports the notifications that M and MR keys produce.

Diverting the G keys may have effects on how the M and MR keys work.

gregopet commented 2 years ago

I could play with the physical keyboard now, I indeed need to divert G keys to receive any events. Those work now, but the M1 through M3 do not. I get python exceptions from Solaar when they are pressed and I would like to report these issues - do I open an issue naming G815 directly, G-keyboards as a group, or M-keys generally, or is this feature still in development and I should wait (you said it was a recent change)?

pfps commented 2 years ago

Please report as a bug. Open a new bug issue with title something like diverting G keys causes Python exceptions.