diff --git a/docs/devices.md b/docs/devices.md index 060773f7..434b3ec2 100644 --- a/docs/devices.md +++ b/docs/devices.md @@ -18,11 +18,12 @@ Linux system configuration) are supported: * The DPI can be changed on the [Performance MX Mouse][P_MX]. * Smooth scrolling (higher sensitivity on vertical scrolling with the wheel) can - be toggled on the [M705 Marathon Mouse][M705] and [Anywhere MX Mouse][A_MX]. + be toggled on the [M705 Marathon Mouse][M705]. # Supported devices + Keyboards: | Device | HID++ | Battery | Other features | @@ -33,7 +34,7 @@ Keyboards: | K360 | | | | | K400 Touch | | | | | K750 Solar | 2.0 | yes | FN swap, Lux reading, solar button | -| K800 Illuminated | | yes | FN swap | +| K800 Illuminated | 1.0 | yes | FN swap | Mice: @@ -44,14 +45,14 @@ Mice: | M325 | | | | | | M345 | | | | | | M505 | | | | | -| M510 | | | | | +| M510 | | yes | | | | M515 Couch | 2.0 | yes | - | | -| M525 | | | | | +| M525 | 2.0 | | | | | M705 Marathon | 1.0 | yes | - | smooth scrolling | | T400 Zone Touch | | | | | | T620 Touch | | | | | | Performance MX | 1.0 | yes | r/w | | -| Anywhere MX | | yes | - | smooth scrolling | +| Anywhere MX | | | | | | Cube | | | | | @@ -74,7 +75,7 @@ Mouse-Keyboard combos: | Device | HID++ | Battery | Other features | |------------------|-------|---------|-----------------------------------------| | MK330 | | | | -| MK710 | 1.0 | | FN swap | +| MK710 | 1.0 | yes | FN swap | -- diff --git a/docs/devices/m510.txt b/docs/devices/m510.txt index 8292f476..de0b771f 100644 --- a/docs/devices/m510.txt +++ b/docs/devices/m510.txt @@ -1,8 +1,8 @@ -# ? +# notification flags << ( 0.001) [10 01 8100 000000] '\x10\x01\x81\x00\x00\x00\x00' >> ( 0.062) [10 01 8100 000000] '\x10\x01\x81\x00\x00\x00\x00' -# ? +# smooth scroll << ( 1.063) [10 01 8101 000000] '\x10\x01\x81\x01\x00\x00\x00' >> ( 1.078) [10 01 8101 820000] '\x10\x01\x81\x01\x82\x00\x00' @@ -10,7 +10,7 @@ << ( 2.079) [10 01 8102 000000] '\x10\x01\x81\x02\x00\x00\x00' >> ( 2.094) [10 01 8102 000080] '\x10\x01\x81\x02\x00\x00\x80' -# ? +# battery status << ( 7.263) [10 01 8107 000000] '\x10\x01\x81\x07\x00\x00\x00' >> ( 7.278) [10 01 8107 050000] '\x10\x01\x81\x07\x05\x00\x00' diff --git a/lib/logitech/unifying_receiver/descriptors.py b/lib/logitech/unifying_receiver/descriptors.py index 326b591f..67f21b1b 100644 --- a/lib/logitech/unifying_receiver/descriptors.py +++ b/lib/logitech/unifying_receiver/descriptors.py @@ -74,6 +74,9 @@ def _D(name, codename=None, kind=None, registers=None, settings=None): # # +# Some HID++1.0 registers and HID++2.0 features can be discovered at run-time, +# so they are not specified here. + # Keyboards _D('Wireless Keyboard K230') @@ -82,12 +85,14 @@ _D('Wireless Keyboard K350') _D('Wireless Keyboard K360') _D('Wireless Touch Keyboard K400') _D('Wireless Keyboard K710', + registers={'battery_charge': -0x0D, 'battery_status': 0x07}, settings=[ _register_fn_swap(0x09, true_value=b'\x00\x01', mask=b'\x00\x01'), ], ) _D('Wireless Solar Keyboard K750') _D('Wireless Illuminated Keyboard K800', + registers={'battery_charge': -0x0D, 'battery_status': 0x07}, settings=[ _register_fn_swap(0x09, true_value=b'\x00\x01', mask=b'\x00\x01'), ], @@ -98,11 +103,17 @@ _D('Wireless Illuminated Keyboard K800', _D('Wireless Mouse M315') _D('Wireless Mouse M325') _D('Wireless Mouse M505') -_D('Wireless Mouse M510') +_D('Wireless Mouse M510', + registers={'battery_charge': -0x0D, 'battery_status': 0x07}, + settings=[ + _register_smooth_scroll(0x01, true_value=0x40, mask=0x40), + ], + ) _D('Couch Mouse M515') _D('Wireless Mouse M525') _D('Touch Mouse M600') _D('Marathon Mouse M705', + registers={'battery_charge': 0x0D}, settings=[ _register_smooth_scroll(0x01, true_value=0x40, mask=0x40), # _register_dpi(0x63, _NamedInts(**{'100': 10, '300': 30, '350':35, '500':50})), @@ -112,11 +123,13 @@ _D('Zone Touch Mouse T400') _D('Touch Mouse T620') _D('Logitech Cube', kind='mouse') _D('Anywhere Mouse MX', codename='Anywhere MX', + registers={'battery_charge': 0x0D}, settings=[ _register_smooth_scroll(0x01, true_value=0x40, mask=0x40), ], ) _D('Performance Mouse MX', codename='Performance MX', + registers={'battery_charge': -0x0D, 'battery_status': 0x07}, settings=[ _register_dpi(0x63, _NamedInts.range(0x81, 0x8F, lambda x: str((x - 0x80) * 100))), ], diff --git a/lib/logitech/unifying_receiver/hidpp10.py b/lib/logitech/unifying_receiver/hidpp10.py index 4c0666a8..4b0ec61b 100644 --- a/lib/logitech/unifying_receiver/hidpp10.py +++ b/lib/logitech/unifying_receiver/hidpp10.py @@ -82,7 +82,11 @@ def get_register(device, name, default_number=-1): def get_battery(device): """Reads a device's battery level, if provided by the HID++ 1.0 protocol.""" - reply = get_register(device, 'battery', 0x0D) + if device.protocol >= 2.0: + # let's just assume HID++ 2.0 devices do not provide the battery info in a register + return + + reply = get_register(device, 'battery_charge', 0x0D) if reply: charge = ord(reply[:1]) status = ord(reply[2:3]) & 0xF0