hidpp20: features: add very basic implementation of 0x1982 (Backlight 2)

Fixes #547
This commit is contained in:
spaced 2019-12-12 19:56:08 +01:00 committed by Filipe Laíns
parent 0bec0e02b1
commit 4fafd4f6be
3 changed files with 15 additions and 5 deletions

View File

@ -220,11 +220,7 @@ _D('Illuminated Living-Room Keyboard K830', protocol=2.0, wpid='4032',
_FS.new_fn_swap() _FS.new_fn_swap()
], ],
) )
_D('Craft Advanced Keyboard', protocol=4.5, wpid='4066', _D('Craft Advanced Keyboard', protocol=4.5, wpid='4066')
settings=[
_FS.new_fn_swap()
],
)
# Mice # Mice

View File

@ -60,6 +60,7 @@ FEATURE = _NamedInts(
LED_CONTROL=0x1300, LED_CONTROL=0x1300,
CHANGE_HOST=0x1814, CHANGE_HOST=0x1814,
BACKLIGHT=0x1981, BACKLIGHT=0x1981,
BACKLIGHT2=0x1982,
REPROG_CONTROLS=0x1B00, REPROG_CONTROLS=0x1B00,
REPROG_CONTROLS_V2=0x1B01, REPROG_CONTROLS_V2=0x1B01,
REPROG_CONTROLS_V2_2=0x1B02, # LogiOptions 2.10.73 features.xml REPROG_CONTROLS_V2_2=0x1B02, # LogiOptions 2.10.73 features.xml

View File

@ -140,6 +140,9 @@ _FN_SWAP = ('fn-swap', _("Swap Fx function"),
"and you must hold the FN key to activate their special function.")) "and you must hold the FN key to activate their special function."))
_HAND_DETECTION = ('hand-detection', _("Hand Detection"), _HAND_DETECTION = ('hand-detection', _("Hand Detection"),
_("Turn on illumination when the hands hover over the keyboard.")) _("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"), _SMART_SHIFT = ('smart-shift', _("Smart Shift"),
_("Automatically switch the mouse wheel between ratchet and freespin mode.\n" _("Automatically switch the mouse wheel between ratchet and freespin mode.\n"
"The mouse wheel is always free at 0, and always locked at 50")) "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], label=_FN_SWAP[1], description=_FN_SWAP[2],
device_kind=(_DK.keyboard,)) 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(): def _feature_hi_res_scroll():
return feature_toggle(_HI_RES_SCROLL[0], _F.HI_RES_SCROLLING, return feature_toggle(_HI_RES_SCROLL[0], _F.HI_RES_SCROLLING,
label=_HI_RES_SCROLL[1], description=_HI_RES_SCROLL[2], label=_HI_RES_SCROLL[1], description=_HI_RES_SCROLL[2],
@ -312,6 +321,7 @@ _SETTINGS_LIST = namedtuple('_SETTINGS_LIST', [
'dpi', 'dpi',
'pointer_speed', 'pointer_speed',
'hand_detection', 'hand_detection',
'backlight',
'typing_illumination', 'typing_illumination',
'smart_shift', 'smart_shift',
]) ])
@ -330,6 +340,7 @@ RegisterSettings = _SETTINGS_LIST(
dpi=_register_dpi, dpi=_register_dpi,
pointer_speed=None, pointer_speed=None,
hand_detection=_register_hand_detection, hand_detection=_register_hand_detection,
backlight=None,
typing_illumination=None, typing_illumination=None,
smart_shift=None, smart_shift=None,
) )
@ -346,6 +357,7 @@ FeatureSettings = _SETTINGS_LIST(
dpi=_feature_adjustable_dpi, dpi=_feature_adjustable_dpi,
pointer_speed=_feature_pointer_speed, pointer_speed=_feature_pointer_speed,
hand_detection=None, hand_detection=None,
backlight=_feature_backlight2,
typing_illumination=None, typing_illumination=None,
smart_shift=_feature_smart_shift, 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(_DPI[0], _F.ADJUSTABLE_DPI)
check_feature(_POINTER_SPEED[0], _F.POINTER_SPEED) check_feature(_POINTER_SPEED[0], _F.POINTER_SPEED)
check_feature(_SMART_SHIFT[0], _F.SMART_SHIFT) check_feature(_SMART_SHIFT[0], _F.SMART_SHIFT)
check_feature(_BACKLIGHT[0], _F.BACKLIGHT2)