From 4fafd4f6be96529694456c5685f7d9c8de4d39d8 Mon Sep 17 00:00:00 2001 From: spaced Date: Thu, 12 Dec 2019 19:56:08 +0100 Subject: [PATCH] hidpp20: features: add very basic implementation of 0x1982 (Backlight 2) Fixes #547 --- lib/logitech_receiver/descriptors.py | 6 +----- lib/logitech_receiver/hidpp20.py | 1 + lib/logitech_receiver/settings_templates.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/logitech_receiver/descriptors.py b/lib/logitech_receiver/descriptors.py index 6c6b3116..11d28fa4 100644 --- a/lib/logitech_receiver/descriptors.py +++ b/lib/logitech_receiver/descriptors.py @@ -220,11 +220,7 @@ _D('Illuminated Living-Room Keyboard K830', protocol=2.0, wpid='4032', _FS.new_fn_swap() ], ) -_D('Craft Advanced Keyboard', protocol=4.5, wpid='4066', - settings=[ - _FS.new_fn_swap() - ], - ) +_D('Craft Advanced Keyboard', protocol=4.5, wpid='4066') # Mice diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index a24e1f86..160234e7 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -60,6 +60,7 @@ FEATURE = _NamedInts( LED_CONTROL=0x1300, CHANGE_HOST=0x1814, BACKLIGHT=0x1981, + BACKLIGHT2=0x1982, REPROG_CONTROLS=0x1B00, REPROG_CONTROLS_V2=0x1B01, REPROG_CONTROLS_V2_2=0x1B02, # LogiOptions 2.10.73 features.xml diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 5b030827..a72e7121 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -140,6 +140,9 @@ _FN_SWAP = ('fn-swap', _("Swap Fx function"), "and you must hold the FN key to activate their special function.")) _HAND_DETECTION = ('hand-detection', _("Hand Detection"), _("Turn on illumination when the hands hover over the keyboard.")) +_BACKLIGHT = ('backlight', _("Backlight"), + _("Turn illumination on or off on keyboard.")) + _SMART_SHIFT = ('smart-shift', _("Smart Shift"), _("Automatically switch the mouse wheel between ratchet and freespin mode.\n" "The mouse wheel is always free at 0, and always locked at 50")) @@ -189,6 +192,12 @@ def _feature_k375s_fn_swap(): label=_FN_SWAP[1], description=_FN_SWAP[2], device_kind=(_DK.keyboard,)) +# FIXME: This will enable all supported backlight settings, we should allow the users to select which settings they want to enable. +def _feature_backlight2(): + return feature_toggle(_BACKLIGHT[0], _F.BACKLIGHT2, + label=_BACKLIGHT[1], description=_BACKLIGHT[2], + device_kind=(_DK.keyboard,)) + def _feature_hi_res_scroll(): return feature_toggle(_HI_RES_SCROLL[0], _F.HI_RES_SCROLLING, label=_HI_RES_SCROLL[1], description=_HI_RES_SCROLL[2], @@ -312,6 +321,7 @@ _SETTINGS_LIST = namedtuple('_SETTINGS_LIST', [ 'dpi', 'pointer_speed', 'hand_detection', + 'backlight', 'typing_illumination', 'smart_shift', ]) @@ -330,6 +340,7 @@ RegisterSettings = _SETTINGS_LIST( dpi=_register_dpi, pointer_speed=None, hand_detection=_register_hand_detection, + backlight=None, typing_illumination=None, smart_shift=None, ) @@ -346,6 +357,7 @@ FeatureSettings = _SETTINGS_LIST( dpi=_feature_adjustable_dpi, pointer_speed=_feature_pointer_speed, hand_detection=None, + backlight=_feature_backlight2, typing_illumination=None, smart_shift=_feature_smart_shift, ) @@ -391,3 +403,4 @@ def check_feature_settings(device, already_known): check_feature(_DPI[0], _F.ADJUSTABLE_DPI) check_feature(_POINTER_SPEED[0], _F.POINTER_SPEED) check_feature(_SMART_SHIFT[0], _F.SMART_SHIFT) + check_feature(_BACKLIGHT[0], _F.BACKLIGHT2)