From ed9aa76547b4455a9073b43678b36693569c67ff Mon Sep 17 00:00:00 2001 From: Alex Cherkayev Date: Mon, 19 Nov 2018 19:55:55 +0200 Subject: [PATCH] Added status info on features MOUSE_POINTER, VERTICAL_SCROLLING, HI_RES_SCROLLING, POINTER_SPEED and LOWRES_WHEEL to solaar show. Renamed functions for HI_RES_SCROLLING and LOWRES_WHEEL features for consistency. --- lib/logitech_receiver/descriptors.py | 2 +- lib/logitech_receiver/hidpp20.py | 37 +++++++++++++++++++++ lib/logitech_receiver/settings_templates.py | 24 ++++++++----- lib/solaar/cli/show.py | 35 +++++++++++++++++++ 4 files changed, 89 insertions(+), 9 deletions(-) diff --git a/lib/logitech_receiver/descriptors.py b/lib/logitech_receiver/descriptors.py index 6347ccec..8ec28248 100644 --- a/lib/logitech_receiver/descriptors.py +++ b/lib/logitech_receiver/descriptors.py @@ -252,7 +252,7 @@ _D('Wireless Mouse M315') _D('Wireless Mouse M317') _D('Wireless Mouse M325', protocol=2.0, wpid='400A', settings=[ - _FS.smooth_scroll(), + _FS.hi_res_scroll(), ]) _D('Wireless Mouse M345', protocol=2.0, wpid='4017') _D('Wireless Mouse M350', protocol=1.0, wpid='101C', diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 21a07c5f..a24e1f86 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -485,6 +485,43 @@ def get_mouse_pointer_info(device): 'suggest_vertical_orientation': suggest_vertical_orientation } + +def get_vertical_scrolling_info(device): + vertical_scrolling_info = feature_request(device, FEATURE.VERTICAL_SCROLLING) + if vertical_scrolling_info: + roller, ratchet, lines = _unpack('!BBB', vertical_scrolling_info[:3]) + roller_type = ('reserved', 'standard', 'reserved', '3G', 'micro', 'normal touch pad', 'inverted touch pad', 'reserved')[roller] + return { + 'roller': roller_type, + 'ratchet': ratchet, + 'lines': lines + } + + +def get_hi_res_scrolling_info(device): + hi_res_scrolling_info = feature_request(device, FEATURE.HI_RES_SCROLLING) + if hi_res_scrolling_info: + mode, resolution = _unpack('!BB', hi_res_scrolling_info[:2]) + return mode, resolution + + +def get_pointer_speed_info(device): + pointer_speed_info = feature_request(device, FEATURE.POINTER_SPEED) + if pointer_speed_info: + pointer_speed_hi, pointer_speed_lo = _unpack('!BB', pointer_speed_info[:2]) + #if pointer_speed_lo > 0: + # pointer_speed_lo = pointer_speed_lo + return pointer_speed_hi+pointer_speed_lo/256 + + +def get_lowres_wheel_status(device): + lowres_wheel_status = feature_request(device, FEATURE.LOWRES_WHEEL) + if lowres_wheel_status: + wheel_flag = _unpack('!B', lowres_wheel_status[:1])[0] + wheel_reporting = ('HID', 'HID++')[wheel_flag & 0x01] + return wheel_reporting + + def get_hires_wheel(device): caps = feature_request(device, FEATURE.HIRES_WHEEL, 0x00) mode = feature_request(device, FEATURE.HIRES_WHEEL, 0x10) diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 5407f284..81f6c1db 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -118,6 +118,11 @@ def feature_range(name, feature, min_value, max_value, _SMOOTH_SCROLL = ('smooth-scroll', _("Smooth Scrolling"), _("High-sensitivity mode for vertical scroll with the wheel.")) +_LOW_RES_SCROLL = ('low-res-scroll', _("HID++ Scrolling"), + _("HID++ mode for vertical scroll with the wheel.")) + +_HI_RES_SCROLL = ('hi-res-scroll', _("High Resolution Scrolling"), + _("High-sensitivity mode for vertical scroll with the wheel.")) _HIRES_INV = ('hires-smooth-invert', _("High Resolution Wheel Invert"), _("High-sensitivity wheel invert mode for vertical scroll.")) _HIRES_RES = ('hires-smooth-resolution', _("Wheel Resolution"), @@ -184,14 +189,14 @@ def _feature_k375s_fn_swap(): label=_FN_SWAP[1], description=_FN_SWAP[2], device_kind=(_DK.keyboard,)) -def _feature_smooth_scroll(): - return feature_toggle(_SMOOTH_SCROLL[0], _F.HI_RES_SCROLLING, - label=_SMOOTH_SCROLL[1], description=_SMOOTH_SCROLL[2], +def _feature_hi_res_scroll(): + return feature_toggle(_HI_RES_SCROLL[0], _F.HI_RES_SCROLLING, + label=_HI_RES_SCROLL[1], description=_HI_RES_SCROLL[2], device_kind=(_DK.mouse, _DK.trackball)) def _feature_lowres_smooth_scroll(): - return feature_toggle(_SMOOTH_SCROLL[0], _F.LOWRES_WHEEL, - label=_SMOOTH_SCROLL[1], description=_SMOOTH_SCROLL[2], + return feature_toggle(_LOW_RES_SCROLL[0], _F.LOWRES_WHEEL, + label=_LOW_RES_SCROLL[1], description=_LOW_RES_SCROLL[2], device_kind=(_DK.mouse, _DK.trackball)) def _feature_hires_smooth_invert(): return feature_toggle(_HIRES_INV[0], _F.HIRES_WHEEL, @@ -299,6 +304,7 @@ _SETTINGS_LIST = namedtuple('_SETTINGS_LIST', [ 'new_fn_swap', 'k375s_fn_swap', 'smooth_scroll', + 'hi_res_scroll', 'lowres_smooth_scroll', 'hires_smooth_invert', 'hires_smooth_resolution', @@ -316,6 +322,7 @@ RegisterSettings = _SETTINGS_LIST( new_fn_swap=None, k375s_fn_swap=None, smooth_scroll=_register_smooth_scroll, + hi_res_scroll=None, lowres_smooth_scroll=None, hires_smooth_invert=None, hires_smooth_resolution=None, @@ -330,7 +337,8 @@ FeatureSettings = _SETTINGS_LIST( fn_swap=_feature_fn_swap, new_fn_swap=_feature_new_fn_swap, k375s_fn_swap=_feature_k375s_fn_swap, - smooth_scroll=_feature_smooth_scroll, + smooth_scroll=None, + hi_res_scroll=_feature_hi_res_scroll, lowres_smooth_scroll=_feature_lowres_smooth_scroll, hires_smooth_invert=_feature_hires_smooth_invert, hires_smooth_resolution=_feature_hires_smooth_resolution, @@ -373,8 +381,8 @@ def check_feature_settings(device, already_known): feature = getattr(FeatureSettings, field_name)() already_known.append(feature(device)) - check_feature(_SMOOTH_SCROLL[0], _F.HI_RES_SCROLLING) - check_feature(_SMOOTH_SCROLL[0], _F.LOWRES_WHEEL) + check_feature(_HI_RES_SCROLL[0], _F.HI_RES_SCROLLING) + check_feature(_LOW_RES_SCROLL[0], _F.LOWRES_WHEEL) check_feature(_HIRES_INV[0], _F.HIRES_WHEEL, "hires_smooth_invert") check_feature(_HIRES_RES[0], _F.HIRES_WHEEL, "hires_smooth_resolution") check_feature(_FN_SWAP[0], _F.FN_INVERSION) diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index d1c3f7ac..94553b93 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -118,6 +118,41 @@ def _print_device(dev): print(" HID++ notification") else: print(" HID notification") + if feature == _hidpp20.FEATURE.MOUSE_POINTER: + mouse_pointer = _hidpp20.get_mouse_pointer_info(dev) + if mouse_pointer: + print(" DPI: %s" % mouse_pointer['dpi']) + print(" Acceleration: %s" % mouse_pointer['acceleration']) + if mouse_pointer['suggest_os_ballistics']: + print(" Use OS ballistics") + else: + print(" Override OS ballistics") + if mouse_pointer['suggest_vertical_orientation']: + print(" Provide vertical tuning, trackball") + else: + print(" No vertical tuning, standard mice") + if feature == _hidpp20.FEATURE.VERTICAL_SCROLLING: + vertical_scrolling_info = _hidpp20.get_vertical_scrolling_info(dev) + if vertical_scrolling_info: + print(" Roller type: %s" % vertical_scrolling_info['roller']) + print(" Ratchet per turn: %s" % vertical_scrolling_info['ratchet']) + print(" Scroll lines: %s" % vertical_scrolling_info['lines']) + if feature == _hidpp20.FEATURE.HI_RES_SCROLLING: + scrolling_mode, scrolling_resolution = _hidpp20.get_hi_res_scrolling_info(dev) + if scrolling_mode: + print(" Hi-res scrolling enabled") + else: + print(" Hi-res scrolling disabled") + if scrolling_resolution: + print(" Hi-res scrolling multiplier: %s" % scrolling_resolution) + if feature == _hidpp20.FEATURE.POINTER_SPEED: + pointer_speed = _hidpp20.get_pointer_speed_info(dev) + if pointer_speed: + print(" Pointer Speed: %s" % pointer_speed) + if feature == _hidpp20.FEATURE.LOWRES_WHEEL: + wheel_status = _hidpp20.get_lowres_wheel_status(dev) + if wheel_status: + print(" Wheel Reports: %s" % wheel_status) if dev.online and dev.keys: print (' Has %d reprogrammable keys:' % len(dev.keys))