device: support bug in backlight on MX Keys S

This commit is contained in:
Peter F. Patel-Schneider 2024-01-28 12:20:00 -05:00
parent 06209d238a
commit 0f8e9b3c0f
1 changed files with 11 additions and 0 deletions

View File

@ -213,12 +213,23 @@ class Backlight(_Setting):
validator_options = {'choices': choices_universe} validator_options = {'choices': choices_universe}
# MX Keys S requires some extra values, as in 11 02 0c1a 000dff000b000b003c00000000000000
# on/off options (from current) effect (FF-no change) level (from current) durations[6] (from current)
class Backlight2(_Setting): class Backlight2(_Setting):
name = 'backlight' name = 'backlight'
label = _('Backlight') label = _('Backlight')
description = _('Turn illumination on or off on keyboard.') description = _('Turn illumination on or off on keyboard.')
feature = _F.BACKLIGHT2 feature = _F.BACKLIGHT2
class rw_class(_FeatureRW):
trail = None
def write(self, device, data_bytes):
if self.trail is None:
reply = device.feature_request(_F.BACKLIGHT2, 0x00)
self.trail = reply[1:2] + b'\xff' + reply[5:12]
return super().write(device, data_bytes + self.trail)
class Backlight3(_Setting): class Backlight3(_Setting):
name = 'backlight-timed' name = 'backlight-timed'