From 360c92f6b0761aa91098a57eee2b7230fa93ddc8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 21 Mar 2017 14:16:09 -0300 Subject: [PATCH] Add support for CLI show to display High Res Wheel settings Add support for the high resolution wheel found on MX Anywhere 2. Signed-off-by: Mauro Carvalho Chehab --- lib/logitech_receiver/hidpp20.py | 27 +++++++++++++++++++++++++++ lib/solaar/cli/show.py | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 7faff999..8b441b6f 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -477,3 +477,30 @@ def get_mouse_pointer_info(device): 'suggest_os_ballistics': suggest_os_ballistics, 'suggest_vertical_orientation': suggest_vertical_orientation } + +def get_hires_wheel(device): + caps = feature_request(device, FEATURE.HIRES_WHEEL, 0x00) + mode = feature_request(device, FEATURE.HIRES_WHEEL, 0x10) + ratchet = feature_request(device, FEATURE.HIRES_WHEEL, 0x030) + + + if caps and mode and ratchet: + # Parse caps + multi, flags = _unpack('!BB', caps[:2]) + + has_invert = (flags & 0x08) != 0 + has_ratchet = (flags & 0x04) != 0 + + # Parse mode + wheel_mode, reserved = _unpack('!BB', mode[:2]) + + target = (wheel_mode & 0x01) != 0 + res = (wheel_mode & 0x02) != 0 + inv = (wheel_mode & 0x04) != 0 + + # Parse Ratchet switch + ratchet_mode, reserved = _unpack('!BB', ratchet[:2]) + + ratchet = (ratchet_mode & 0x01) != 0 + + return multi, has_invert, has_ratchet, inv, res, target, ratchet diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index e69c2a01..d1c3f7ac 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -93,6 +93,31 @@ def _print_device(dev): flags = 0 if flags is None else ord(flags[1:2]) flags = _hidpp20.FEATURE_FLAG.flag_names(flags) print (' %2d: %-22s {%04X} %s' % (index, feature, feature, ', '.join(flags))) + if feature == _hidpp20.FEATURE.HIRES_WHEEL: + wheel = _hidpp20.get_hires_wheel(dev) + if wheel: + multi, has_invert, has_switch, inv, res, target, ratchet = wheel + print(" Multiplier: %s" % multi) + if has_invert: + print(" Has invert") + if inv: + print(" Inverse wheel motion") + else: + print(" Normal wheel motion") + if has_switch: + print(" Has ratchet switch") + if ratchet: + print(" Normal wheel mode") + else: + print(" Free wheel mode") + if res: + print(" High resolution mode") + else: + print(" Low resolution mode") + if target: + print(" HID++ notification") + else: + print(" HID notification") if dev.online and dev.keys: print (' Has %d reprogrammable keys:' % len(dev.keys))