From 76c5b3e8134680141bcfbe0694fa9b36aee9ba9b Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Mon, 24 Oct 2022 18:21:15 -0400 Subject: [PATCH] settings: add setting to turn scroll ratchet on and off --- lib/logitech_receiver/settings_templates.py | 23 +++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 7188d010..0408e800 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -394,12 +394,22 @@ class DivertGkeys(_Setting): return b'\x00' +class ScrollRatchet(_Setting): + name = 'scroll-ratchet' + label = _('Scroll wheel Ratcheted') + description = _('Switch the mouse wheel between speed-controlled ratcheting and always freespin.') + feature = _F.SMART_SHIFT + choices_universe = _NamedInts(**{_('Freespinning'): 1, _('Ratcheted'): 2}) + validator_class = _ChoicesV + validator_options = {'choices': choices_universe} + + class SmartShift(_Setting): name = 'smart-shift' - label = _('Scroll Wheel Rachet') + label = _('Scroll Wheel Rachet Speed') description = _( - 'Automatically switch the mouse wheel between ratchet and freespin mode.\n' - 'The mouse wheel is always free at 0, and always ratcheted at 50' + 'Use the mouse wheel speed to switch between ratcheted and freespinning.\n' + 'The mouse wheel is always free at 0, and always ratcheted at 50.' ) feature = _F.SMART_SHIFT rw_options = {'read_fnid': 0x00, 'write_fnid': 0x10} @@ -424,11 +434,11 @@ class SmartShift(_Setting): def write(self, device, data_bytes): threshold = _bytes2int(data_bytes) # Freespin at minimum - mode = 1 if threshold == self.MIN_VALUE else 2 + mode = 0 # 1 if threshold <= self.MIN_VALUE else 2 # Ratchet at maximum - if threshold == self.MAX_VALUE: + if threshold >= self.MAX_VALUE: threshold = 255 - data = _int2bytes(mode, count=1) + _int2bytes(threshold, count=1) + data = _int2bytes(mode, count=1) + _int2bytes(max(0, threshold), count=1) return super().write(device, data) min_value = rw_class.MIN_VALUE @@ -1167,6 +1177,7 @@ SETTINGS = [ HiresSmoothInvert, # working HiresSmoothResolution, # working HiresMode, # simple + ScrollRatchet, # simple SmartShift, # working SmartShiftEnhanced, # simple ThumbInvert, # working