pwr-Solaar / Solaar

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

New device N305 Wireless Number pad #1941

Closed audunmg closed 1 year ago

audunmg commented 1 year ago

Information

``` solaar version 1.1.8 3: Number Pad N545 Device path : /dev/hidraw3 WPID : 2006 Codename : N545 Kind : numpad Protocol : HID++ 1.0 Polling rate : 20 ms (50Hz) Serial number: 900A4D98 Firmware: 13.00.B0037 Bootloader: 02.03 Other: 00.01 The power switch is located on the base. Notifications: battery status (0x100000). Features: (none) Battery: full, discharging. ```
``` - 1.1.8 - {_NAME: Number Pad N545, _serial: 900A4D98, _wpid: '2006'} - _NAME: Wireless Mouse B330/M330/M331 _modelId: '405700000000' _serial: B5E948CE _unitId: B5E948CE _wpid: '4057' divert-keys: {80: 0, 81: 0, 82: 0} lowres-smooth-scroll: false pointer_speed: 256 reprogrammable-keys: {80: 80, 81: 81, 82: 82} - _NAME: Multi Device Silent Mouse M585/M590 _absent: [hi-res-scroll, hires-smooth-invert, hires-smooth-resolution, hires-scroll-mode, smart-shift, thumb-scroll-invert, thumb-scroll-mode, onboard_profiles, report_rate, dpi, dpi-sliding, speed-change, backlight, backlight-timed, fn-swap, disable-keyboard-keys, crown-smooth, divert-crown, divert-gkeys, m-key-leds, mr-key-led, multiplatform, gesture2-gestures, gesture2-divert, gesture2-params, sidetone, equalizer, scroll-ratchet] _battery: 4096 _modelId: B01B406B0000 _serial: 5F1B3A82 _unitId: B19881D7 _wpid: 406B change-host: null divert-keys: {82: 0, 83: 0, 86: 0, 91: 0, 93: 0} lowres-scroll-mode: false lowres-smooth-scroll: false persistent-remappable-keys: null pointer_speed: 256 reprogrammable-keys: {80: 80, 81: 81, 82: 82, 83: 83, 86: 86, 91: 91, 93: 93} - _NAME: Touch Mouse M600 _absent: [lowres-scroll-mode, hires-smooth-invert, hires-smooth-resolution, hires-scroll-mode, scroll-ratchet, smart-shift, thumb-scroll-invert, thumb-scroll-mode, onboard_profiles, report_rate, pointer_speed, dpi, speed-change, backlight, backlight-timed, fn-swap, reprogrammable-keys, persistent-remappable-keys, divert-keys, disable-keyboard-keys, crown-smooth, divert-crown, divert-gkeys, m-key-leds, mr-key-led, multiplatform, change-host, gesture2-gestures, gesture2-divert, gesture2-params, sidetone, equalizer] _battery: 4096 _modelId: Touch Mouse M600 _serial: 1946539B _unitId: '00000000' _wpid: 401A hi-res-scroll: false ```

Is your feature request related to a problem? Please describe. The N305 Number pad shows up as N545 and works mostly as normal, but is not customizable.

I think some of the keys are remappable in windows, but not in Solaar, especially two buttons with excel and calculator icon.

Other buttons present are equals, left parenthesis, right parentehsis, backspace, "clear", and the normal Number pad buttons.

Out of the box, they do keypresses for: win+r, typing "calc" (or excel), and enter.

The equals and parenthesis buttons do: turn numlock on, key down Alt_L, Key in the keycode for the symbol, 4,4,0,0 for left parens, 4,4,1,1 for right parens, 6,6,1,1 for equals.

This doesn't work well on linux.

The number pad buttons do: turn on numlock, KP_, turn off numlock, so they work.

The Clear-button is mapped to delete, and backspace and numpad enter work as normal.

Describe the solution you'd like Would be very nice to remap or disable the "macro"-like keys.

Additional context Add any other context or screenshots about the feature request here.

/sys/class/hidraw/hidraw3/device/uevent:

``` DRIVER=logitech-hidpp-device HID_ID=0003:0000046D:00002006 HID_NAME=Logitech N305/B505 HID_PHYS=usb-0000:00:1d.0-1.2.1/input2:3 HID_UNIQ=2006-90-0a-4d-98 MODALIAS=hid:b0003g0102v0000046Dp00002006 ```

cat /sys/class/hidraw/hidraw3/device/report_descriptor | base64

``` BQEJBqEBhQGVCHUBFQAlAQUHGeAp54EClQZ1CBUAJv8ABQcZACr/AIEAhQ4FCJUFdQEVACUBGQEp BZEClQF1A5EBwAUMCQGhAYUDdRCVAhUBJv8CGQEq/wKBAMAGAP8JAaEBhRB1CJUGFQAm/wAJAYEA CQGRAMAGAP8JAqEBhRF1CJUTFQAm/wAJAoEACQKRAMAGAP8JBKEBhSB1CJUOFQAm/wAJQYEACUGR AIUhlR8VACb/AAlCgQAJQpEAwA== ```

I'm more than happy to test or provide more data.

pfps commented 1 year ago

This is an old Logitech device, and uses an old version of the Logitech HID++ protocol. Solaar mostly supports the new version, which does not require that Solaar have descriptions for the capabilities of each device. What Solaar is doing is recognizing your device by its WPID and using the description that Solaar has for this WPID

_D('Number Pad N545', protocol=1.0, wpid='2006', registers=(_R.battery_status, ))

It looks as if this WPID (which identifies the internal controls for the device) has been used for multiple models, probably for different regions.

It is entirely possible that the Logitech driver for this device does something special with it that Solaar cannot do, as Solaar is not a device driver. To determine whether this device has the capability of doing anything that Solaar can control would require you to probe the device using the Solaar hidconsole tool. To determine how to probe and how to interpret the answer would require observing how the Logitech driver communicates with the device under Windows, using some tool in Windows to capture the interactions or getting the HID++ 1.0 specification from Logitech under NDA. The former path is how the limited support for HID++ 1.0 devices was developed in Solaar.

So adding support for what you want may be impossible or may only be very difficult and can only be done by you.

Some information on HID++ 1.0 is available at https://github.com/cvuchener/hidpp. Use hidpp-list-devices to find out which devices you have and then hidpp-list-features -d N [-w] /dev/hidrawM to list the registers and features of a device. The -w flag also writes to registers, but may interfere with the workings of the device. If you report back the results then I may be able to look up what the registers do.

audunmg commented 1 year ago

I see.

I'll try to get a USB capture with wireshark and a VM when time allows.

It doesn't seem to have many registers, maybe that helps?

Output of hidpp-list-features -d 3 /dev/hidraw2:

N305/B505 (046d:2006) is a HID++ 1.0 device
Register 0x00 read   3: 10 00 00
Register 0x01 read   3: 00 00 00
Register 0x07 read   3: 07 00 00
Register 0x09 read   3: 00 00 00
Register 0xd0 read   3: 00 00 00
Register 0xf1 read   3: Invalid value (0x03)
Register 0xf3 read   3: 00 00 00

Output of hidpp-list-features -d 3 -w /dev/hidraw2:

N305/B505 (046d:2006) is a HID++ 1.0 device
Register 0x00 read   3: 10 00 00
Register 0x00 write  3: 00 00 00
Register 0x01 read   3: 00 00 00
Register 0x01 write  3: 00 00 00
Register 0x07 read   3: 07 00 00
Register 0x09 read   3: 00 00 00
Register 0x09 write  3: 00 00 00
Register 0xd0 read   3: 00 00 00
Register 0xd0 write  3: 00 00 00
Register 0xf0 write  3: Invalid value (0x03)
Register 0xf1 read   3: Invalid value (0x03)
Register 0xf3 read   3: 00 00 00
Register 0xf3 write  3: 00 00 00
Individual features: 100004
 - Enhanced Key Usage

Thank you for pointing me in the right direction.

pfps commented 1 year ago

Register 0 is used to turn on HID++ reporting. The bit in the this register means that the device is reporting changes to its battery state. There are bits in this register that might change how the keys on your device work.

Register 1 is used to enable individual features. Enhanced key usage changes how the Fn key works, either as a normal Fn key or to send HID++ reports, but it is unclear whether the device actually has a Fn key. The other bit in this register is to disable num lock toggle. I'm not sure whether the device has a key that can be used to toggle num lock, though.

Register 7 is used to query battery status. The device is reporting a full battery.

Register 9 is used to toggle Fn status. It may be possible to use this to change how some of the keys on the device work.

Register D0 is unknown.

Register F0 is unknown.

Register F1 is used to get information about the firmware version.

Register F3 is unknown.

It may be that some numpads with this WPID have a Fn key. It also might be possible to use the registers to toggle Fn status and thus change how the function keys - probably the top three keys - work. It also might be possible to have some or all keys send HID++ reports that can be used in Solaar rules.

Changing the Fn status is the easiest. Clone Solaar and change the device description in lib/logitech_receiver/descriptors.py to

_D('Number Pad N545', protocol=1.0, wpid='2006', registers=(_R.battery_status, ), settings=[_ST.RegisterFnSwap])

Then quit out of Solaar and start it up again as bin/Solaar from your Solaar directory. You should see a setting for Swap Fx function. Change it and see whether the behaviour of any keys change. If this works for you then you don't need to go further.

Changing the keys to send HID++ reports requires more changes to Solaar. The first thing to do would be to send commands to the device to try to get it to change its behaviour. Clone the Solaar if you haven't already done so. Then use ./tools/hidconsole in the Solaar. You have to find out the /dev/hidrawN for the device and its device number, which you can get via solaar show. The device number is the first thing that Solaar show emits.

You then run ./tools/hidconsole /dev/hidrawN for N that you just found out. Send the command

10 DN 80 00 FF FF FF

where DN is the device number as two hexidecimal digits.

If that doesn't produce an error see the result by sending the command

10 DN 81 00 00 00 00

If the result is different from

10 DN 81 00 10 00 00

try using the device and see what changed. Keep hidconsole running. If some keys appear to be doing nothing then see what hidconsole prints for them.

Turning the device off and on again should reset its behaviour.

If the first command did produce an error try

10 DN 80 00 91 00 00

and then query as able and see what changed.

Report back on what you did and the results.

pfps commented 1 year ago

Closing due to no response from submitter.

This issue can be reopened when more information is provided.