diff --git a/docs/capabilities.md b/docs/capabilities.md index f71b6eb1..7493255f 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -51,7 +51,7 @@ connect via a USB cable or via bluetooth can be determined by their USB or Bluetooth product ID. -# Pairing and Unpairing +## Pairing and Unpairing Solaar is able to pair and unpair devices with receivers as supported by the device and receiver. @@ -174,6 +174,18 @@ is sent to the Solaar rule system so that rules can detect these notifications. For more information on Mouse Gestures rule conditions see [the rules page](https://pwr-solaar.github.io/Solaar/rules). +### Keyboard Key Names and Locations + +Solaar uses the standard Logitech names for keyboard keys. Some Logitech keyboards have different icons on some of their keys and have different functionality than suggested by these names. + +Solaar is uses the standard US keyboard layout. This currently only matters for the `Per-key Lighting` setting. Users who want to have the key names for this setting reflect the keyboard layout that they use can create and edit `~/.config/solaar/keys.yaml` which contains a YAML dictionary of key names and locations. For example, switching the `Y` and `Z` keys can be done as: + + Z: 25 + Y: 26 + +This is an experimental feature and may be modified or even eliminated. + + ### Device Profiles Some mice store one or more profiles, which control aspects of the behavior of the device. diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 21a0a081..0752cf15 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -1579,7 +1579,7 @@ class PerKeyLighting(_Settings): label = _("Per-key Lighting") description = _("Control per-key lighting.") feature = _F.PER_KEY_LIGHTING_V2 - keys_universe = _NamedInts.range(1, 254) + keys_universe = _special_keys.KEYCODES choices_universe = _special_keys.COLORS def read(self, cached=True): @@ -1607,7 +1607,7 @@ class PerKeyLighting(_Settings): return map def write_key_value(self, key, value, save=True): - result = super().write_key_value(key, value, save) + result = super().write_key_value(int(key), value, save) if self._device.online: self._device.feature_request(self.feature, 0x70, 0x00) # signal device to make the change return result @@ -1624,7 +1624,8 @@ class PerKeyLighting(_Settings): key_bitmap += device.feature_request(setting_class.feature, 0x00, 0x00, 0x02)[2:] for i in range(1, 255): if (key_bitmap[i // 8] >> i % 8) & 0x01: - choices_map[setting_class.keys_universe[i]] = setting_class.choices_universe + key = setting_class.keys_universe[i] if i in setting_class.keys_universe else _NamedInt(i, "KEY " + str(i)) + choices_map[key] = setting_class.choices_universe result = cls(choices_map) if choices_map else None return result diff --git a/lib/logitech_receiver/special_keys.py b/lib/logitech_receiver/special_keys.py index 149bcb6e..660e2734 100644 --- a/lib/logitech_receiver/special_keys.py +++ b/lib/logitech_receiver/special_keys.py @@ -17,9 +17,16 @@ # Reprogrammable keys information # Mostly from Logitech documentation, but with some edits for better Lunix compatibility +import os as _os + +import yaml as _yaml + from .common import NamedInts as _NamedInts from .common import UnsortedNamedInts as _UnsortedNamedInts +_XDG_CONFIG_HOME = _os.environ.get("XDG_CONFIG_HOME") or _os.path.expanduser(_os.path.join("~", ".config")) +_keys_file_path = _os.path.join(_XDG_CONFIG_HOME, "solaar", "keys.yaml") + #