diff --git a/lib/logitech/unifying_receiver/hidpp20.py b/lib/logitech/unifying_receiver/hidpp20.py index 821fdd76..fd6e29dd 100644 --- a/lib/logitech/unifying_receiver/hidpp20.py +++ b/lib/logitech/unifying_receiver/hidpp20.py @@ -25,6 +25,7 @@ from .common import (FirmwareInfo as _FirmwareInfo, ReprogrammableKeyInfo as _ReprogrammableKeyInfo, KwException as _KwException, NamedInts as _NamedInts) +from . import special_keys # # @@ -82,30 +83,6 @@ BATTERY_STATUS = _NamedInts( invalid_battery=0x05, thermal_error=0x06) -KEY = _NamedInts( - Volume_Up=0x0001, - Volume_Down=0x0002, - Mute=0x0003, - Play__Pause=0x0004, - Next=0x0005, - Previous=0x0006, - Stop=0x0007, - Application_Switcher=0x0008, - Calculator=0x000A, - Mail=0x000E, - Home=0x001A, - Music=0x001D, - Search=0x0029, - Sleep=0x002F) -KEY._fallback = lambda x: 'unknown:%04X' % x - -KEY_FLAG = _NamedInts( - reprogrammable=0x10, - FN_sensitive=0x08, - nonstandard=0x04, - is_FN=0x02, - mse=0x01) - ERROR = _NamedInts( unknown=0x01, invalid_argument=0x02, @@ -285,7 +262,9 @@ class KeysArray(object): keydata = feature_request(self.device, FEATURE.REPROGRAMMABLE_KEYS, 0x10, index) if keydata: key, key_task, flags = _unpack('!HHB', keydata[:5]) - self.keys[index] = _ReprogrammableKeyInfo(index, KEY[key], KEY[key_task], flags) + ctrl_id_text = special_keys.CONTROL[key] + ctrl_task_text = special_keys.TASK[key_task] + self.keys[index] = _ReprogrammableKeyInfo(index, ctrl_id_text, ctrl_task_text, flags) return self.keys[index] diff --git a/lib/logitech/unifying_receiver/special_keys.py b/lib/logitech/unifying_receiver/special_keys.py new file mode 100644 index 00000000..bb2975b3 --- /dev/null +++ b/lib/logitech/unifying_receiver/special_keys.py @@ -0,0 +1,51 @@ +# +# Reprogrammable keys information +# + +from __future__ import absolute_import, division, print_function, unicode_literals + +from .common import NamedInts as _NamedInts + +CONTROL = _NamedInts( + Volume_Up=0x0001, + Volume_Down=0x0002, + Mute=0x0003, + Play__Pause=0x0004, + Next=0x0005, + Previous=0x0006, + Stop=0x0007, + Application_Switcher=0x0008, + Calculator=0x000A, + Mail=0x000E, + Home=0x001A, + Music=0x001D, + Search=0x0029, + Sleep=0x002F, +) +CONTROL._fallback = lambda x: 'unknown:%04X' % x + +TASK = _NamedInts( + Volume_Up=0x0001, + Volume_Down=0x0002, + Mute=0x0003, + Play__Pause=0x0004, + Next=0x0005, + Previous=0x0006, + Stop=0x0007, + Application_Switcher=0x0008, + Calculator=0x000A, + Mail=0x000E, + Home=0x001A, + Music=0x001D, + Search=0x0029, + Sleep=0x002F, +) +TASK._fallback = lambda x: 'unknown:%04X' % x + +KEY_FLAG = _NamedInts( + reprogrammable=0x10, + FN_sensitive=0x08, + nonstandard=0x04, + is_FN=0x02, + mse=0x01 +) diff --git a/lib/solaar/cli.py b/lib/solaar/cli.py index 391f0762..8d1ed3ef 100644 --- a/lib/solaar/cli.py +++ b/lib/solaar/cli.py @@ -132,7 +132,7 @@ def _print_device(dev, verbose=False): if dev.power_switch_location: print (" The power switch is located on the", dev.power_switch_location) - from logitech.unifying_receiver import hidpp10, hidpp20 + from logitech.unifying_receiver import hidpp10, hidpp20, special_keys if p > 0: if dev.features: print (" Supports %d HID++ 2.0 features:" % len(dev.features)) @@ -146,7 +146,7 @@ def _print_device(dev, verbose=False): if dev.keys: print (" Has %d reprogrammable keys:" % len(dev.keys)) for k in dev.keys: - flags = hidpp20.KEY_FLAG.flag_names(k.flags) + flags = special_keys.KEY_FLAG.flag_names(k.flags) print (" %2d: %-20s => %-20s %s" % (k.index, k.key, k.task, ', '.join(flags))) if p > 0: