settings: add setting to turn scroll ratchet on and off

This commit is contained in:
Peter F. Patel-Schneider 2022-10-24 18:21:15 -04:00
parent 5cd3ac60c5
commit 76c5b3e813
1 changed files with 17 additions and 6 deletions

View File

@ -394,12 +394,22 @@ class DivertGkeys(_Setting):
return b'\x00' 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): class SmartShift(_Setting):
name = 'smart-shift' name = 'smart-shift'
label = _('Scroll Wheel Rachet') label = _('Scroll Wheel Rachet Speed')
description = _( description = _(
'Automatically switch the mouse wheel between ratchet and freespin mode.\n' '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' 'The mouse wheel is always free at 0, and always ratcheted at 50.'
) )
feature = _F.SMART_SHIFT feature = _F.SMART_SHIFT
rw_options = {'read_fnid': 0x00, 'write_fnid': 0x10} rw_options = {'read_fnid': 0x00, 'write_fnid': 0x10}
@ -424,11 +434,11 @@ class SmartShift(_Setting):
def write(self, device, data_bytes): def write(self, device, data_bytes):
threshold = _bytes2int(data_bytes) threshold = _bytes2int(data_bytes)
# Freespin at minimum # 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 # Ratchet at maximum
if threshold == self.MAX_VALUE: if threshold >= self.MAX_VALUE:
threshold = 255 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) return super().write(device, data)
min_value = rw_class.MIN_VALUE min_value = rw_class.MIN_VALUE
@ -1167,6 +1177,7 @@ SETTINGS = [
HiresSmoothInvert, # working HiresSmoothInvert, # working
HiresSmoothResolution, # working HiresSmoothResolution, # working
HiresMode, # simple HiresMode, # simple
ScrollRatchet, # simple
SmartShift, # working SmartShift, # working
SmartShiftEnhanced, # simple SmartShiftEnhanced, # simple
ThumbInvert, # working ThumbInvert, # working