pwr-Solaar / Solaar

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

G102 LIGHTSYNC mouse support? #1225

Closed oxalica closed 3 years ago

oxalica commented 3 years ago

Information

Is your feature request related to a problem? Please describe.

I'm using Logitech G102 LIGHTSYNC wired mouse. I want to adjust DPI of it on Linux, and found this project.

I tried solaar show but it said it cannot find devices. When I plugged the mouse, there are two devices /dev/hidraw5 and /dev/hidraw6. Then I tried solaar -D /dev/hidraw5 show (or hidraw6) but still show the same result. I also tried my M590 (which is using bluetooth), and solaar is working well.

Is G102 not supported yet, or is there some issue handling it? is there anything I can do to help supporting it?

pfps commented 3 years ago

It looks as if this is a USB-connected mouse. Please provide the output of lsusb to see the USB identifiers of the mouse. Also provide the output of ls -l /dev/hidraw* when your M590 is not connected to see if the device permissions are being correctly set.

It may be that the mouse does not provide a HID++ interface. If that is the case Solaar will not support the mouse. Please provide the output of solaar -dd to see whether the mouse is detected at all.

oxalica commented 3 years ago

It looks as if this is a USB-connected mouse.

Yes.

Please provide the output of lsusb to see the USB identifiers of the mouse.

Bus 001 Device 007: ID 046d:c092 Logitech, Inc. G102 LIGHTSYNC Gaming Mouse

Also provide the output of ls -l /dev/hidraw* when your M590 is not connected to see if the device permissions are being correctly set.

I have udev rules installed and re-plugged the mouse. The permission is correct. I (user oxa) do have access to device files. The hidraw5 and hidraw6 are provided by the mouse, checked by diff devices before and after plugging.

> ls -l /dev/hidraw*
crw-------  249,0 root 10 Aug 04:12 /dev/hidraw0
crw-------  249,1 root 10 Aug 04:12 /dev/hidraw1
crw-------  249,2 root 10 Aug 04:12 /dev/hidraw2
crw-------  249,3 root 10 Aug 06:20 /dev/hidraw3
crw-rw----@ 249,5 root 10 Aug 05:26 /dev/hidraw5
crw-rw----@ 249,6 root 10 Aug 05:26 /dev/hidraw6

> getfacl /dev/hidraw{5,6}
getfacl: Removing leading '/' from absolute path names
# file: dev/hidraw5
# owner: root
# group: root
user::rw-
user:oxa:rw-
group::---
mask::rw-
other::---

# file: dev/hidraw6
# owner: root
# group: root
user::rw-
user:oxa:rw-
group::---
mask::rw-
other::---

It may be that the mouse does not provide a HID++ interface.

Is there any way to verify if it support that interface?

Please provide the output of solaar -dd to see whether the mouse is detected at all.

Seems not. Same results for solaar -dd -D /dev/hidraw5 show or hidraw6.

> solaar -dd show
07:32:45,895    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
solaar: error: Traceback (most recent call last):
  File "/nix/store/r9brgyp5q586i9wb4hn9a9ryk9yza53h-solaar-1.0.6/lib/python3.9/site-packages/solaar/cli/__init__.py", line 203, in run
    raise Exception('No devices found')
Exception: No devices found
pfps commented 3 years ago

Is this a new Logitech device? If so, it is possible that your distribution is not setting it up correctly. Or that the device does not talk HID++. I added some logging to the part of Solaar that looks for devices. Please clone and run PR #1226 and provide output for bin/solaar -dd show, preferably when your other mouse is not connected.

To download and work with Solar

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

Run Solaar as bin/solaar from this directory.

To run PR #1226, 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/1226/head:pull_1226
git checkout pull_1226

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_1226
git fetch origin pull/1226/head
git reset --hard FETCH_HEAD
oxalica commented 3 years ago

Is this a new Logitech device?

Wiki says G102 LIGHTSYNC is released in 2020.

I tried your PR and here's the output:

> ./result/bin/solaar -dd show
08:58:59,870    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Down"
08:58:59,871    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Up"
08:58:59,877    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
08:58:59,911    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 0 FILTER 2
08:58:59,912    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 1 FILTER 2
solaar: error: Traceback (most recent call last):
  File "/nix/store/k9mjy2ppg26wls2ca5qkjzqmp2wyvbwh-solaar-dev/lib/python3.9/site-packages/solaar/cli/__init__.py", line 203, in run
    raise Exception('No devices found')
Exception: No devices found
pfps commented 3 years ago

Most modern Logitech USB mice have three USB interfaces (0,1,2) but there are only two here. To see what the situation is you should do lsusb to find out where the mouse is connected and then lsusb -vv -s <bus>:<device> where <bus> and <device> are the bus and device for the mouse. Look for the bNumInterfaces line. If it is 3 then the mouse is not being fully set up by your OS. If it is 2 then either the mouse has a old HID++ interface or doesn't have HID++ at all. You can try to add information about the mouse to lib/logitech_receiver/descriptors.py Try adding something like

_D('G102 Lightsync Mouse, codename='G102', protocol=1.0, usbid=0xc092, interface=1)

after the description of the G700S. You can then try to add registers and settings information.

Alternatively, if the mouse can also connect via a wireless receiver, you could try using the receiver.

oxalica commented 3 years ago

bNumInterfaces reports 2.

> lsusb -vv -s 001:008 ``` Bus 001 Device 008: ID 046d:c092 Logitech, Inc. G102 LIGHTSYNC Gaming Mouse Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x046d Logitech, Inc. idProduct 0xc092 bcdDevice 52.00 iManufacturer 1 Logitech iProduct 2 G102 LIGHTSYNC Gaming Mouse iSerial 3 205C346B5442 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x003b bNumInterfaces 2 bConfigurationValue 1 iConfiguration 4 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 300mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 2 Mouse iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.11 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 67 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 151 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 0x0014 1x 20 bytes bInterval 1 ```

After adding an entry to descriptors.py,

> ./bin/solaar -dd show
16:20:03,161    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Down"
16:20:03,162    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Up"
16:20:03,167    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
16:20:03,199    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 0 FILTER 1
16:20:03,199    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 1 FILTER 1
16:20:03,200    DEBUG [MainThread] solaar.cli: [/dev/hidraw5] => <Device(0,C092,G102 Lightsync Mouse,?)>
Wired Devices
16:20:03,202    DEBUG [MainThread] logitech_receiver.base: (10) pinging device 0
16:20:03,202     INFO [MainThread] logitech_receiver.base: New lock 10
16:20:03,202    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 00 001E 000009]
16:20:03,206    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 00 FF00 1E0A0000000000000000000000000000]
16:20:11,208  WARNING [MainThread] logitech_receiver.base: (10) timeout (8.00/8.00) on device 0 ping
  1: G102 Lightsync Mouse
     Device path  : /dev/hidraw5
     USB id       : 046d:C092
     Codename     : G102
     Kind         : mouse
     Protocol     : HID++ 1.0
     Serial number: ?
     Battery: unknown (device is offline).

I try to add settings=[_RS.dpi(choices=_PERFORMANCE_MX_DPIS)] (not sure this is correct for G102) and open GUI with ./bin/solaar -dd. it do shows the device but the DPI input box is disabled with hover text read/write operation failed.

Partial debug log ``` 16:37:41,433 INFO [MainThread] solaar.listener: starting receiver listening threads 16:37:41,443 DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 0 FILTER 1 16:37:41,444 DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 1 FILTER 1 16:37:41,445 INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw5', vendor_id='046D', product_id='C092', serial='205C346B5442', release=None, manufacturer=None, product=None, interface=1, driver='hid-generic', bus_id=3, isDevice=True) 16:37:41,445 DEBUG [MainThread] solaar.configuration: load => {'None:?': {'_name': 'G102 Lightsync Mouse', '_sensitive': {'dpi': True}}, '_version': '1.0.6'} 16:37:41,445 INFO [MainThread] solaar.configuration: saved {'None:?': {'_name': 'G102 Lightsync Mouse', '_sensitive': {'dpi': True}}, '_version': '1.0.6'} to /home/oxa/.config/solaar/config.json 16:37:41,446 INFO [MainThread] logitech_receiver.status: pushing device settings [] 16:37:41,446 DEBUG [MainThread] logitech_receiver.settings: dpi: apply None () 16:37:41,446 DEBUG [MainThread] logitech_receiver.settings: dpi: settings read None from 16:37:41,446 INFO [MainThread] logitech_receiver.base: New lock 17 16:37:41,446 DEBUG [MainThread] logitech_receiver.base: (17) <= w[10 00 8163 000000] 16:37:41,449 DEBUG [MainThread] logitech_receiver.base: (17) => r[10 00 8F81 630100] 16:37:41,449 DEBUG [MainThread] logitech_receiver.base: (17) device 0x00 error on request {8163}: 1 = invalid SubID/command 16:37:41,450 INFO [MainThread] solaar.configuration: saved {'None:?': {'_name': 'G102 Lightsync Mouse'}, '_version': '1.0.6'} to /home/oxa/.config/solaar/config.json 16:37:41,450 DEBUG [MainThread] logitech_receiver.base: (17) <= w[10 00 810D 000000] 16:37:41,453 DEBUG [MainThread] logitech_receiver.base: (17) => r[10 00 8F81 0D0100] 16:37:41,453 DEBUG [MainThread] logitech_receiver.base: (17) device 0x00 error on request {810D}: 1 = invalid SubID/command 16:37:41,453 DEBUG [MainThread] logitech_receiver.base: (17) <= w[10 00 8107 000000] 16:37:41,457 DEBUG [MainThread] logitech_receiver.base: (17) => r[10 00 8F81 070100] 16:37:41,457 DEBUG [MainThread] logitech_receiver.base: (17) device 0x00 error on request {8107}: 1 = invalid SubID/command 16:37:41,457 INFO [MainThread] solaar.listener: status_changed : paired online, {'NOTIFICATION FLAGS': False} (0) 16:37:41,458 INFO [ReceiverListener:hidraw5] logitech_receiver.listener: started with (17) 16:37:41,458 INFO [ReceiverListener:hidraw5] solaar.listener: : notifications listener has started (17) 16:37:41,458 INFO [ReceiverListener:hidraw5] solaar.listener: status_changed : paired online, {'NOTIFICATION FLAGS': False} (0) 16:37:41,459 DEBUG [MainThread] solaar.ui: activate 16:37:41,474 DEBUG [MainThread] solaar.ui: status changed: (NONE) None 16:37:41,475 WARNING [MainThread] solaar.ui.icons: icon battery-missing not found in current theme 16:37:41,476 DEBUG [MainThread] solaar.ui.tray: picked device with lowest battery: None 16:37:41,478 DEBUG [MainThread] solaar.ui.window: new device row ('/dev/hidraw5', 0, True, 'G102', None, None, None, ) at index 0 16:37:41,479 INFO [MainThread] logitech_receiver.base: New lock 18 16:37:41,479 DEBUG [MainThread] logitech_receiver.base: (18) <= w[10 00 810D 000000] 16:37:41,482 DEBUG [ReceiverListener:hidraw5] logitech_receiver.base: (17) => r[10 00 8F81 0D0100] 16:37:41,482 DEBUG [MainThread] logitech_receiver.base: (18) => r[10 00 8F81 0D0100] 16:37:41,482 DEBUG [MainThread] logitech_receiver.base: (18) device 0x00 error on request {810D}: 1 = invalid SubID/command 16:37:41,482 DEBUG [MainThread] logitech_receiver.base: (18) <= w[10 00 8107 000000] 16:37:41,486 DEBUG [ReceiverListener:hidraw5] logitech_receiver.base: (17) => r[10 00 8F81 070100] 16:37:41,486 DEBUG [MainThread] logitech_receiver.base: (18) => r[10 00 8F81 070100] 16:37:41,486 DEBUG [MainThread] logitech_receiver.base: (18) device 0x00 error on request {8107}: 1 = invalid SubID/command 16:37:41,486 WARNING [MainThread] solaar.ui.icons: icon battery-missing not found in current theme 16:37:41,492 DEBUG [AsyncUI] logitech_receiver.settings: dpi: settings read None from 16:37:41,492 INFO [AsyncUI] logitech_receiver.base: New lock 19 16:37:41,492 DEBUG [AsyncUI] logitech_receiver.base: (19) <= w[10 00 8163 000000] 16:37:41,494 DEBUG [MainThread] solaar.ui: status changed: (NONE) None 16:37:41,494 WARNING [MainThread] solaar.ui.icons: icon battery-missing not found in current theme 16:37:41,494 DEBUG [MainThread] solaar.ui.tray: picked device with lowest battery: None 16:37:41,495 DEBUG [MainThread] logitech_receiver.base: (18) <= w[10 00 810D 000000] 16:37:41,495 DEBUG [AsyncUI] logitech_receiver.base: (19) => r[10 00 8F81 630100] 16:37:41,495 DEBUG [ReceiverListener:hidraw5] logitech_receiver.base: (17) => r[10 00 8F81 630100] 16:37:41,495 DEBUG [AsyncUI] logitech_receiver.base: (19) device 0x00 error on request {8163}: 1 = invalid SubID/command 16:37:41,496 INFO [AsyncUI] solaar.configuration: saved {'None:?': {'_name': 'G102 Lightsync Mouse'}, '_version': '1.0.6'} to /home/oxa/.config/solaar/config.json 16:37:41,498 DEBUG [MainThread] logitech_receiver.base: (18) => r[10 00 8F81 630100] 16:37:41,499 DEBUG [MainThread] logitech_receiver.base: (18) => r[10 00 8F81 0D0100] 16:37:41,499 DEBUG [ReceiverListener:hidraw5] logitech_receiver.base: (17) => r[10 00 8F81 0D0100] 16:37:41,499 DEBUG [MainThread] logitech_receiver.base: (18) device 0x00 error on request {810D}: 1 = invalid SubID/command 16:37:41,499 DEBUG [MainThread] logitech_receiver.base: (18) <= w[10 00 8107 000000] 16:37:41,503 DEBUG [ReceiverListener:hidraw5] logitech_receiver.base: (17) => r[10 00 8F81 070100] 16:37:41,503 DEBUG [MainThread] logitech_receiver.base: (18) => r[10 00 8F81 070100] 16:37:41,503 DEBUG [MainThread] logitech_receiver.base: (18) device 0x00 error on request {8107}: 1 = invalid SubID/command 16:37:41,503 WARNING [MainThread] solaar.ui.icons: icon battery-missing not found in current theme ```

Alternatively, if the mouse can also connect via a wireless receiver, you could try using the receiver.

Sorry but the mouse only supports USB-A wired connection.

pfps commented 3 years ago

It looks as if the device talks HID++ 1.0 so there should be something that can be done. The way to find out what is happening is to use a little tool that directly sends commands to the device. Run ./tools/hidconsole /dev/hidrawX where X is the higher node for the mouse. Enter 10000011000000 If there is a response then the device talks HID++. If the response starts 10 00 0011 then the device talks HID++ 2.0, any other response (probably starting 10 00 8F) HID++ 1.0.

You could also try this with the other node for the mouse.

Then you have to try different HID++ 1.0 commands to see what the device understands. However, this can be a frustrating process. From the log you provided none of the commands that Solaar sent were accepted neither DPI nor battery status nor battery charge.

oxalica commented 3 years ago

Run ./tools/hidconsole /dev/hidrawX where X is the higher node for the mouse. Enter 10000011000000

It returns 11 00 FF00 110A0000000000000000000000000000 but I failed to make it work with protocol=1.0.

I found https://github.com/cvuchener/hidpp which also provides some tools for HID++ protocol. It reports the protocol version to be 4.2. Here is some of its output.

> ./src/tools/hidpp-check-device /dev/hidraw5
4.2

> ./src/tools/hidpp-list-devices
/dev/hidraw5: Logitech G102 LIGHTSYNC Gaming Mouse (046d:c092) HID++ 4.2

> ./src/tools/hidpp-list-features /dev/hidraw5
Logitech G102 LIGHTSYNC Gaming Mouse (046d:c092) is a HID++ 4.2 device
Feature 0x01: [0x0001] Feature set
Feature 0x02: [0x0003] Device FW version
Feature 0x03: [0x0005] Device name
Feature 0x04: [0x1801] ? (hidden, internal)
Feature 0x05: [0x1802] Device reset (hidden, internal)
Feature 0x06: [0x1806] Configurable device properties (hidden, internal)
Feature 0x07: [0x1e00] Enable hidden features (hidden)
Feature 0x08: [0x1e22] ? (hidden, internal)
Feature 0x09: [0x1eb0] ? (hidden, internal)
Feature 0x0a: [0x2201] Adjustable dpi
Feature 0x0b: [0x18b1] ? (hidden, internal)
Feature 0x0c: [0x00c2] DFUcontrol 3
Feature 0x0d: [0x8060] Report rate
Feature 0x0e: [0x8071] RGB Effects
Feature 0x0f: [0x8100] Onboard profiles
Feature 0x10: [0x8110] Mouse button spy
Feature 0x11: [0x18a1] ? (hidden, internal)
Feature 0x12: [0x8081] Per-key lighting v2

> ./src/tools/hidpp-mouse-resolution /dev/hidraw5 info
Sensor count: 1
0: min: 50, max: 8000, step: 50

I also checked that its hidpp-mouse-resolution can get or set my mouse DPI successfully.

Then I add this entry for solaar. But it seems still not working.

_D(
    'G102 Lightsync Mouse',
    codename='G102',
    protocol=4.2,
    usbid=0xc092,
    interface=1,
    settings=[_FS.dpi()],
)

It shows nothing on GUI and leaves some errors in console:

> ./bin/solaar

(solaar:705951): Gtk-WARNING **: 00:23:28.220: Could not find the icon 'solaar-init-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
        http://icon-theme.freedesktop.org/releases
Traceback (most recent call last):
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/ui/__init__.py", line 159, in <lambda>
    application.connect('startup', lambda app, startup_hook: _startup(app, startup_hook, use_tray, show_window), startup_hook)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/ui/__init__.py", line 119, in _startup
    startup_hook()
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 304, in start_all
    _process_receiver_event('add', device_info)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 384, in _process_receiver_event
    _start(device_info)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 287, in _start
    rl = ReceiverListener(receiver, _status_callback)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 81, in __init__
    receiver.status.changed(True)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/status.py", line 310, in changed
    _settings.apply_all_settings(d)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/settings.py", line 1206, in apply_all_settings
    persister = getattr(device, 'persister', None)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 359, in persister
    self._persister = _configuration.persister(self)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/configuration.py", line 159, in persister
    elif not entry and device.modelId:  # online new-style device so look for modelId and unitId
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 234, in modelId
    ids = _hidpp20.get_ids(self)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 1065, in get_ids
    ids = feature_request(device, FEATURE.DEVICE_FW_VERSION)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 1025, in feature_request
    if device.online and device.features:
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 267, in _check
    reply = self.device.request(0x0000, _pack('!H', FEATURE.FEATURE_SET))
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 438, in request
    return _base.request(
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/base.py", line 458, in request
    raise _hidpp20.FeatureCallError(number=devnumber, request=request_id, error=error, params=params)
logitech_receiver.hidpp20.FeatureCallError: {'number': 0, 'request': 10, 'error': 10, 'params': b'\x00\x01'}
pfps commented 3 years ago

So the G102 is an unusual device in that it uses an interface other than 2 but but uses HID++ 2.0. The only real distinction is between 1.0 and 2.0 or more - 4.x is mostly the same as 2.0. So you appear to have done the right thing in describing the device.

But it appears that Solaar is doing something wrong. Please run with the -dd flag and attach the output so that I can see exactly what communication with the device is happening.

pfps commented 3 years ago

You could also run bin/solar -dd show, which would produce similar output.

oxalica commented 3 years ago

(It seems always trying to get battery level which is not available, even though I doesn't specify it in the descriptor. Not sure if it is an issue.)

> ./bin/solaar -dd show
13:58:30,860    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Down"
13:58:30,860    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Up"
13:58:30,868    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
13:58:30,910    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 0 FILTER 1
13:58:30,911    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 1 FILTER 1
13:58:30,912    DEBUG [MainThread] solaar.cli: [/dev/hidraw5] => <Device(0,C092,G102 Lightsync Mouse,?)>
Wired Devices
13:58:30,915    DEBUG [MainThread] logitech_receiver.base: (10) pinging device 0
13:58:30,915     INFO [MainThread] logitech_receiver.base: New lock 10
13:58:30,915    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 00 0018 00004A]
13:58:30,919    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 00 FF00 180A0000000000000000000000000000]
13:58:38,927  WARNING [MainThread] logitech_receiver.base: (10) timeout (8.01/8.00) on device 0 ping
  1: G102 Lightsync Mouse
     Device path  : /dev/hidraw5
     USB id       : 046d:C092
     Codename     : G102
     Kind         : mouse
     Protocol     : HID++ 2.0
     Serial number: ?
     Battery: unknown (device is offline).

It fails on feature request. But hidpp's hidpp-list-features can retrieve features successfully. Not sure if it helps.

> ./bin/solaar -dd
13:59:13,378     INFO [MainThread] root: language en_US (UTF-8), translations path None
13:59:13,739    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Down"
13:59:13,739    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Up"
13:59:13,747    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
13:59:13,751  WARNING [MainThread] solaar.upower: failed to register suspend/resume callbacks
13:59:13,790    DEBUG [MainThread] solaar.ui: startup registered=True, remote=False
13:59:13,792    DEBUG [AsyncUI] solaar.tasks: started

(solaar:733895): Gtk-WARNING **: 13:59:13.818: Could not find the icon 'solaar-init-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
        http://icon-theme.freedesktop.org/releases
13:59:13,826    DEBUG [MainThread] solaar.ui.icons: sys.path[0] = /home/oxa/repo/tmp/Solaar/lib
13:59:13,827    DEBUG [MainThread] solaar.ui.icons: looking for icons in /home/oxa/repo/tmp/Solaar/icons
13:59:13,827    DEBUG [MainThread] solaar.ui.icons: looking for icons in /home/oxa/repo/tmp/Solaar/share/solaar/icons
13:59:13,827    DEBUG [MainThread] solaar.ui.icons: icon theme paths: ['/home/oxa/repo/tmp/Solaar/share/solaar/icons', '/home/oxa/.local/share/icons', '/home/oxa/.icons', '/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/share/icons', '/nix/store/wl5vdx1g9wkjgsjb8z1g9gxp5dwr8dfx-patchelf-0.12/share/icons', '/nix/store/sc3cq7qkkdnlv74f1h2s5445zwzx5bph-gobject-introspection-1.68.0-dev/share/icons', '/nix/store/9cdbgzwlfvgws9ny4w1rdy31sva2qbdp-gtk+3-3.24.30-dev/share/icons', '/nix/store/jdxzb4s5nkdwwy9k9plgqrf3pcm1i3f1-atk-2.36.0-dev/share/icons', '/nix/store/jzqd9pnf971hgjni4srw6sgrxi6y57nx-gdk-pixbuf-2.42.6-dev/share/icons', '/nix/store/3ciga7lydf8wa2f7n4k18qsq9d0rnsy3-gsettings-desktop-schemas-40.0/share/icons', '/nix/store/cpkbc83ha7n646gg6jfpsbqlc3fbkcq2-pango-1.48.5-dev/share/icons', '/nix/store/2f29irshp97xgay5dk5vn0yih26j7bm9-harfbuzz-2.8.2-dev/share/icons', '/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/share/pixmaps', '/nix/store/wl5vdx1g9wkjgsjb8z1g9gxp5dwr8dfx-patchelf-0.12/share/pixmaps', '/nix/store/sc3cq7qkkdnlv74f1h2s5445zwzx5bph-gobject-introspection-1.68.0-dev/share/pixmaps', '/nix/store/9cdbgzwlfvgws9ny4w1rdy31sva2qbdp-gtk+3-3.24.30-dev/share/pixmaps', '/nix/store/jdxzb4s5nkdwwy9k9plgqrf3pcm1i3f1-atk-2.36.0-dev/share/pixmaps', '/nix/store/jzqd9pnf971hgjni4srw6sgrxi6y57nx-gdk-pixbuf-2.42.6-dev/share/pixmaps', '/nix/store/3ciga7lydf8wa2f7n4k18qsq9d0rnsy3-gsettings-desktop-schemas-40.0/share/pixmaps', '/nix/store/cpkbc83ha7n646gg6jfpsbqlc3fbkcq2-pango-1.48.5-dev/share/pixmaps', '/nix/store/2f29irshp97xgay5dk5vn0yih26j7bm9-harfbuzz-2.8.2-dev/share/pixmaps']
13:59:13,829  WARNING [MainThread] solaar.ui.icons: failed to detect icons
13:59:13,875     INFO [MainThread] solaar.listener: starting receiver listening threads
13:59:13,882    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 0 FILTER 1
13:59:13,883    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C092 INTERFACE 1 FILTER 1
13:59:13,883     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw5', vendor_id='046D', product_id='C092', serial='205C346B5442', release=None, manufacturer=None, product=None, interface=1, driver='hid-generic', bus_id=3, isDevice=True)
13:59:13,884    DEBUG [MainThread] solaar.configuration: load => {}
13:59:13,884     INFO [MainThread] logitech_receiver.base: New lock 17
13:59:13,884    DEBUG [MainThread] logitech_receiver.base: (17) <= w[11 00 000A 00010000000000000000000000000000]
13:59:13,887    DEBUG [MainThread] logitech_receiver.base: (17) => r[11 00 FF00 0A0A0000000000000000000000000000]
13:59:13,887    ERROR [MainThread] logitech_receiver.base: (17) device 0 error on feature request {000A}: 10 = None
Traceback (most recent call last):
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/ui/__init__.py", line 159, in <lambda>
    application.connect('startup', lambda app, startup_hook: _startup(app, startup_hook, use_tray, show_window), startup_hook)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/ui/__init__.py", line 119, in _startup
    startup_hook()
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 304, in start_all
    _process_receiver_event('add', device_info)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 384, in _process_receiver_event
    _start(device_info)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 287, in _start
    rl = ReceiverListener(receiver, _status_callback)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/listener.py", line 81, in __init__
    receiver.status.changed(True)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/status.py", line 309, in changed
    _log.info('%s pushing device settings %s', d, d.settings)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 342, in settings
    if self.persister and self.descriptor and self.descriptor.settings:
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 359, in persister
    self._persister = _configuration.persister(self)
  File "/home/oxa/repo/tmp/Solaar/lib/solaar/configuration.py", line 159, in persister
    elif not entry and device.modelId:  # online new-style device so look for modelId and unitId
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 234, in modelId
    ids = _hidpp20.get_ids(self)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 1065, in get_ids
    ids = feature_request(device, FEATURE.DEVICE_FW_VERSION)
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 1025, in feature_request
    if device.online and device.features:
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/hidpp20.py", line 267, in _check
    reply = self.device.request(0x0000, _pack('!H', FEATURE.FEATURE_SET))
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/device.py", line 438, in request
    return _base.request(
  File "/home/oxa/repo/tmp/Solaar/lib/logitech_receiver/base.py", line 458, in request
    raise _hidpp20.FeatureCallError(number=devnumber, request=request_id, error=error, params=params)
logitech_receiver.hidpp20.FeatureCallError: {'number': 0, 'request': 10, 'error': 10, 'params': b'\x00\x01'}
13:59:13,892    DEBUG [MainThread] solaar.ui: activate
13:59:16,187    DEBUG [MainThread] solaar.ui: shutdown
13:59:16,188     INFO [MainThread] solaar.configuration: saved {'_version': '1.0.6'} to /home/oxa/.config/solaar/config.json
13:59:16,188    DEBUG [AsyncUI] solaar.tasks: stopped
pfps commented 3 years ago

What Solaar is trying to do is to find out what short numbers the device is using for the features it implements. This is the information shown by hidpp-list-features. Devices that use HID++ >=2.0 are "self describing" in that they can be queried for the features they support.

I think the problem is that Solaar is sending a long message when the device requires a short message. HID++ messages can be either short or long. Some combinations of device, interface, and feature require long messages; some require short messages; many can be either. Solaar is set up to mostly send long messages.

The way to check is to clone Solaar and change line 444 of lib/logitech_receiver to

                long_message=self.bluetooth

and run with the -dd flag again and provide the output.

oxalica commented 3 years ago

Sorry for the late reply.

I suppose you mean lib/logitech_receiver/devices.py:444. It doesn't work no matter I override long_message in request to True or False.

Truncated output of ./bin/solaar -dd: Short

18:02:47,130    DEBUG [MainThread] logitech_receiver.base: (17) <= w[10 00 000B 000100]
18:02:47,134    DEBUG [MainThread] logitech_receiver.base: (17) => r[11 00 FF00 0B0A0000000000000000000000000000]
18:02:47,135    ERROR [MainThread] logitech_receiver.base: (17) device 0 error on feature request {000B}: 10 = None

Long

18:05:24,071    DEBUG [MainThread] logitech_receiver.base: (17) <= w[11 00 000A 00010000000000000000000000000000]
18:05:24,074    DEBUG [MainThread] logitech_receiver.base: (17) => r[11 00 FF00 0A0A0000000000000000000000000000]
18:05:24,074    ERROR [MainThread] logitech_receiver.base: (17) device 0 error on feature request {000A}: 10 = None

I also check the ping function at line 452 which is called when running ./bin/solaar -dd show. It also doesn't work no matter I force the message to be long or short in this function.

Short

18:07:27,483    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 00 0018 0000E7]
18:07:27,488    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 00 FF00 180A0000000000000000000000000000]
<long time waiting>
18:07:35,493  WARNING [MainThread] logitech_receiver.base: (10) timeout (8.01/8.00) on device 0 ping

Long

18:07:45,108    DEBUG [MainThread] logitech_receiver.base: (10) <= w[11 00 001C 00005400000000000000000000000000]
18:07:45,112    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 00 FF00 1C0A0000000000000000000000000000]
<long time waiting>
18:07:53,120  WARNING [MainThread] logitech_receiver.base: (10) timeout (8.01/8.00) on device 0 ping

If hidpp can successfully get the result. Does it mean solaar just failed to parse the message received from mouse? Or solaar sent the wrong request data that the mouse cannot recognize?

pfps commented 3 years ago

The problem is likely that Solaar is sending the wrong message. Can you run hidpp with the -vdebug flag and post the output? Thanks.

oxalica commented 3 years ago

I ran several commands and here's the result: https://gist.github.com/oxalica/c04f471a4f44d52b061889468d05947c

pfps commented 3 years ago

Thanks. I see the difference. It should be easy to fix.

pfps commented 3 years ago

Some (older) directly connected devices require 0xFF for their device number. Most directly-connected devices permit 0x0 as well, which Solaar used. I changed this to the official 0xFF. I also added the G102 to descriptors.py.

So try PR #1234 and see whether it works for you.

To download and work with Solar

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

Run Solaar as bin/solaar from this directory.

To run PR #1234, 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/1234/head:pull_1234
git checkout pull_1234

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_1234
git fetch origin pull/1234/head
git reset --hard FETCH_HEAD