From 17a7b0689e22491d92de3639bfa2605b130b6ea3 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Thu, 3 Mar 2022 11:47:39 -0500 Subject: [PATCH] settings: add BACKLIGHT3 setting template --- lib/logitech_receiver/settings.py | 10 ++++---- lib/logitech_receiver/settings_templates.py | 26 ++++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/logitech_receiver/settings.py b/lib/logitech_receiver/settings.py index 4d31e24a..59a54aeb 100644 --- a/lib/logitech_receiver/settings.py +++ b/lib/logitech_receiver/settings.py @@ -687,15 +687,12 @@ class RegisterRW: class FeatureRW: - __slots__ = ('feature', 'read_fnid', 'write_fnid', 'prefix', 'no_reply') - kind = _NamedInt(0x02, _('feature')) default_read_fnid = 0x00 default_write_fnid = 0x10 - default_prefix = b'' def __init__( - self, feature, read_fnid=default_read_fnid, write_fnid=default_write_fnid, prefix=default_prefix, no_reply=False + self, feature, read_fnid=default_read_fnid, write_fnid=default_write_fnid, prefix=b'', suffix=b'', no_reply=False ): assert isinstance(feature, _NamedInt) self.feature = feature @@ -703,6 +700,7 @@ class FeatureRW: self.write_fnid = write_fnid self.no_reply = no_reply self.prefix = prefix + self.suffix = suffix def read(self, device, data_bytes=b''): assert self.feature is not None @@ -710,7 +708,9 @@ class FeatureRW: def write(self, device, data_bytes): assert self.feature is not None - reply = device.feature_request(self.feature, self.write_fnid, self.prefix, data_bytes, no_reply=self.no_reply) + reply = device.feature_request( + self.feature, self.write_fnid, self.prefix, data_bytes, self.suffix, no_reply=self.no_reply + ) return reply if not self.no_reply else True diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index c37b8f27..f2df0f17 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -197,24 +197,33 @@ class K375sFnSwap(FnSwapVirtual): validator_options = {'true_value': b'\x01', 'false_value': b'\x00', 'read_skip_byte_count': 1} -class BacklightVirtual(_Setting): - label = _('Backlight') - description = _('Turn illumination on or off on keyboard.') - - -class Backlight(BacklightVirtual): - name = 'backlight-timed' +class Backlight(_Setting): + name = 'backlight-qualitative' + description = _('Set illumination time for keyboard.') feature = _F.BACKLIGHT choices_universe = _NamedInts(Off=0, Short=5, Medium=20, Long=60, VeryLong=180) validator_class = _ChoicesV validator_options = {'choices': choices_universe} -class Backlight2(BacklightVirtual): +class Backlight2(_Setting): + label = _('Backlight') + description = _('Turn illumination on or off on keyboard.') name = 'backlight' feature = _F.BACKLIGHT2 +class Backlight3(_Setting): + name = 'backlight-timed' + description = _('Set illumination time for keyboard.') + feature = _F.BACKLIGHT3 + rw_options = {'read_fnid': 0x10, 'write_fnid': 0x20, 'suffix': 0x09} + validator_class = _RangeV + min_value = 0 + max_value = 1000 + validator_options = {'byte_count': 2} + + class HiResScroll(_Setting): name = 'hi-res-scroll' label = _('Scroll Wheel High Resolution') @@ -1057,6 +1066,7 @@ SETTINGS = [ MouseGesture, # working Backlight, Backlight2, # working + Backlight3, FnSwap, # simple NewFnSwap, # simple K375sFnSwap, # working