settings: add BACKLIGHT3 setting template
This commit is contained in:
parent
bc398a8720
commit
17a7b0689e
|
@ -687,15 +687,12 @@ class RegisterRW:
|
||||||
|
|
||||||
|
|
||||||
class FeatureRW:
|
class FeatureRW:
|
||||||
__slots__ = ('feature', 'read_fnid', 'write_fnid', 'prefix', 'no_reply')
|
|
||||||
|
|
||||||
kind = _NamedInt(0x02, _('feature'))
|
kind = _NamedInt(0x02, _('feature'))
|
||||||
default_read_fnid = 0x00
|
default_read_fnid = 0x00
|
||||||
default_write_fnid = 0x10
|
default_write_fnid = 0x10
|
||||||
default_prefix = b''
|
|
||||||
|
|
||||||
def __init__(
|
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)
|
assert isinstance(feature, _NamedInt)
|
||||||
self.feature = feature
|
self.feature = feature
|
||||||
|
@ -703,6 +700,7 @@ class FeatureRW:
|
||||||
self.write_fnid = write_fnid
|
self.write_fnid = write_fnid
|
||||||
self.no_reply = no_reply
|
self.no_reply = no_reply
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
self.suffix = suffix
|
||||||
|
|
||||||
def read(self, device, data_bytes=b''):
|
def read(self, device, data_bytes=b''):
|
||||||
assert self.feature is not None
|
assert self.feature is not None
|
||||||
|
@ -710,7 +708,9 @@ class FeatureRW:
|
||||||
|
|
||||||
def write(self, device, data_bytes):
|
def write(self, device, data_bytes):
|
||||||
assert self.feature is not None
|
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
|
return reply if not self.no_reply else True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -197,24 +197,33 @@ class K375sFnSwap(FnSwapVirtual):
|
||||||
validator_options = {'true_value': b'\x01', 'false_value': b'\x00', 'read_skip_byte_count': 1}
|
validator_options = {'true_value': b'\x01', 'false_value': b'\x00', 'read_skip_byte_count': 1}
|
||||||
|
|
||||||
|
|
||||||
class BacklightVirtual(_Setting):
|
class Backlight(_Setting):
|
||||||
label = _('Backlight')
|
name = 'backlight-qualitative'
|
||||||
description = _('Turn illumination on or off on keyboard.')
|
description = _('Set illumination time for keyboard.')
|
||||||
|
|
||||||
|
|
||||||
class Backlight(BacklightVirtual):
|
|
||||||
name = 'backlight-timed'
|
|
||||||
feature = _F.BACKLIGHT
|
feature = _F.BACKLIGHT
|
||||||
choices_universe = _NamedInts(Off=0, Short=5, Medium=20, Long=60, VeryLong=180)
|
choices_universe = _NamedInts(Off=0, Short=5, Medium=20, Long=60, VeryLong=180)
|
||||||
validator_class = _ChoicesV
|
validator_class = _ChoicesV
|
||||||
validator_options = {'choices': choices_universe}
|
validator_options = {'choices': choices_universe}
|
||||||
|
|
||||||
|
|
||||||
class Backlight2(BacklightVirtual):
|
class Backlight2(_Setting):
|
||||||
|
label = _('Backlight')
|
||||||
|
description = _('Turn illumination on or off on keyboard.')
|
||||||
name = 'backlight'
|
name = 'backlight'
|
||||||
feature = _F.BACKLIGHT2
|
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):
|
class HiResScroll(_Setting):
|
||||||
name = 'hi-res-scroll'
|
name = 'hi-res-scroll'
|
||||||
label = _('Scroll Wheel High Resolution')
|
label = _('Scroll Wheel High Resolution')
|
||||||
|
@ -1057,6 +1066,7 @@ SETTINGS = [
|
||||||
MouseGesture, # working
|
MouseGesture, # working
|
||||||
Backlight,
|
Backlight,
|
||||||
Backlight2, # working
|
Backlight2, # working
|
||||||
|
Backlight3,
|
||||||
FnSwap, # simple
|
FnSwap, # simple
|
||||||
NewFnSwap, # simple
|
NewFnSwap, # simple
|
||||||
K375sFnSwap, # working
|
K375sFnSwap, # working
|
||||||
|
|
Loading…
Reference in New Issue