From ad2660a1bd57d5c037ca229f66f3043ada6dc1a0 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Mon, 22 Jun 2020 13:01:16 -0400 Subject: [PATCH] receiver: minor updates to key remapping --- docs/usage.md | 15 +++++++++------ lib/logitech_receiver/settings_templates.py | 8 +++++--- lib/logitech_receiver/special_keys.py | 8 ++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index f0cb6052..81624220 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -84,17 +84,16 @@ but it still can be unpaired if its receiver allows unpairing. ![Solaar-main-window-offline](Solaar-main-window-offline.png) -#### Reprogramming key and button actions +#### Remapping key and button actions -For many devices Solaar can reprogram some of their keys or buttons to +For many devices Solaar can remap some of their keys or buttons to perform a different action. (This actually changes the information that the device sends when the key or button is activated.) Only some keys on some -devices can be reprogrammed and they can only be reprogrammed to a limited -number of actions. The reprogramming is done in Solaar by selecting a key +devices can be remapped and they can only be remapped to a limited +number of actions. The remapping is done in Solaar by selecting a key or button in the left-hand box on the ``Action'' setting line and then selecting the action to be performed in the right-hand box. The default -action is always the shown first in the list. If the key or button has not -been reprogrammed the action box will be blank. As with all settings, +action is always the shown first in the list. As with all settings, Solaar will remembers past action settings and restore them on the device from then on. @@ -103,6 +102,10 @@ from then on. The names of the keys, buttons, and actions are mostly taken from Logitech documentation and may not be completely obvious. +It is possible to end up with an unusable system, for example by having no +way to do a mouse left click, so exercise caution when remapping keys or +buttons that are needed to operate your system. + ## Solaar command line interface diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 4df85401..a600d782 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -203,7 +203,7 @@ _POINTER_SPEED = ('pointer_speed', _("Sensitivity (Pointer Speed)"), None) _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")) _BACKLIGHT = ('backlight', _("Backlight"), _("Turn illumination on or off on keyboard.")) -_REPROGRAMMABLE_KEYS = ('reprogrammable-keys', _("Actions"), _("Change the action for the key")) +_REPROGRAMMABLE_KEYS = ('reprogrammable-keys', _("Actions"), _("Change the action for the key or button")) _DISABLE_KEYS = ('disable-keyboard-keys', _("Disable keys"), _("Disable specific keyboard keys.")) # @@ -368,6 +368,7 @@ def _feature_pointer_speed(): # the keys for the choice map are Logitech controls (from special_keys) # each choice value is a NamedInt with the string from a task (to be shown to the user) # and the integer being the control number for that task (to be written to the device) +# Solaar only remaps keys (controlled by key gmask and group), not other key reprogramming def _feature_reprogrammable_keys_choices(device): count = device.feature_request(_F.REPROG_CONTROLS_V4) assert count, 'Oops, reprogrammable key count cannot be retrieved!' @@ -382,9 +383,10 @@ def _feature_reprogrammable_keys_choices(device): keys[i] = ( _special_keys.CONTROL[key], action, flags, gmask ) groups[group].append(action) for k in keys: - if k[2] & _special_keys.KEY_FLAG.reprogrammable: + # if k[2] & _special_keys.KEY_FLAG.reprogrammable: # this flag is only to show in UI, ignore in Solaar + if k[3]: # only keys with a non-zero gmask are remappable key_choices = [ k[1] ] # it should always be possible to map the key to itself - for g in range(1,9): # group 0 and gmask 0 (k[3]) don't appear to work, don't consider group 0 + for g in range(1,9): # group 0 and gmask 0 (k[3]) does not indicate remappability so don't consider group 0 if ( k[3]==0 if g==0 else k[3] & 2**(g-1) ): for gm in groups[g]: if int(gm) != int(k[0]): # don't put itself in twice diff --git a/lib/logitech_receiver/special_keys.py b/lib/logitech_receiver/special_keys.py index 36fa8c5f..70229913 100644 --- a/lib/logitech_receiver/special_keys.py +++ b/lib/logitech_receiver/special_keys.py @@ -105,8 +105,8 @@ CONTROL = _NamedInts( PAUSE_BREAK=0x004D, SCROLL_LOCK=0x004E, CONTEXTUAL_MENU=0x004F, - LEFT_CLICK=0x0050, - RIGHT_CLICK=0x0051, + Left_Button=0x0050, # LEFT_CLICK + Right_Button=0x0051, # RIGHT_CLICK Middle_Button=0x0052, # MIDDLE_BUTTON Back_Button=0x0053, # from M510v2 was BACK_AS_BUTTON_4 Back=0x0054, # BACK_AS_HID @@ -274,8 +274,8 @@ TASK = _NamedInts( ZoomBtnOutSet2=0x0035, ZoomBtnOutSet=0x0036, ZoomBtnResetSet=0x0037, - LeftClick=0x0038, - RightClick=0x0039, + Left_Click=0x0038, # LeftClick + Right_Click=0x0039, # RightClick Mouse_Middle_Button=0x003A, # from M510v2 was MiddleMouseButton Back=0x003B, Mouse_Back_Button=0x003C, # from M510v2 was BackEx